|
@@ -0,0 +1,199 @@
|
|
|
+package com.jpsoft.employment.modules.mobile.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.config.OSSConfig;
|
|
|
+import com.jpsoft.employment.modules.base.entity.MessageNotice;
|
|
|
+import com.jpsoft.employment.modules.base.entity.UserAuthenticationApprove;
|
|
|
+import com.jpsoft.employment.modules.base.service.MessageNoticeService;
|
|
|
+import com.jpsoft.employment.modules.base.service.UserAuthenticationApproveService;
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.employment.modules.common.utils.*;
|
|
|
+import com.jpsoft.employment.modules.job.entity.JobUser;
|
|
|
+import com.jpsoft.employment.modules.job.service.JobUserService;
|
|
|
+import com.jpsoft.employment.modules.job.service.ResumeDeliverService;
|
|
|
+import com.jpsoft.employment.modules.job.service.ResumeService;
|
|
|
+import com.jpsoft.employment.modules.job.service.UserCollectionService;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.SysLog;
|
|
|
+import com.jpsoft.employment.modules.sys.entity.User;
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
+import com.jpsoft.employment.modules.sys.service.SysLogService;
|
|
|
+import com.jpsoft.employment.modules.sys.service.UserService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+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.joda.time.DateTime;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.ValueOperations;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
+
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/messageApi")
|
|
|
+@Api(description = "消息通知接口")
|
|
|
+@Slf4j
|
|
|
+public class MessageNoticeApiController {
|
|
|
+ @Value("${jwt.secret}")
|
|
|
+ private String jwtSecret;
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JobUserService jobUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ValueOperations<String, Object> valueOperations;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysLogService sysLogService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MessageNoticeService messageNoticeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("messageClassify")
|
|
|
+ @ApiOperation(value = "消息分类")
|
|
|
+ public MessageResult<List> messageClassify(
|
|
|
+ String token,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<List> messageResult = new MessageResult<>();
|
|
|
+ List<Map> resultList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ JobUser jobUser = jobUserService.get(subject);
|
|
|
+
|
|
|
+ if (jobUser == null) {
|
|
|
+ throw new Exception("未登录!");
|
|
|
+ }
|
|
|
+ List<DataDictionary> ddList = dataDictionaryService.findByCatalogName("消息分类");
|
|
|
+
|
|
|
+ for(DataDictionary dd :ddList){
|
|
|
+ Map<String, Object> mnMap = new HashMap<>();
|
|
|
+ MessageNotice mn = messageNoticeService.findTopByUserIdAndClassify(subject,dd.getValue());
|
|
|
+ mnMap.put("classify",dd.getName());
|
|
|
+ mnMap.put("classifyId",dd.getValue());
|
|
|
+ mnMap.put("newMessage",mn);
|
|
|
+ mnMap.put("num",0);
|
|
|
+
|
|
|
+ resultList.add(mnMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData(resultList);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage());
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("messageList")
|
|
|
+ @ApiOperation(value = "消息列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "classifyId", value = "消息分类ID", required = true, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "pageIndex", value = "不传默认1", required = false, paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "不传默认5", required = false, paramType = "query"),
|
|
|
+ })
|
|
|
+ public MessageResult<Map> messageList(
|
|
|
+ String classifyId,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="5") int pageSize,
|
|
|
+ String token,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ JobUser jobUser = jobUserService.get(subject);
|
|
|
+
|
|
|
+ if (jobUser == null) {
|
|
|
+ throw new Exception("未登录!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time","asc"));
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ //List<MessageNotice> mnList = messageNoticeService.findByUserIdAndClassify(subject,classifyId);
|
|
|
+
|
|
|
+ searchParams.put("recipientIdAndNull",subject);
|
|
|
+ searchParams.put("classify",classifyId);
|
|
|
+ searchParams.put("status","1");
|
|
|
+ searchParams.put("type","1");
|
|
|
+
|
|
|
+ Page<MessageNotice> page = messageNoticeService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ messageResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage());
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("messageDetail")
|
|
|
+ @ApiOperation(value = "消息详细")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "messageId", value = "消息ID", required = true, paramType = "query"),
|
|
|
+ })
|
|
|
+ public MessageResult<MessageNotice> messageDetail(
|
|
|
+ String messageId,
|
|
|
+ String token,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<MessageNotice> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ JobUser jobUser = jobUserService.get(subject);
|
|
|
+
|
|
|
+ if (jobUser == null) {
|
|
|
+ throw new Exception("未登录!");
|
|
|
+ }
|
|
|
+
|
|
|
+ MessageNotice mc = messageNoticeService.get(messageId);
|
|
|
+ if(mc == null){
|
|
|
+ throw new Exception("查询错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ User createUser = userService.get(mc.getCreateBy());
|
|
|
+ mc.setCreateByN(createUser.getRealName());
|
|
|
+
|
|
|
+ messageResult.setData(mc);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage());
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|