|
@@ -0,0 +1,134 @@
|
|
|
|
+package com.jpsoft.railroad.modules.mobile.controller;
|
|
|
|
+
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+import com.jpsoft.railroad.modules.base.entity.NetworkNotice;
|
|
|
|
+import com.jpsoft.railroad.modules.base.entity.NetworkNoticeRalation;
|
|
|
|
+import com.jpsoft.railroad.modules.base.entity.Organization;
|
|
|
|
+import com.jpsoft.railroad.modules.base.entity.RegUser;
|
|
|
|
+import com.jpsoft.railroad.modules.base.service.NetworkNoticeRalationService;
|
|
|
|
+import com.jpsoft.railroad.modules.base.service.NetworkNoticeService;
|
|
|
|
+import com.jpsoft.railroad.modules.base.service.OrganizationService;
|
|
|
|
+import com.jpsoft.railroad.modules.base.service.RegUserService;
|
|
|
|
+import com.jpsoft.railroad.modules.common.dto.MessageResult;
|
|
|
|
+import com.jpsoft.railroad.modules.common.dto.Sort;
|
|
|
|
+import com.jpsoft.railroad.modules.common.utils.PojoUtils;
|
|
|
|
+import com.jpsoft.railroad.modules.sys.service.DataDictionaryService;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
+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.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.format.annotation.DateTimeFormat;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/mobile/networkNotice")
|
|
|
|
+@Api(description = "内网公告接口")
|
|
|
|
+public class NetworkNoticeApi {
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
+
|
|
|
|
+ @Value("${jwt.secret}")
|
|
|
|
+ private String jwtSecret;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrganizationService organizationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RegUserService regUserService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private NetworkNoticeService networkNoticeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private NetworkNoticeRalationService networkNoticeRalationService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="公告列表")
|
|
|
|
+ @RequestMapping(value = "networkNoticeList",method = RequestMethod.POST)
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "name", value = "name", required = false,paramType = "form"),
|
|
|
|
+ @ApiImplicitParam(name = "queryDate", value = "queryDate", required = false,paramType = "form"),
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<Map> networkNoticeList(
|
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date queryDate,
|
|
|
|
+ @RequestParam(value = "name", defaultValue = "") String name,
|
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ RegUser regUser = regUserService.get(subject);
|
|
|
|
+ if(regUser == null){
|
|
|
|
+ throw new Exception("未登录");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
|
+
|
|
|
|
+ if(queryDate != null){
|
|
|
|
+ searchParams.put("createTime",queryDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(queryDate != null){
|
|
|
|
+ searchParams.put("name","%" + name + "%");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ searchParams.put("businessIds",Arrays.asList(regUser.getId(),regUser.getOrgId()));
|
|
|
|
+ Page<NetworkNotice> page = networkNoticeService.pageSearchByMobile(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
+ for (NetworkNotice networkNotice : page.getResult()){
|
|
|
|
+ networkNotice.setTypeN(dataDictionaryService.findNameByCatalogNameAndValue("文件类型",networkNotice.getType()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="公告详细")
|
|
|
|
+ @RequestMapping(value = "networkNoticeDetails",method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> networkNoticeDetails(
|
|
|
|
+ String id,
|
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String,Object> returnMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ RegUser regUser = regUserService.get(subject);
|
|
|
|
+ if(regUser == null){
|
|
|
|
+ throw new Exception("未登录");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ NetworkNotice networkNotice = networkNoticeService.get(id);
|
|
|
|
+ returnMap.put("networkNotice",networkNotice);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(returnMap);
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+}
|