소스 검색

Merge remote-tracking branch 'origin/V1' into V1

xiao547607 5 년 전
부모
커밋
b9bb930d7c

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/MessageNoticeDAO.java

@@ -17,4 +17,5 @@ public interface MessageNoticeDAO {
 	int delete(String id);
 	List<MessageNotice> list();
 	List<MessageNotice> search(Map<String,Object> searchParams,List<Sort> sortList);
+	List<MessageNotice> searchShort(Map<String,Object> searchParams,List<Sort> sortList);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/MessageNoticeService.java

@@ -14,4 +14,5 @@ public interface MessageNoticeService {
 	int delete(String id);
 	List<MessageNotice> list();
 	Page<MessageNotice> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	Page<MessageNotice> pageSearchShort(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 }

+ 9 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/MessageNoticeServiceImpl.java

@@ -67,4 +67,13 @@ public class MessageNoticeServiceImpl implements MessageNoticeService {
         
         return page;
 	}
+
+	@Override
+	public Page<MessageNotice> pageSearchShort(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+		Page<MessageNotice> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+			messageNoticeDAO.searchShort(searchParams,sortList);
+		});
+
+		return page;
+	}
 }

+ 14 - 0
common/src/main/resources/mapper/base/MessageNotice.xml

@@ -104,4 +104,18 @@ id_,title_,content_,sender_id,recipient_id,status_,del_flag,create_by,create_tim
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="searchShort" parameterType="hashmap" resultMap="MessageNoticeMap">
+		<![CDATA[
+			select id_,title_ from base_message_notice
+		]]>
+		<where>
+			and del_flag = false
+			<if test="searchParams.title != null">
+				and title_ like #{searchParams.title}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+			${sort.name} ${sort.order}
+		</foreach>
+	</select>
 </mapper>

+ 114 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/MessageNoticeApiController.java

@@ -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;
+    }
+}

+ 60 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/MessageReportApiController.java

@@ -0,0 +1,60 @@
+package com.jpsoft.smart.modules.mobile.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.MessageReport;
+import com.jpsoft.smart.modules.base.service.MessageReportService;
+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/messageReportApi")
+@Api(description = "messageReport")
+public class MessageReportApiController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private MessageReportService messageReportService;
+
+    @ApiOperation(value="添加信息")
+    @RequestMapping(value = "add",method = RequestMethod.POST)
+    public MessageResult<MessageReport> add(@RequestBody MessageReport messageReport,
+                                            String token,
+                                            @RequestAttribute String subject){
+        MessageResult<MessageReport> msgResult = new MessageResult<>();
+
+        try {
+            messageReport.setId(UUID.randomUUID().toString());
+            messageReport.setDelFlag(false);
+            messageReport.setCreateBy(subject);
+            messageReport.setCreateTime(new Date());
+            
+            int affectCount = messageReportService.insert(messageReport);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(messageReport);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}