|
|
@@ -1,17 +1,29 @@
|
|
|
package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.RecruitInfoListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.WhisperingWallDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.WhisperingWallListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.RecruitInfo;
|
|
|
import com.jpsoft.enterprise.modules.base.entity.WhisperingWall;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
|
|
|
import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.enterprise.modules.base.service.WhisperingWallService;
|
|
|
import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.enterprise.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.enterprise.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
|
|
|
import com.jpsoft.enterprise.modules.sys.service.UserService;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -26,6 +38,12 @@ public class WhisperingWallApiController {
|
|
|
@Autowired
|
|
|
private PersonInfoService personInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
@ApiOperation(value="提问")
|
|
|
@PostMapping("questions")
|
|
|
@ApiImplicitParams({
|
|
|
@@ -106,4 +124,304 @@ public class WhisperingWallApiController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("whisperingWallInfoList")
|
|
|
+ @ApiOperation(value = "回音壁列表(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "类型(0:全部,1:建议意见,2:困难反馈)", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> whisperingWallInfoList(String type, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<WhisperingWallListDTO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ if (!"0".equals(type)){
|
|
|
+ searchParams.put("type",Integer.valueOf(type));
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("status",1);
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+ Page<WhisperingWall> page = whisperingWallService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<WhisperingWall> whisperingWallList = page.getResult();
|
|
|
+ if (whisperingWallList.size() > 0) {
|
|
|
+
|
|
|
+ for (WhisperingWall whisperingWall : whisperingWallList) {
|
|
|
+ WhisperingWallListDTO whisperingWallListDTO = new WhisperingWallListDTO();
|
|
|
+ BeanUtils.copyProperties(whisperingWall, whisperingWallListDTO);
|
|
|
+ //回答者
|
|
|
+ PersonInfo personInfo = personInfoService.get(whisperingWall.getAnswerBy());
|
|
|
+ //回答者的公司
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ whisperingWallListDTO.setAnswerCompanyName(companyInfo.getCompanyName());
|
|
|
+ if (whisperingWall.getType() == 1){
|
|
|
+ whisperingWallListDTO.setTypeName("建议意见");
|
|
|
+ }
|
|
|
+ if (whisperingWall.getType() == 2){
|
|
|
+ whisperingWallListDTO.setTypeName("困难反馈");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ list.add(whisperingWallListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("whisperingWallInfoDetail")
|
|
|
+ @ApiOperation(value = "回音壁详情(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<WhisperingWallDTO> whisperingWallInfoDetail(String id) {
|
|
|
+ MessageResult<WhisperingWallDTO> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ WhisperingWall whisperingWall = whisperingWallService.get(id);
|
|
|
+ if (whisperingWall == null){
|
|
|
+ throw new Exception("记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ WhisperingWallDTO whisperingWallDTO = new WhisperingWallDTO();
|
|
|
+ BeanUtils.copyProperties(whisperingWall,whisperingWallDTO);
|
|
|
+ //提问者
|
|
|
+ PersonInfo personInfo = personInfoService.get(whisperingWall.getQuestionBy());
|
|
|
+ //提问人的公司
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ whisperingWallDTO.setQuestionCompanyName(companyInfo.getCompanyName());
|
|
|
+ whisperingWallDTO.setTypeName(whisperingWall.getTypeName());
|
|
|
+ whisperingWallDTO.setQuestionTime(DateUtil.format(whisperingWall.getQuestionTime(),"yyyy-MM-dd"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(whisperingWall.getAnswerBy())){
|
|
|
+ //回答者
|
|
|
+ PersonInfo personInfo1 = personInfoService.get(whisperingWall.getAnswerBy());
|
|
|
+ //回答者的公司
|
|
|
+ CompanyInfo companyInfo1 = companyInfoService.get(personInfo1.getCompanyId());
|
|
|
+ CompanyInfoDetailDTO companyInfoDetailDTO = new CompanyInfoDetailDTO();
|
|
|
+ BeanUtils.copyProperties(companyInfo1,companyInfoDetailDTO);
|
|
|
+ String positionName = dataDictionaryService.findNameByCatalogNameAndValue("企联职务",companyInfo1.getPosition());
|
|
|
+ companyInfoDetailDTO.setPositionName(positionName);
|
|
|
+ whisperingWallDTO.setCompanyInfoDetailDTO(companyInfoDetailDTO);
|
|
|
+ whisperingWallDTO.setAnswerTime(DateUtil.format(whisperingWall.getAnswerTime(),"yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(whisperingWallDTO);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("whisperingWallInfoListByCompany")
|
|
|
+ @ApiOperation(value = "诉求列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "function", value = "功能(1:诉求反应,2:诉求回复)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态(1:待回复,2:已回复)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> whisperingWallInfoListByCompany(String function, String status, String token, @RequestAttribute String subject,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<WhisperingWallListDTO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ PersonInfo personInfo0 = personInfoService.get(subject);
|
|
|
+ if (personInfo0 == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo0 = companyInfoService.get(personInfo0.getCompanyId());
|
|
|
+ if (personInfo0 == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("1".equals(function)){
|
|
|
+ searchParams.put("questionBy",personInfo0.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ int statusB = 1;
|
|
|
+ if ("1".equals(status)){
|
|
|
+ statusB = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("status",statusB);
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+ Page<WhisperingWall> page = whisperingWallService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<WhisperingWall> whisperingWallList = page.getResult();
|
|
|
+ if (whisperingWallList.size() > 0) {
|
|
|
+
|
|
|
+ for (WhisperingWall whisperingWall : whisperingWallList) {
|
|
|
+ WhisperingWallListDTO whisperingWallListDTO = new WhisperingWallListDTO();
|
|
|
+ BeanUtils.copyProperties(whisperingWall, whisperingWallListDTO);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(whisperingWall.getAnswerBy())){
|
|
|
+ //回答者
|
|
|
+ PersonInfo personInfo = personInfoService.get(whisperingWall.getAnswerBy());
|
|
|
+ //回答者的公司
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ whisperingWallListDTO.setAnswerCompanyName(companyInfo.getCompanyName());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whisperingWall.getType() == 1){
|
|
|
+ whisperingWallListDTO.setTypeName("建议意见");
|
|
|
+ }
|
|
|
+ if (whisperingWall.getType() == 2){
|
|
|
+ whisperingWallListDTO.setTypeName("困难反馈");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ list.add(whisperingWallListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("submitWhisperingWallInfo")
|
|
|
+ @ApiOperation(value = "提交诉求")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type", value = "类型(1:建议意见,2:困难反馈)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "content", value = "内容", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> submitWhisperingWallInfo(String type, String content, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ WhisperingWall whisperingWall = new WhisperingWall();
|
|
|
+ whisperingWall.setId(UUID.randomUUID().toString());
|
|
|
+ whisperingWall.setQuestion(content);
|
|
|
+ whisperingWall.setQuestionBy(personInfo.getId());
|
|
|
+ whisperingWall.setQuestionTime(new Date());
|
|
|
+ whisperingWall.setType(Integer.valueOf(type));
|
|
|
+ whisperingWall.setDelFlag(false);
|
|
|
+ whisperingWall.setCreateBy(personInfo.getId());
|
|
|
+ whisperingWall.setCreateTime(new Date());
|
|
|
+ whisperingWall.setStatus(false);
|
|
|
+ whisperingWallService.insert(whisperingWall);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("replyWhisperingWallInfo")
|
|
|
+ @ApiOperation(value = "回复诉求")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "content", value = "回复内容", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> replyWhisperingWallInfo(String id, String content, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ WhisperingWall whisperingWall = whisperingWallService.get(id);
|
|
|
+ if (whisperingWall == null){
|
|
|
+ throw new Exception("诉求不存在");
|
|
|
+ }
|
|
|
+ if (whisperingWall.getStatus()){
|
|
|
+ throw new Exception("诉求已回复");
|
|
|
+ }
|
|
|
+
|
|
|
+ whisperingWall.setAnswer(content);
|
|
|
+ whisperingWall.setAnswerBy(personInfo.getId());
|
|
|
+ whisperingWall.setAnswerTime(new Date());
|
|
|
+ whisperingWall.setUpdateBy(personInfo.getId());
|
|
|
+ whisperingWall.setUpdateTime(new Date());
|
|
|
+ whisperingWall.setStatus(true);
|
|
|
+ whisperingWallService.update(whisperingWall);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
}
|