package com.sinata.modular.system.controller;
|
|
import cn.hutool.json.JSONUtil;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.sinata.common.enums.EnumIsDelete;
|
import com.sinata.common.enums.EnumIsSystemNotice;
|
import com.sinata.common.enums.EnumSystemSetKey;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.base.tips.ErrorTip;
|
import com.sinata.core.common.annotion.BussinessLog;
|
import com.sinata.core.common.annotion.Permission;
|
import com.sinata.core.common.constant.factory.ConstantFactory;
|
import com.sinata.core.shiro.ShiroKit;
|
import com.sinata.modular.system.model.SystemNotice;
|
import com.sinata.modular.system.model.TSystemSet;
|
import com.sinata.modular.system.model.TSystemSetAudit;
|
import com.sinata.modular.system.service.ISystemNoticeService;
|
import com.sinata.modular.system.service.ITSystemSetAuditService;
|
import com.sinata.modular.system.service.ITSystemSetService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
|
/**
|
* 系统设置控制器
|
*/
|
@Controller
|
@RequestMapping("/tSystemSet")
|
public class TSystemSetController extends BaseController {
|
|
private String PREFIX = "/system/tSystemSet/";
|
|
@Autowired
|
private ITSystemSetService tSystemSetService;
|
|
@Autowired
|
private ITSystemSetAuditService tSystemSetAuditService;
|
|
@Autowired
|
private ISystemNoticeService systemNoticeService;
|
|
/**
|
* 跳转到系统设置首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tSystemSet.html";
|
}
|
|
@RequestMapping("/set_1")
|
public String set_4(Model model) {
|
Integer[] idArray = new Integer[]{
|
EnumSystemSetKey.PLATFORM_TELEPHONE.index
|
};
|
// 封装Model数据
|
getModelByIdArray(model, idArray);
|
|
return PREFIX + "tSystemSet_1.html";
|
}
|
@BussinessLog(value = "修改平台客服联系电话")
|
@ResponseBody
|
@RequestMapping(value = "/update_1")
|
public Object update_1(String val) {
|
TSystemSet set = new TSystemSet()
|
.setId(EnumSystemSetKey.PLATFORM_TELEPHONE.index)
|
.setValueStr(val);
|
set.updateById();
|
return SUCCESS_TIP;
|
}
|
|
@RequestMapping("/set_100")
|
public String set_100(Model model) {
|
List<TSystemSet> list = tSystemSetService.selectList(
|
new EntityWrapper<TSystemSet>()
|
.in("id", Arrays.asList(
|
EnumSystemSetKey.SET_101.index,
|
EnumSystemSetKey.SET_102.index,
|
EnumSystemSetKey.SET_103.index,
|
EnumSystemSetKey.SET_104.index,
|
EnumSystemSetKey.SET_105.index,
|
EnumSystemSetKey.SET_106.index
|
))
|
);
|
for (TSystemSet o : list) {
|
model.addAttribute("t_" + o.getId(), o.getValueStr());
|
}
|
return PREFIX + "tSystemSet_100.html";
|
}
|
@BussinessLog(value = "修改积分规则")
|
@ResponseBody
|
@RequestMapping(value = "/update_100")
|
public Object update_100(String t_101, String t_102, String t_103, String t_104, String t_105, String t_106) {
|
List<TSystemSet> list = Arrays.asList(
|
new TSystemSet().setId(EnumSystemSetKey.SET_101.index).setValueStr(t_101),
|
new TSystemSet().setId(EnumSystemSetKey.SET_102.index).setValueStr(t_102),
|
new TSystemSet().setId(EnumSystemSetKey.SET_103.index).setValueStr(t_103),
|
new TSystemSet().setId(EnumSystemSetKey.SET_104.index).setValueStr(t_104),
|
new TSystemSet().setId(EnumSystemSetKey.SET_105.index).setValueStr(t_105),
|
new TSystemSet().setId(EnumSystemSetKey.SET_106.index).setValueStr(t_106)
|
);
|
|
tSystemSetService.updateBatchById(list);
|
return SUCCESS_TIP;
|
}
|
|
@RequestMapping("/set_200")
|
public String set_200(Model model) {
|
Integer[] idArray = new Integer[]{
|
EnumSystemSetKey.SET_201.index, EnumSystemSetKey.SET_204.index,
|
EnumSystemSetKey.SET_211.index, EnumSystemSetKey.SET_212.index, EnumSystemSetKey.SET_214.index, EnumSystemSetKey.SET_215.index, EnumSystemSetKey.SET_217.index,
|
EnumSystemSetKey.SET_221.index, EnumSystemSetKey.SET_222.index, EnumSystemSetKey.SET_223.index, EnumSystemSetKey.SET_224.index, EnumSystemSetKey.SET_225.index, EnumSystemSetKey.SET_226.index, EnumSystemSetKey.SET_227.index
|
};
|
// 封装Model数据
|
getModelByIdArray(model, idArray);
|
|
return PREFIX + "tSystemSet_200.html";
|
}
|
@BussinessLog(value = "修改职级佣金设置")
|
@Permission
|
@ResponseBody
|
@RequestMapping(value = "/update_200")
|
public Object update_200(
|
String t_201, String t_204,
|
String t_211, String t_212, String t_214, String t_215, String t_217,
|
String t_221, String t_222, String t_223, String t_224, String t_225, String t_226, String t_227
|
) {
|
List<TSystemSet> list = Arrays.asList(
|
new TSystemSet().setId(EnumSystemSetKey.SET_201.index).setValueStr(t_201),
|
new TSystemSet().setId(EnumSystemSetKey.SET_204.index).setValueStr(t_204),
|
|
new TSystemSet().setId(EnumSystemSetKey.SET_211.index).setValueStr(t_211),
|
new TSystemSet().setId(EnumSystemSetKey.SET_212.index).setValueStr(t_212),
|
new TSystemSet().setId(EnumSystemSetKey.SET_214.index).setValueStr(t_214),
|
new TSystemSet().setId(EnumSystemSetKey.SET_215.index).setValueStr(t_215),
|
new TSystemSet().setId(EnumSystemSetKey.SET_217.index).setValueStr(t_217),
|
|
new TSystemSet().setId(EnumSystemSetKey.SET_221.index).setValueStr(t_221),
|
new TSystemSet().setId(EnumSystemSetKey.SET_222.index).setValueStr(t_222),
|
new TSystemSet().setId(EnumSystemSetKey.SET_223.index).setValueStr(t_223),
|
new TSystemSet().setId(EnumSystemSetKey.SET_224.index).setValueStr(t_224),
|
new TSystemSet().setId(EnumSystemSetKey.SET_225.index).setValueStr(t_225),
|
new TSystemSet().setId(EnumSystemSetKey.SET_226.index).setValueStr(t_226),
|
new TSystemSet().setId(EnumSystemSetKey.SET_227.index).setValueStr(t_227)
|
);
|
|
// 是否为超级管理员
|
if (ShiroKit.hasRole("administrator")) {
|
// 直接修改
|
tSystemSetService.updateBatchById(list);
|
|
// 添加后台通知
|
SystemNotice.builder()
|
.param(0)
|
.type(EnumIsSystemNotice.TYPE_3.index)
|
.adminId(ShiroKit.getUser().getId())
|
.content(ShiroKit.getUser().getName() + " 已调整职级佣金设置!")
|
.build()
|
.insert();
|
|
return SUCCESS_TIP;
|
}
|
|
int count = systemNoticeService.selectCount(
|
new EntityWrapper<SystemNotice>()
|
.eq("type", EnumIsSystemNotice.TYPE_2.index)
|
.eq("is_delete", EnumIsDelete.EXISTED.index)
|
);
|
if (count != 0) {
|
return new ErrorTip(500, "职级佣金设置审核中,请稍后再试!");
|
}
|
|
// 系统设置审核信息
|
TSystemSetAudit o = TSystemSetAudit.builder()
|
.adminId(ShiroKit.getUser().getId())
|
.type(1)
|
.setJson(JSONUtil.toJsonStr(list))
|
.build();
|
o.insert();
|
|
// 添加后台通知
|
SystemNotice.builder()
|
.param(o.getId())
|
.type(EnumIsSystemNotice.TYPE_2.index)
|
.adminId(ShiroKit.getUser().getId())
|
.content(ShiroKit.getUser().getName() + " 申请调整职级佣金设置,请核实审核!")
|
.build()
|
.insert();
|
return SUCCESS_TIP;
|
}
|
@RequestMapping("/set_200_audit/{id}")
|
public String set_200_audit(@PathVariable("id") Integer id, Model model) {
|
TSystemSetAudit o = tSystemSetAuditService.selectById(id);
|
|
// 封装Model数据
|
model.addAttribute("id", id);
|
List<TSystemSet> list = JSONUtil.toList(o.getSetJson(), TSystemSet.class);
|
for (TSystemSet t : list) {
|
model.addAttribute("t_" + t.getId(), t == null ? "0" : t.getValueStr());
|
}
|
|
return PREFIX + "tSystemSet_200_audit.html";
|
}
|
@BussinessLog(value = "职级佣金设置-审核")
|
@Permission
|
@ResponseBody
|
@RequestMapping(value = "/update_200_audit")
|
public Object update_200_audit(Integer id, Integer state, String remark) {
|
Object result = updateAudit(id, state, remark);
|
|
SystemNotice systemNotice = systemNoticeService.selectOne(
|
new EntityWrapper<SystemNotice>()
|
.eq("param", id)
|
.eq("type", EnumIsSystemNotice.TYPE_2.index)
|
);
|
// 修改后台通知
|
systemNotice
|
.setId(systemNotice.getId())
|
.setType(state == 1 ? EnumIsSystemNotice.TYPE_3.index : EnumIsSystemNotice.TYPE_4.index)
|
.setContent(ConstantFactory.me().getUserNameById(systemNotice.getAdminId()) + " 申请调整职级佣金系数,已审核" + (state == 1 ? "通过" : "拒绝") + "!")
|
.updateById();
|
return result;
|
}
|
|
@RequestMapping("/set_300")
|
public String set_300(Model model) {
|
Integer[] idArray = new Integer[]{
|
EnumSystemSetKey.SET_301.index, EnumSystemSetKey.SET_302.index, EnumSystemSetKey.SET_303.index, EnumSystemSetKey.SET_304.index, EnumSystemSetKey.SET_305.index,
|
EnumSystemSetKey.SET_306.index,EnumSystemSetKey.SET_321.index, EnumSystemSetKey.SET_322.index, EnumSystemSetKey.SET_323.index, EnumSystemSetKey.SET_324.index,
|
EnumSystemSetKey.SET_325.index,EnumSystemSetKey.SET_326.index, EnumSystemSetKey.SET_327.index, EnumSystemSetKey.SET_328.index, EnumSystemSetKey.SET_341.index,
|
EnumSystemSetKey.SET_342.index, EnumSystemSetKey.SET_343.index, EnumSystemSetKey.SET_344.index, EnumSystemSetKey.SET_345.index,EnumSystemSetKey.SET_346.index,
|
EnumSystemSetKey.SET_347.index, EnumSystemSetKey.SET_348.index
|
};
|
// 封装Model数据
|
getModelByIdArray(model, idArray);
|
|
return PREFIX + "tSystemSet_300.html";
|
}
|
@BussinessLog(value = "修改人员职级晋升维持设置")
|
@ResponseBody
|
@RequestMapping(value = "/update_300")
|
public Object update_300(
|
String t_301, String t_302, String t_303, String t_304, String t_305,String t_306,
|
String t_321, String t_322, String t_323, String t_324, String t_325,
|
String t_326, String t_327, String t_328,
|
String t_341, String t_342, String t_343, String t_344, String t_345,
|
String t_346, String t_347, String t_348
|
) {
|
List<TSystemSet> list = Arrays.asList(
|
new TSystemSet().setId(EnumSystemSetKey.SET_301.index).setValueStr(t_301),
|
new TSystemSet().setId(EnumSystemSetKey.SET_302.index).setValueStr(t_302),
|
new TSystemSet().setId(EnumSystemSetKey.SET_303.index).setValueStr(t_303),
|
new TSystemSet().setId(EnumSystemSetKey.SET_304.index).setValueStr(t_304),
|
new TSystemSet().setId(EnumSystemSetKey.SET_305.index).setValueStr(t_305),
|
new TSystemSet().setId(EnumSystemSetKey.SET_306.index).setValueStr(t_306),
|
|
new TSystemSet().setId(EnumSystemSetKey.SET_321.index).setValueStr(t_321),
|
new TSystemSet().setId(EnumSystemSetKey.SET_322.index).setValueStr(t_322),
|
new TSystemSet().setId(EnumSystemSetKey.SET_323.index).setValueStr(t_323),
|
new TSystemSet().setId(EnumSystemSetKey.SET_324.index).setValueStr(t_324),
|
new TSystemSet().setId(EnumSystemSetKey.SET_325.index).setValueStr(t_325),
|
new TSystemSet().setId(EnumSystemSetKey.SET_326.index).setValueStr(t_326),
|
new TSystemSet().setId(EnumSystemSetKey.SET_327.index).setValueStr(t_327),
|
new TSystemSet().setId(EnumSystemSetKey.SET_328.index).setValueStr(t_328),
|
|
new TSystemSet().setId(EnumSystemSetKey.SET_341.index).setValueStr(t_341),
|
new TSystemSet().setId(EnumSystemSetKey.SET_342.index).setValueStr(t_342),
|
new TSystemSet().setId(EnumSystemSetKey.SET_343.index).setValueStr(t_343),
|
new TSystemSet().setId(EnumSystemSetKey.SET_344.index).setValueStr(t_344),
|
new TSystemSet().setId(EnumSystemSetKey.SET_345.index).setValueStr(t_345),
|
new TSystemSet().setId(EnumSystemSetKey.SET_346.index).setValueStr(t_346),
|
new TSystemSet().setId(EnumSystemSetKey.SET_347.index).setValueStr(t_347),
|
new TSystemSet().setId(EnumSystemSetKey.SET_348.index).setValueStr(t_348)
|
);
|
|
// 系统设置审核信息
|
TSystemSetAudit o = TSystemSetAudit.builder()
|
.adminId(ShiroKit.getUser().getId())
|
.type(2)
|
.setJson(JSONUtil.toJsonStr(list))
|
.build();
|
|
o.insert();
|
|
// 添加后台通知
|
SystemNotice.builder()
|
.param(o.getId())
|
.type(EnumIsSystemNotice.TYPE_5.index)
|
.adminId(ShiroKit.getUser().getId())
|
.content(ShiroKit.getUser().getName() + " 申请调整人员职级晋升维持设置,请核实审核!")
|
.build()
|
.insert();
|
|
return SUCCESS_TIP;
|
}
|
@RequestMapping("/set_300_audit/{id}")
|
public String set_300_audit(@PathVariable("id") Integer id, Model model) {
|
TSystemSetAudit o = tSystemSetAuditService.selectById(id);
|
|
// 封装Model数据
|
model.addAttribute("id", id);
|
List<TSystemSet> list = JSONUtil.toList(o.getSetJson(), TSystemSet.class);
|
for (TSystemSet t : list) {
|
model.addAttribute("t_" + t.getId(), t == null ? "0" : t.getValueStr());
|
}
|
|
return PREFIX + "tSystemSet_300_audit.html";
|
}
|
@BussinessLog(value = "人员职级晋升维持设置-审核")
|
@Permission
|
@ResponseBody
|
@RequestMapping(value = "/update_300_audit")
|
public Object update_300_audit(Integer id, Integer state, String remark) {
|
SystemNotice systemNotice = systemNoticeService.selectOne(
|
new EntityWrapper<SystemNotice>()
|
.eq("param", id)
|
.eq("type", EnumIsSystemNotice.TYPE_5.index)
|
);
|
if (systemNotice != null) {
|
// 修改后台通知
|
systemNotice
|
.setId(systemNotice.getId())
|
.setType(state == 1 ? EnumIsSystemNotice.TYPE_6.index : EnumIsSystemNotice.TYPE_7.index)
|
.setContent(ConstantFactory.me().getUserNameById(systemNotice.getAdminId()) + " 申请调整人员职级晋升维持设置,审核" + (state == 1 ? "通过" : "拒绝") + "!")
|
.updateById();
|
}
|
|
return updateAudit(id, state, remark);
|
}
|
|
public Object updateAudit(Integer id, Integer state, String remark) {
|
TSystemSetAudit o = tSystemSetAuditService.selectById(id);
|
if (state != null && state == 1) {
|
tSystemSetService.updateBatchById(JSONUtil.toList(o.getSetJson(), TSystemSet.class));
|
}
|
o.setState(state);
|
o.setRemark(remark);
|
o.updateById();
|
|
return SUCCESS_TIP;
|
}
|
|
private void getModelByIdArray(Model model, Object[] idArray) {
|
List<TSystemSet> list = tSystemSetService.selectList(new EntityWrapper<TSystemSet>().in("id", idArray));
|
for (TSystemSet t : list) {
|
model.addAttribute("t_" + t.getId(), t == null ? "0" : t.getValueStr());
|
}
|
}
|
|
/**
|
* 获取系统设置列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String condition) {
|
Wrapper wrapper = new EntityWrapper<TSystemSet>();
|
return tSystemSetService.selectList(wrapper);
|
}
|
|
/**
|
* 修改系统设置
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/TSystemSetUpdate")
|
public Object TSystemSetUpdate(String sys_1, String sys_2, String sys_3) {
|
List<TSystemSet> list = new ArrayList<>();
|
list.add(new TSystemSet(1, sys_1));
|
list.add(new TSystemSet(2, sys_2));
|
list.add(new TSystemSet(3, sys_3));
|
|
tSystemSetService.updateBatchById(list);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 新增系统设置
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TSystemSet tSystemSet) {
|
tSystemSetService.insert(tSystemSet);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除系统设置
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tSystemSetId) {
|
tSystemSetService.deleteById(tSystemSetId);
|
// tSystemSetService.updateById(new TSystemSet(tSystemSetId, 1));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改系统设置
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TSystemSet tSystemSet) {
|
tSystemSetService.updateById(tSystemSet);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改系统设置状态
|
*/
|
@RequestMapping(value = "/updateState")
|
@ResponseBody
|
public Object updateState(@RequestParam Integer tSystemSetId) {
|
// TSystemSet obj = tSystemSetService.selectById(tSystemSetId);
|
// if (obj != null) {
|
// if(obj.getState() == 0) {
|
// obj.setState(1);
|
// } else {
|
// obj.setState(0);
|
// }
|
// tSystemSetService.updateById(obj);
|
// }
|
return SUCCESS_TIP;
|
}
|
|
|
/**
|
* 系统设置详情
|
*/
|
@RequestMapping(value = "/detail/{tSystemSetId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tSystemSetId") Integer tSystemSetId) {
|
return tSystemSetService.selectById(tSystemSetId);
|
}
|
|
}
|