|
|
@@ -1,11 +1,15 @@
|
|
|
package com.jpsoft.employment.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.modules.base.entity.RegUser;
|
|
|
+import com.jpsoft.employment.modules.base.service.RegUserService;
|
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
import com.jpsoft.employment.modules.base.entity.MessageBoard;
|
|
|
import com.jpsoft.employment.modules.base.service.MessageBoardService;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.User;
|
|
|
+import com.jpsoft.employment.modules.sys.service.UserService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -24,6 +28,12 @@ public class MessageBoardController {
|
|
|
|
|
|
@Autowired
|
|
|
private MessageBoardService messageBoardService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RegUserService regUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@@ -79,6 +89,14 @@ public class MessageBoardController {
|
|
|
MessageBoard messageBoard = messageBoardService.get(id);
|
|
|
|
|
|
if (messageBoard != null) {
|
|
|
+ RegUser regUser = regUserService.get(messageBoard.getRegUserId());
|
|
|
+ if(regUser!=null){
|
|
|
+ messageBoard.setRegUserName(regUser.getRealName());
|
|
|
+ }
|
|
|
+ User user = userService.get(messageBoard.getReplyBy());
|
|
|
+ if(user!=null){
|
|
|
+ messageBoard.setReplyName(user.getRealName());
|
|
|
+ }
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(messageBoard);
|
|
|
} else {
|
|
|
@@ -102,8 +120,11 @@ public class MessageBoardController {
|
|
|
MessageResult<MessageBoard> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
+ Date now = new Date();
|
|
|
messageBoard.setUpdateBy(subject);
|
|
|
- messageBoard.setUpdateTime(new Date());
|
|
|
+ messageBoard.setUpdateTime(now);
|
|
|
+ messageBoard.setReplyBy(subject);
|
|
|
+ messageBoard.setReplyTime(now);
|
|
|
|
|
|
int affectCount = messageBoardService.update(messageBoard);
|
|
|
|
|
|
@@ -195,7 +216,7 @@ public class MessageBoardController {
|
|
|
@ApiOperation(value="列表")
|
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
- String id,
|
|
|
+ String name,
|
|
|
@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
@RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
HttpServletRequest request){
|
|
|
@@ -209,19 +230,67 @@ public class MessageBoardController {
|
|
|
Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("create_time","desc"));
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(id)) {
|
|
|
- searchParams.put("id","%" + id + "%");
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ searchParams.put("name", name + "%");
|
|
|
}
|
|
|
|
|
|
|
|
|
Page<MessageBoard> page = messageBoardService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
+ for (MessageBoard messageBoard:page) {
|
|
|
+ RegUser regUser = regUserService.get(messageBoard.getRegUserId());
|
|
|
+ if(regUser!=null){
|
|
|
+ messageBoard.setRegUserName(regUser.getRealName());
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = userService.get(messageBoard.getReplyBy());
|
|
|
+ if(user!=null){
|
|
|
+ messageBoard.setReplyName(user.getRealName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="审核")
|
|
|
+ @PostMapping("audit/{id}")
|
|
|
+ public MessageResult<MessageBoard> audit(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ MessageResult<MessageBoard> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Date now = new Date();
|
|
|
+ MessageBoard messageBoard = messageBoardService.get(id);
|
|
|
+ messageBoard.setStatus("2");
|
|
|
+ messageBoard.setAuditTime(now);
|
|
|
+ messageBoard.setAuditBy(subject);
|
|
|
+ messageBoard.setUpdateBy(subject);
|
|
|
+ messageBoard.setUpdateTime(now);
|
|
|
+
|
|
|
+ int affectCount = messageBoardService.update(messageBoard);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库审核失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|