package com.sinata.modular.system.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.common.enums.EnumIsDelete;
|
import com.sinata.common.enums.EnumNoticeMessageType;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.sinata.core.shiro.ShiroKit;
|
import com.sinata.core.util.ToolUtil;
|
import com.sinata.modular.member.model.MemUser;
|
import com.sinata.modular.member.service.IMemUserService;
|
import com.sinata.modular.system.controller.util.WrapperUtil;
|
import com.sinata.modular.system.model.TFeedback;
|
import com.sinata.modular.system.model.TNoticeMessage;
|
import com.sinata.modular.system.service.ITFeedbackService;
|
import com.sinata.modular.system.service.ITNoticeMessageService;
|
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.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 意见反馈控制器
|
*/
|
@Controller
|
@RequestMapping("/tFeedback")
|
public class TFeedbackController extends BaseController {
|
|
private String PREFIX = "/system/tFeedback/";
|
|
@Autowired
|
private ITFeedbackService tFeedbackService;
|
|
@Autowired
|
private IMemUserService memUserService;
|
|
@Autowired
|
private ITNoticeMessageService itNoticeMessageService;
|
|
/**
|
* 跳转到意见反馈首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tFeedback.html";
|
}
|
|
/**
|
* 跳转到添加意见反馈
|
*/
|
@RequestMapping("/tFeedback_add")
|
public String tFeedbackAdd() {
|
return PREFIX + "tFeedback_add.html";
|
}
|
|
/**
|
* 跳转到修改意见反馈
|
*/
|
@RequestMapping("/tFeedback_update/{tFeedbackId}")
|
public String tFeedbackUpdate(@PathVariable Integer tFeedbackId, Model model) {
|
model.addAttribute("id", tFeedbackId);
|
return PREFIX + "tFeedback_update.html";
|
}
|
|
/**
|
* 获取意见反馈列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String nikeName, Integer state, String beginTime, String endTime,String template ) {
|
Wrapper wrapper = new EntityWrapper<TFeedback>().orderBy("state").orderBy("id", false).eq("is_delete",0);
|
// 未删除的信息
|
wrapper.eq("is_delete", EnumIsDelete.EXISTED.index);
|
|
// 用户昵称搜索
|
if (ToolUtil.isNotEmpty(nikeName)) {
|
List<MemUser> list = memUserService.selectList(new EntityWrapper<MemUser>().like("nick_name", nikeName));
|
// 封装查询用户ID组
|
WrapperUtil.getWrapperAndInUserId(list, wrapper);
|
}
|
|
// 状态搜索
|
if (ToolUtil.isNotEmpty(state) && state != -1) {
|
wrapper.and().eq("state", state);
|
}
|
if (ToolUtil.isNotEmpty(template)){
|
wrapper.eq("template",template);
|
}
|
// 创建时间
|
if (ToolUtil.isNotEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if (ToolUtil.isNotEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
|
// 物理分页
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
// 查询总代理信息
|
List<Map<String, Object>> list = tFeedbackService.selectMapsPage(page, wrapper).getRecords();
|
|
// 封装数据
|
for (Map<String, Object> map : list) {
|
Integer uid = (Integer) map.get("userId");
|
if(uid != null){
|
MemUser user = memUserService.selectById(uid);
|
if (user != null) {
|
map.put("userId", user.getPhone() + "-" + user.getNickName());
|
}
|
}
|
}
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
|
|
/**
|
* 删除意见反馈
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam String ids) {
|
// tFeedbackService.deleteById(tFeedbackId);
|
tFeedbackService.updateForSet("is_delete = 1",
|
new EntityWrapper<TFeedback>().eq( "state", 1)
|
.in("id", ids.split(",")));
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改意见反馈
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TFeedback tFeedback) {
|
tFeedbackService.updateById(tFeedback);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改意见反馈状态
|
*/
|
@RequestMapping(value = "/updateState")
|
@ResponseBody
|
public Object updateState(@RequestParam Integer tFeedbackId, @RequestParam String backMsg) {
|
TFeedback obj = tFeedbackService.selectById(tFeedbackId);
|
if (obj != null) {
|
obj.setState(1);
|
obj.setBackMsg(backMsg);
|
tFeedbackService.updateById(obj);
|
TNoticeMessage tNoticeMessage = new TNoticeMessage();
|
tNoticeMessage.setUserType(1);
|
tNoticeMessage.setType(EnumNoticeMessageType.FEEDBACK_DEAL.index);
|
tNoticeMessage.setUserId(obj.getUserId());
|
tNoticeMessage.setOtherId(tFeedbackId.toString());
|
tNoticeMessage.setIsRead(0);
|
tNoticeMessage.setIsDelete(0);
|
tNoticeMessage.setContent("您提交的反馈“"+ ShiroKit.getUser().getName()+"”已处理,处理结果为:"+backMsg);
|
tNoticeMessage.setCreateTime(new Date());
|
this.itNoticeMessageService.insert(tNoticeMessage);
|
}
|
return SUCCESS_TIP;
|
}
|
|
|
/**
|
* 意见反馈详情
|
*/
|
@RequestMapping(value = "/detail/{tFeedbackId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tFeedbackId") Integer tFeedbackId) {
|
return tFeedbackService.selectById(tFeedbackId);
|
}
|
}
|