|
|
@@ -0,0 +1,107 @@
|
|
|
+package com.jpsoft.employment.modules.base.api;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.modules.base.entity.ImageWall;
|
|
|
+import com.jpsoft.employment.modules.base.entity.MessageBoard;
|
|
|
+import com.jpsoft.employment.modules.base.entity.RegUser;
|
|
|
+import com.jpsoft.employment.modules.base.service.ImageWallService;
|
|
|
+import com.jpsoft.employment.modules.base.service.MessageBoardService;
|
|
|
+import com.jpsoft.employment.modules.base.service.RegUserService;
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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 javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/base/api/board")
|
|
|
+@Api(description = "留言板")
|
|
|
+public class BoardApi {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MessageBoardService messageBoardService;
|
|
|
+ @Autowired
|
|
|
+ private RegUserService regUserService;
|
|
|
+
|
|
|
+ @ApiOperation(value="列表-公开")
|
|
|
+ @RequestMapping(value = "pubList",method = RequestMethod.POST)
|
|
|
+ public MessageResult pubList(
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize) {
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("status","2");
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
+
|
|
|
+ Page<MessageBoard> page = messageBoardService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="列表-私有")
|
|
|
+ @RequestMapping(value = "priList",method = RequestMethod.POST)
|
|
|
+ public MessageResult priList(
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+ String subject = (String)request.getAttribute("subject");
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("status","2");
|
|
|
+ searchParams.put("regUserId",subject);
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.status_","desc"));
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
+
|
|
|
+ Page<MessageBoard> page = messageBoardService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="保存")
|
|
|
+ @RequestMapping(value = "save",method = RequestMethod.POST)
|
|
|
+ public MessageResult save(String content, HttpServletRequest request) {
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+ String subject = (String)request.getAttribute("subject");
|
|
|
+ RegUser regUser = regUserService.get(subject);
|
|
|
+
|
|
|
+ MessageBoard messageBoard = new MessageBoard();
|
|
|
+ messageBoard.setId(UUID.randomUUID().toString());
|
|
|
+ messageBoard.setTitle(regUser.getNickName() + "留言");
|
|
|
+ messageBoard.setContent(content);
|
|
|
+ messageBoard.setRegUserId(subject);
|
|
|
+ messageBoard.setStatus("1");
|
|
|
+ messageBoard.setDelFlag(false);
|
|
|
+ messageBoard.setCreateBy(subject);
|
|
|
+ messageBoard.setCreateTime(new Date());
|
|
|
+ messageBoardService.insert(messageBoard);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(messageBoard);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|