package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.util.DateUtil;
|
import com.stylefeng.guns.core.util.SinataUtil;
|
import com.stylefeng.guns.modular.system.util.task.base.QuartzManager;
|
import com.stylefeng.guns.modular.system.util.task.base.TimeJobType;
|
import com.stylefeng.guns.modular.system.util.task.jobs.AddNotice;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import com.stylefeng.guns.modular.system.model.TNotices;
|
import com.stylefeng.guns.modular.system.service.ITNoticesService;
|
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 滚动消息设置控制器
|
*
|
* @author fengshuonan
|
* @Date 2020-06-10 15:21:25
|
*/
|
@Controller
|
@RequestMapping("/tNotices")
|
public class TNoticesController extends BaseController {
|
|
private String PREFIX = "/system/tNotices/";
|
|
@Autowired
|
private ITNoticesService tNoticesService;
|
|
/**
|
* 跳转到滚动消息设置首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tNotices.html";
|
}
|
|
/**
|
* 跳转到系统公告设置首页
|
*/
|
@RequestMapping("/system")
|
public String system() {
|
return PREFIX + "system.html";
|
}
|
|
/**
|
* 跳转到添加滚动消息设置
|
*/
|
@RequestMapping("/tNotices_add")
|
public String tNoticesAdd() {
|
return PREFIX + "tNotices_add.html";
|
}
|
|
/**
|
* 跳转到添加系统公告
|
*/
|
@RequestMapping("/system_add")
|
public String system_add() {
|
return PREFIX + "system_add.html";
|
}
|
|
/**
|
* 跳转到修改滚动消息设置
|
*/
|
@RequestMapping("/tNotices_update/{tNoticesId}")
|
public String tNoticesUpdate(@PathVariable Integer tNoticesId, Model model) {
|
TNotices tNotices = tNoticesService.selectById(tNoticesId);
|
model.addAttribute("item",tNotices);
|
LogObjectHolder.me().set(tNotices);
|
return PREFIX + "tNotices_edit.html";
|
}
|
|
/**
|
* 跳转到修改系统公告
|
*/
|
@RequestMapping("/system_update/{tNoticesId}")
|
public String system_update(@PathVariable Integer tNoticesId, Model model) {
|
TNotices tNotices = tNoticesService.selectById(tNoticesId);
|
model.addAttribute("item",tNotices);
|
LogObjectHolder.me().set(tNotices);
|
return PREFIX + "system_update.html";
|
}
|
|
/**
|
* 获取滚动消息设置列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String insertTime,String content) {
|
String beginTime = null;
|
String endTime = null;
|
if (SinataUtil.isNotEmpty(insertTime)){
|
String[] timeArray = insertTime.split(" - ");
|
beginTime = timeArray[0];
|
endTime = timeArray[1];
|
}
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
if (ShiroKit.getUser().getRoleType() != 1){
|
page.setRecords(null);
|
}else{
|
page.setRecords(tNoticesService.getRollingNoticeList(page,beginTime,endTime,1,content));
|
}
|
return super.packForBT(page);
|
}
|
|
/**
|
* 获取系统公告设置列表
|
*/
|
@RequestMapping(value = "/listSystem")
|
@ResponseBody
|
public Object listSystem(String insertTime,String content) {
|
String beginTime = null;
|
String endTime = null;
|
if (SinataUtil.isNotEmpty(insertTime)){
|
String[] timeArray = insertTime.split(" - ");
|
beginTime = timeArray[0];
|
endTime = timeArray[1];
|
}
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
if (ShiroKit.getUser().getRoleType() != 1){
|
page.setRecords(null);
|
}else{
|
page.setRecords(tNoticesService.getRollingNoticeList(page,beginTime,endTime,2,content));
|
}
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增滚动消息设置
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TNotices tNotices) {
|
tNotices.setIsDelete(1);
|
tNotices.setInsertTime(new Date());
|
tNotices.setInsertUser(ShiroKit.getUser().getId());
|
tNotices.setType(1);
|
tNoticesService.insert(tNotices);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 新增系统公告
|
*/
|
@RequestMapping(value = "/addSystem")
|
@ResponseBody
|
public Object addSystem(TNotices tNotices) {
|
tNotices.setIsDelete(1);
|
tNotices.setInsertTime(new Date());
|
tNotices.setInsertUser(ShiroKit.getUser().getId());
|
tNotices.setType(2);
|
tNoticesService.insert(tNotices);
|
|
if (tNotices.getIsShow() == 1){ //发布
|
//定时1秒后执行
|
Map<String,Object> maps=new HashMap<>();
|
maps.put("noticeId",tNotices.getId());
|
QuartzManager.addJob(AddNotice.class, (AddNotice.name+tNotices.getId()).toUpperCase(), TimeJobType.UNLOCK,DateUtil.getDate_strYMdHms(new Date().getTime() + 1*1000) , maps);
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 发布系统公告
|
*/
|
@RequestMapping(value = "/sendSystem")
|
@ResponseBody
|
public Object sendSystem(@RequestParam Integer tNoticesId) {
|
TNotices tNotices = tNoticesService.selectById(tNoticesId);
|
if (tNotices.getIsShow() == 2){
|
//定时1秒后执行
|
Map<String,Object> maps=new HashMap<>();
|
maps.put("noticeId",tNotices.getId());
|
QuartzManager.addJob(AddNotice.class, (AddNotice.name+tNotices.getId()).toUpperCase(), TimeJobType.UNLOCK,DateUtil.getDate_strYMdHms(new Date().getTime() + 1*1000) , maps);
|
}
|
tNotices.setIsShow(1);
|
tNotices.setUpdateTime(new Date());
|
tNotices.setUpdateUser(ShiroKit.getUser().getId());
|
tNoticesService.updateById(tNotices);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tNoticesId) {
|
TNotices tNotices = tNoticesService.selectById(tNoticesId);
|
tNotices.setIsDelete(2);
|
tNotices.setFlag("3");
|
tNotices.setUpdateTime(new Date());
|
tNotices.setUpdateUser(ShiroKit.getUser().getId());
|
tNoticesService.updateById(tNotices);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改滚动消息设置
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TNotices tNotices) {
|
tNotices.setUpdateUser(ShiroKit.getUser().getId());
|
tNotices.setUpdateTime(new Date());
|
tNoticesService.updateById(tNotices);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改系统公告
|
*/
|
@RequestMapping(value = "/updateSystem")
|
@ResponseBody
|
public Object updateSystem(TNotices tNotices) {
|
tNotices.setUpdateUser(ShiroKit.getUser().getId());
|
tNotices.setUpdateTime(new Date());
|
tNoticesService.updateById(tNotices);
|
|
if (tNotices.getIsShow() == 1){ //发布
|
//定时1秒后执行
|
Map<String,Object> maps=new HashMap<>();
|
maps.put("noticeId",tNotices.getId());
|
QuartzManager.addJob(AddNotice.class, (AddNotice.name+tNotices.getId()).toUpperCase(), TimeJobType.UNLOCK,DateUtil.getDate_strYMdHms(new Date().getTime() + 1*1000) , maps);
|
}
|
return SUCCESS_TIP;
|
}
|
|
}
|