示例#1
0
  /**
   * 查询新闻列表 wfw
   *
   * @param map
   * @param result
   * @return
   */
  @RequestMapping(value = Module.NEWS_MODULE + "/selectNoticeList")
  public String selectNoticeList(
      @RequestParam Map<String, Object> map, Map<String, Object> result) {
    Notice notice = new Notice();

    String ntcTitle = (String) map.get("ntcTitle"); // 消息名称
    if (!"".equals(ntcTitle) && !"null".equals(ntcTitle) && ntcTitle != null) {
      notice.setNtcTitle(ntcTitle);
    }
    String ntcContent = (String) map.get("ntcContent"); // 消息内容
    if (!"".equals(ntcContent) && !"null".equals(ntcContent) && ntcContent != null) {
      notice.setNtcContent(ntcContent);
    }
    String ntcDate = (String) map.get("ntcDate"); // 消息时间

    if (!"".equals(ntcDate) && !"null".equals(ntcDate) && ntcDate != null) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      Date date = null;

      try {
        date = sdf.parse(ntcDate);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      notice.setNtcDate(date);
    }
    List<Notice> noticeList = noticeService.selectBySelective(notice); // 选择性查询
    result.put("noticeList", noticeList);
    result.put("map", map);
    return Module.NEWS_MODULE + "/noticeManager";
  }
示例#2
0
  /**
   * ************** by stt
   *
   * @param map
   * @param result
   * @return
   */
  @Transactional
  @RequestMapping(value = Module.NEWS_MODULE + "/saveNoticeInfo")
  public String saveNoticeInfo(@RequestParam Map<String, Object> map, Map<String, Object> result) {
    int flag = -1;

    Notice notice = new Notice();

    String ntcId = (String) map.get("ntcId");
    String ntcTitle = (String) map.get("ntcTitle");
    String ntcContent = (String) map.get("ntcContent");
    String ntcDate = (String) map.get("ntcDate");
    String orgId = (String) map.get("orgId");
    String userId = (String) map.get("userId");

    notice.setNtcTitle(ntcTitle);
    notice.setNtcContent(ntcContent);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date = null;
    try {
      date = sdf.parse(ntcDate);
    } catch (ParseException e) {
      e.printStackTrace();
    }
    notice.setNtcDate(date);
    notice.setOrgId(orgId);
    notice.setUserId(userId);

    // ID, 插入
    if (ntcId != null && !"".equals(ntcId) && !"null".equals(ntcId)) {

      notice.setNtcId(ntcId);
      flag = noticeService.updateByPrimaryKeySelective(notice);
      if (flag == 1) {
        result.put("status", "更新成功!");
      } else {
        result.put("status", "更新失败!");
      }
    } else { // 新增
      ntcId = BaseUtil.createId();
      notice.setNtcId(ntcId);
      flag = noticeService.insertSelective(notice);

      if (flag == 1) {
        result.put("status", "新增成功!");
      } else {
        result.put("status", "新增失败!");
      }
    }

    return "redirect:selectNoticeList.action";
  }