公告查询页面 限时优先级公告

master
zhangshanxue 2019-10-09 10:46:23 +08:00
parent cc33128057
commit 0bb8547993
10 changed files with 322 additions and 7 deletions

View File

@ -1,26 +1,97 @@
package com.jmfy.controller;
import com.jmfy.dao.impl.NoticeInfoDaoImpl;
import com.jmfy.model.NoticeInfo;
import com.jmfy.model.ServerMail;
import com.jmfy.model.vo.NoticeInfoVo;
import com.jmfy.model.vo.ServerMailVo;
import com.jmfy.utils.JsonUtil;
import com.jmfy.utils.SeqUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Controller
public class NoticeController {
@Resource
private NoticeInfoDaoImpl noticeInfoDao;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Resource
private SeqUtils seqUtils;
@RequestMapping(value = "/publishNotice", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody
int publishNotice(HttpServletRequest request) throws Exception {
String content = request.getParameter("content1");
String title = request.getParameter("title1");
noticeInfoDao.updateNoticeInfo(title,content);
int type = Integer.valueOf(request.getParameter("addType"));
if(type==0){
noticeInfoDao.updateNoticeInfo(title,content);
return 0;
}
String startTime = JsonUtil.date3TimeStamp(request.getParameter("startTime"));
String endTime = JsonUtil.date3TimeStamp(request.getParameter("endTime"));
NoticeInfo noticeInfo = new NoticeInfo();
String id =String.valueOf(seqUtils.getSequence("notice_id"));
if(id.equals("1")){
id =String.valueOf(seqUtils.getSequence("notice_id"));
}
noticeInfo.set_id(id);
noticeInfo.setContent(content);
noticeInfo.setTitle(title);
noticeInfo.setStartTime(Long.parseLong(startTime));
noticeInfo.setEndTime(Long.parseLong(endTime));
noticeInfo.setLeve(type);
noticeInfoDao.updateNoticeInfo(noticeInfo);
return 0;
}
@RequestMapping(value = "/noticeInfos", method = {RequestMethod.POST, RequestMethod.GET})
public String sysMailCheck (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
List<NoticeInfo> infos = noticeInfoDao.getAllNotice();
List<NoticeInfoVo> noticeInfoVos = new ArrayList<>();
for (NoticeInfo item :infos){
NoticeInfoVo noticeInfoVo = new NoticeInfoVo();
noticeInfoVo.setId(item.get_id());
noticeInfoVo.setTitle(item.getTitle());
noticeInfoVo.setContent(item.getContent());
Date data = new Date(item.getStartTime());
noticeInfoVo.setCreateTime(sdf.format(data));
Date endData = new Date(item.getEndTime());
noticeInfoVo.setEndTime(sdf.format(endData));
if(item.get_id().equals("1")){
noticeInfoVo.setCreateTime("常驻");
noticeInfoVo.setEndTime("常驻");
}
noticeInfoVos.add(noticeInfoVo);
}
map.put("noticeInfoVos",noticeInfoVos);
return "ShowNotice";
}
@RequestMapping(value = "/deleteNotice", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody
int removeNotice(HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
String id = parameterMap.get("noticeId");
if(null ==id||id.equals("1")){
return -1;
}
noticeInfoDao.deleteNotice(Integer.valueOf(id));
return 0;
}

View File

@ -1,7 +1,11 @@
package com.jmfy.dao;
import com.jmfy.model.NoticeInfo;
public interface NoticeInfoDao {
void updateNoticeInfo(NoticeInfo noticeInfo) throws Exception;
void updateNoticeInfo(String title,String content) throws Exception;
}

View File

@ -103,10 +103,10 @@ public class CdkInfoDaoImpl implements CdkInfoDao {
@Override
public void updateCdkGoodsInfo(SCdkInfo scdkInfo,int goodsId) throws Exception {
Update update = new Update();
update.set("isAdd",1);
MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName);
Query query = new Query(Criteria.where("_id").is(goodsId));
mongoTemplate.updateMulti(query, update, SCdkInfo.class);
// Update update = new Update();
// update.set("isAdd",1);
// MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName);
// Query query = new Query(Criteria.where("_id").is(goodsId));
// mongoTemplate.updateMulti(query, update, SCdkInfo.class);
}
}

View File

@ -3,6 +3,7 @@ package com.jmfy.dao.impl;
import com.jmfy.dao.NoticeInfoDao;
import com.jmfy.model.Constant;
import com.jmfy.model.NoticeInfo;
import com.jmfy.model.ServerMail;
import com.jmfy.utils.Connect;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
@ -11,6 +12,7 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class NoticeInfoDaoImpl implements NoticeInfoDao {
@ -18,6 +20,12 @@ public class NoticeInfoDaoImpl implements NoticeInfoDao {
@Resource
private Connect connect;
public static final String dbName = Constant.dbName;
@Override
public void updateNoticeInfo(NoticeInfo noticeInfo) throws Exception {
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
mongoTemplate.insert(noticeInfo);
}
@Override
public void updateNoticeInfo(String title, String content) throws Exception {
Update update = new Update();
@ -29,5 +37,17 @@ public class NoticeInfoDaoImpl implements NoticeInfoDao {
}
public void deleteNotice(int id) throws Exception {
MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName);
Query query = new Query();
query.addCriteria(Criteria.where("_id").is(String.valueOf(id)));
mongoTemplate.remove(query, NoticeInfo.class);
}
public List<NoticeInfo> getAllNotice() throws Exception{
MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName);
Query query = new Query();
return mongoTemplate.find(query,NoticeInfo.class);
}
}

View File

@ -21,6 +21,19 @@ public class NoticeInfo {
@Field(value = "title")
private String title;
/**
* 0
* 1
* 2
*/
@Field(value = "leve")
private int leve;
@Field(value = "start_time")
private long startTime;
@Field(value = "end_time")
private long endTime;
public String getContent() {
return content;
@ -37,4 +50,36 @@ public class NoticeInfo {
public void setTitle(String title) {
this.title = title;
}
public String get_id() {
return _id;
}
public void set_id(String _id) {
this._id = _id;
}
public int getLeve() {
return leve;
}
public void setLeve(int leve) {
this.leve = leve;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
}

View File

@ -0,0 +1,50 @@
package com.jmfy.model.vo;
public class NoticeInfoVo {
private String id;
private String title;
private String content;
private String createTime;
private String endTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

View File

@ -60,6 +60,37 @@
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
开始时间:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'datemin\')}' })" id="datemin" class="input-text Wdate" style="width:180px;" name="startTime">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
结束时间:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'datemin\')}' })" id="datemax" class="input-text Wdate" style="width:180px;" name="endTime">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
公告等级:</label>
<div class="formControls col-xs-8 col-sm-9">
<select name="addType" class="input-text" id="contentType"><!--下拉列表-->
<option value="0" selected = "selected">常驻公告(优先级低)</option>
<option value="1" >限时公告(中)</option>
<option value="2" >限时公告(高)</option>
</select>
</div>
</div>
<div class="row cl" style="text-align: center">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
<button class="btn btn-primary radius" type="submit" style="font-size: 15px"><i class="Hui-iconfont">&#xe665;</i>

View File

@ -192,7 +192,7 @@ $(document).ready(function() {
{
FieldCount++; //text box added increment
//add input box
$(InputsWrapper).append('<div>物品id:<input type="text" name="itemIds[]" id="itemId_'+ FieldCount +'" style="width: 150px" /> 物品数量:<input type="text" name="itemNums[]" id="itemNum_'+FieldCount+'" style="width: 150px" /> 物品类型:<input type="text" name="itemTypes[]" id="itemType_'+FieldCount+'" style="width: 150px" /><a href="#" class="removeclass">×</a></div>');
$(InputsWrapper).append('<div>物品id:<input type="text" name="itemIds[]" id="itemId_'+ FieldCount +'" style="width: 150px" /> 物品数量:<input type="text" name="itemNums[]" id="itemNum_'+FieldCount+'" style="width: 150px" /><a href="#" class="removeclass">×</a></div>');
x++; //text box increment
}
return false;

View File

@ -0,0 +1,93 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/H-ui.admin.css"/>
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/skin/default/skin.css" id="skin"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/style.css"/>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
<title>公告信息</title>
</head>
<body>
<nav class="breadcrumb">
<i class="Hui-iconfont">&#xe67f;</i> 首页
<span class="c-gray en">&gt;</span> 公告信息 <span class="c-gray en">&gt;</span> 公告信息
</nav>
<div class="page-container" style="text-align: center">
<h2><span style="color:red;">公告信息</span></h2>
<div class="text-c">
<div class="mt-20">
<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
<thead>
<tr class="text-c">
<!--<th width="25"><input type="checkbox" name="" value=""/></th>-->
<th width="200">标题</th>
<th width="200">内容</th>
<th width="200">开始时间</th>
<th width="200">结束时间</th>
<th width="200">操作</th>
</tr>
</thead>
<tbody>
<tr th:each="obj:${noticeInfoVos}">
<!--<td><input type="checkbox" value="" name=""/></td>-->
<td th:text="${obj.title}" style="text-align: center;"></td>
<td th:text="${obj.content}" style="text-align: center;"></td>
<td th:text="${obj.createTime}" style="text-align: center;"></td>
<td th:text="${obj.endTime}" style="text-align: center;"></td>
<td style="text-align: center; width: 300px">
<button type="button" th:id="${obj.id}" class="btn btn-primary"
onclick="return deleteMail(this)"><i class="Hui-iconfont"></i> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
function deleteMail(obj, noticeId) {
noticeId = $(obj).attr("id");
$.ajax({
type: "POST",
data: {"noticeId": noticeId},
url: "/deleteNotice",
success: function (data) {
if (data < 0) {
layer.msg('操作失败!', {icon: 6, time: 1000});
}
if (data == 0) {
layer.msg('删除成功!', {icon: 6, time: 1000});
}
}
}
)
}
</script>
</body>
</html>

View File

@ -103,6 +103,7 @@
<li><a data-href="/html/sendSysMSG.html" data-title="发送跑马灯" href="javascript:;">发送跑马灯</a></li>
<li><a data-href="/html/sendSysNotice.html" data-title="发送公告" href="javascript:;">发送公告</a></li>
<li><a data-href="/html/sendSysCmd.html" data-title="发送gm" href="javascript:;">发送gm</a></li>
<li><a data-href="noticeInfos" data-title="公告信息" href="javascript:void(0)">公告信息</a></li>
<!--<li><a data-href="/html/recoverItem.html" data-title="回收道具" href="javascript:;">回收道具</a></li>-->
</ul>
</dd>