|
|
|
@ -1,32 +1,32 @@ |
|
|
|
package com.xm.core.ctrl; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import io.swagger.annotations.*; |
|
|
|
|
|
|
|
import static com.mdp.core.utils.ResponseHelper.*; |
|
|
|
import static com.mdp.core.utils.BaseUtils.*; |
|
|
|
import com.mdp.core.entity.Tips; |
|
|
|
import com.mdp.core.err.BizException; |
|
|
|
import com.mdp.mybatis.PageUtils; |
|
|
|
import com.mdp.core.utils.RequestUtils; |
|
|
|
import com.mdp.core.utils.NumberUtil; |
|
|
|
import com.mdp.core.utils.ResponseHelper; |
|
|
|
import com.mdp.msg.client.PushNotifyMsgService; |
|
|
|
import com.mdp.mybatis.PageUtils; |
|
|
|
import com.mdp.qx.HasRole; |
|
|
|
import com.mdp.safe.client.entity.User; |
|
|
|
import com.mdp.safe.client.utils.LoginUtils; |
|
|
|
import ApiEntityParams; |
|
|
|
import com.mdp.swagger.ApiEntityParams; |
|
|
|
import com.xm.core.entity.XmMenu; |
|
|
|
import com.xm.core.entity.XmMenuComment; |
|
|
|
import com.xm.core.service.XmMenuCalcService; |
|
|
|
import com.xm.core.service.XmMenuCommentService; |
|
|
|
import com.xm.core.service.XmMenuService; |
|
|
|
import io.swagger.annotations.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
import com.xm.core.service.XmMenuCommentService; |
|
|
|
import com.xm.core.entity.XmMenuComment; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.mdp.core.utils.BaseUtils.toMap; |
|
|
|
|
|
|
|
/** |
|
|
|
* url编制采用rest风格,如对xm_menu_comment 档案评论表的操作有增删改查,对应的url分别为:<br> |
|
|
|
@ -42,6 +42,12 @@ public class XmMenuCommentController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private XmMenuCommentService xmMenuCommentService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
XmMenuService xmMenuService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
PushNotifyMsgService notifyMsgService; |
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> fieldsMap = toMap(new XmMenuComment()); |
|
|
|
@ -65,15 +71,199 @@ public class XmMenuCommentController { |
|
|
|
Tips tips=new Tips("查询成功"); |
|
|
|
RequestUtils.transformArray(xmMenuComment, "ids"); |
|
|
|
PageUtils.startPage(xmMenuComment); |
|
|
|
String pid= (String) xmMenuComment.get("pid"); |
|
|
|
if(!StringUtils.hasText(pid)){ |
|
|
|
xmMenuComment.put("pidIsNull","1"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Map<String,Object>> xmMenuCommentList = xmMenuCommentService.selectListMapByWhere(xmMenuComment); //列出XmMenuComment列表 |
|
|
|
|
|
|
|
if(xmMenuCommentList.size()>0) { |
|
|
|
List<Map<String, Object>> children=xmMenuCommentService.selectListByPids(xmMenuCommentList.stream().map(k->(String)k.get("id")).collect(Collectors.toList())); |
|
|
|
m.put("children", children); |
|
|
|
} |
|
|
|
|
|
|
|
PageUtils.responePage(m, xmMenuCommentList); |
|
|
|
m.put("data",xmMenuCommentList); |
|
|
|
|
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation( value = "新增一条档案评论表信息",notes="addXmMenuComment,主键如果为空,后台自动生成") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200,response=XmMenuComment.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|
|
|
}) |
|
|
|
@HasRole |
|
|
|
@RequestMapping(value="/add",method=RequestMethod.POST) |
|
|
|
public Map<String,Object> addXmMenuComment(@RequestBody XmMenuComment xmMenuComment) { |
|
|
|
Map<String,Object> m = new HashMap<>(); |
|
|
|
Tips tips=new Tips("成功评论"); |
|
|
|
try{ |
|
|
|
User user=LoginUtils.getCurrentUserInfo(); |
|
|
|
XmMenu xmMenuDb=this.xmMenuService.selectOneById(xmMenuComment.getMenuId()); |
|
|
|
if(xmMenuDb==null){ |
|
|
|
return ResponseHelper.failed("xmMenu-0","需求已不存在"); |
|
|
|
} |
|
|
|
xmMenuComment.setId(xmMenuCommentService.createKey("id")); |
|
|
|
xmMenuComment.setBranchId(user.getBranchId()); |
|
|
|
xmMenuComment.setUserid(user.getUserid()); |
|
|
|
xmMenuComment.setUsername(user.getUsername()); |
|
|
|
xmMenuComment.setCdate(new Date()); |
|
|
|
xmMenuComment.setIp(RequestUtils.getIpAddr(RequestUtils.getRequest())); |
|
|
|
xmMenuCommentService.insert(xmMenuComment); |
|
|
|
if(StringUtils.hasText(xmMenuComment.getPid())){ |
|
|
|
xmMenuCommentService.updateChildrenSum(xmMenuComment.getPid(),Integer.valueOf(1)); |
|
|
|
} |
|
|
|
XmMenuCalcService.commentsSet.add(xmMenuComment.getMenuId()); |
|
|
|
if(!user.getUserid().equals(xmMenuDb.getMmUserid())){ |
|
|
|
notifyMsgService.pushMsg(user, xmMenuDb.getMmUserid(), xmMenuDb.getMmUsername(),"10",xmMenuDb.getMenuId(),xmMenuComment.getId(),user.getUsername()+"发表评论:"+xmMenuComment.getContext()); |
|
|
|
} |
|
|
|
m.put("data",xmMenuComment); |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
logger.error("执行异常",e); |
|
|
|
}catch (Exception e) { |
|
|
|
tips.setFailureMsg(e.getMessage()); |
|
|
|
logger.error("执行异常",e); |
|
|
|
} |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation( value = "删除一条档案评论表信息",notes="delXmMenuComment,仅需要上传主键字段") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|
|
|
}) |
|
|
|
@RequestMapping(value="/del",method=RequestMethod.POST) |
|
|
|
public Map<String,Object> delXmMenuComment(@RequestBody XmMenuComment xmMenuComment){ |
|
|
|
Map<String,Object> m = new HashMap<>(); |
|
|
|
Tips tips=new Tips("成功删除一条数据"); |
|
|
|
try{ |
|
|
|
XmMenuComment commentDb=this.xmMenuCommentService.selectOneById(xmMenuComment.getId()); |
|
|
|
if(commentDb==null){ |
|
|
|
return ResponseHelper.failed("data-0","评论已不存在"); |
|
|
|
} |
|
|
|
User user=LoginUtils.getCurrentUserInfo(); |
|
|
|
if(!LoginUtils.isSuperAdmin()){ |
|
|
|
if(!LoginUtils.isBranchAdmin(commentDb.getBranchId())){ |
|
|
|
if(!user.getUserid().equals(commentDb.getUserid())){ |
|
|
|
return ResponseHelper.failed("no-qx-0","无权限删除评论"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
xmMenuCommentService.deleteByPk(xmMenuComment); |
|
|
|
if(StringUtils.hasText(commentDb.getPid())){ |
|
|
|
xmMenuCommentService.updateChildrenSum(commentDb.getPid(),Integer.valueOf(-1)); |
|
|
|
} |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
logger.error("执行异常",e); |
|
|
|
}catch (Exception e) { |
|
|
|
tips.setFailureMsg(e.getMessage()); |
|
|
|
logger.error("执行异常",e); |
|
|
|
} |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation( value = "点赞评论",notes="praiseComment") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200,response=XmMenuComment.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|
|
|
}) |
|
|
|
@RequestMapping(value="/praise",method=RequestMethod.POST) |
|
|
|
public Map<String,Object> praiseComment(@RequestBody XmMenuComment xmMenuComment) { |
|
|
|
Map<String,Object> m = new HashMap<>(); |
|
|
|
Tips tips=new Tips("成功更新一条数据"); |
|
|
|
try{ |
|
|
|
xmMenuCommentService.update("praiseComment", xmMenuComment); |
|
|
|
|
|
|
|
m.put("data",xmMenuComment); |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
logger.error("执行异常",e); |
|
|
|
}catch (Exception e) { |
|
|
|
tips.setFailureMsg(e.getMessage()); |
|
|
|
logger.error("执行异常",e); |
|
|
|
} |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation( value = "屏蔽评论",notes="unShowComment") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200,response=XmMenuComment.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|
|
|
}) |
|
|
|
@RequestMapping(value="/unshow",method=RequestMethod.POST) |
|
|
|
public Map<String,Object> unShowComment(@RequestBody String[] ids) { |
|
|
|
Map<String,Object> m = new HashMap<>(); |
|
|
|
Tips tips=new Tips("成功屏蔽评论"); |
|
|
|
try{ |
|
|
|
User user=LoginUtils.getCurrentUserInfo(); |
|
|
|
List<XmMenuComment> comments=this.xmMenuCommentService.selectListByIds(Arrays.asList(ids)); |
|
|
|
if(comments==null || comments.size()==0){ |
|
|
|
return ResponseHelper.failed("data-0","评论已不存在"); |
|
|
|
} |
|
|
|
boolean isSuperAdmin=LoginUtils.isSuperAdmin(); |
|
|
|
for (XmMenuComment comment : comments) { |
|
|
|
if(!isSuperAdmin){ |
|
|
|
if(!LoginUtils.isBranchAdmin(comment.getBranchId())){ |
|
|
|
if(!user.getUserid().equals(comment.getUserid())){ |
|
|
|
return ResponseHelper.failed("无权限修改","无权限屏蔽评论【"+comment.getContext()+"】"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
xmMenuCommentService.unShowComment(ids); |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
logger.error("执行异常",e); |
|
|
|
}catch (Exception e) { |
|
|
|
tips.setFailureMsg(e.getMessage()); |
|
|
|
logger.error("执行异常",e); |
|
|
|
} |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation( value = "打开评论",notes="showComment") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200,response=XmMenuComment.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|
|
|
}) |
|
|
|
@RequestMapping(value="/show",method=RequestMethod.POST) |
|
|
|
public Map<String,Object> showComment(@RequestBody String[] ids) { |
|
|
|
Map<String,Object> m = new HashMap<>(); |
|
|
|
Tips tips=new Tips("成功打开评论"); |
|
|
|
try{ |
|
|
|
User user= LoginUtils.getCurrentUserInfo(); |
|
|
|
List<XmMenuComment> comments=this.xmMenuCommentService.selectListByIds(Arrays.asList(ids)); |
|
|
|
if(comments==null || comments.size()==0){ |
|
|
|
return ResponseHelper.failed("data-0","评论已不存在"); |
|
|
|
} |
|
|
|
boolean isSuperAdmin=LoginUtils.isSuperAdmin(); |
|
|
|
for (XmMenuComment comment : comments) { |
|
|
|
if(!isSuperAdmin){ |
|
|
|
if(!LoginUtils.isBranchAdmin(comment.getBranchId())){ |
|
|
|
if(!user.getUserid().equals(comment.getUserid())){ |
|
|
|
return ResponseHelper.failed("无权限修改","无权限打开此评论【"+comment.getContext()+"】"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
xmMenuCommentService.showComment(ids); |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
logger.error("执行异常",e); |
|
|
|
}catch (Exception e) { |
|
|
|
tips.setFailureMsg(e.getMessage()); |
|
|
|
logger.error("执行异常",e); |
|
|
|
} |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ApiOperation( value = "新增一条档案评论表信息",notes=" ") |
|
|
|
|