|
@@ -0,0 +1,114 @@
|
|
|
+package com.jpsoft.smart.modules.mobile.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.smart.modules.base.entity.MessageNotice;
|
|
|
+import com.jpsoft.smart.modules.base.service.MessageNoticeService;
|
|
|
+import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.smart.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.*;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/messageNoticeApi")
|
|
|
+@Api(description = "messageNotice")
|
|
|
+public class MessageNoticeApiController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MessageNoticeService messageNoticeService;
|
|
|
+
|
|
|
+ @ApiOperation(value="获取信息")
|
|
|
+ @RequestMapping(value = "detail",method = RequestMethod.POST)
|
|
|
+ public MessageResult<MessageNotice> detail(@PathVariable("id") String id,
|
|
|
+ String token){
|
|
|
+ MessageResult<MessageNotice> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ MessageNotice messageNotice = messageNoticeService.get(id);
|
|
|
+
|
|
|
+ if (messageNotice != null) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(messageNotice);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="列表")
|
|
|
+ @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> pageList(
|
|
|
+ String title,String token,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ searchParams.put("title","%" + title + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<MessageNotice> page = messageNoticeService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="列表")
|
|
|
+ @RequestMapping(value = "pageListShort",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> pageListShort(
|
|
|
+ String title,String token,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ searchParams.put("title","%" + title + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<MessageNotice> page = messageNoticeService.pageSearchShort(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|