Bladeren bron

爱心项目

jz.kai 1 jaar geleden
bovenliggende
commit
9003f627aa

+ 3 - 2
common/src/main/resources/mapper/base/LoveProject.xml

@@ -99,8 +99,9 @@
 			select * from base_love_project
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			del_flag = 0
+			<if test="searchParams.title != null">
+				and title_ like #{searchParams.title}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 4 - 1
web/src/main/java/com/jpsoft/employment/config/WebMvcConfig.java

@@ -72,7 +72,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/training/trainingDetail")
 				.excludePathPatterns("/wechat/decryptData")
 				.excludePathPatterns("/mobile/user/saveLoginRecord")
-
+				//心愿互换
+				.excludePathPatterns("/base/api/wish/list")
+				.excludePathPatterns("/base/api/wish/edit")
+				.excludePathPatterns("/base/api/wish/wishTypeList")
 		;
 
 

+ 99 - 0
web/src/main/java/com/jpsoft/employment/modules/base/api/LoveApi.java

@@ -0,0 +1,99 @@
+package com.jpsoft.employment.modules.base.api;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.LoveProject;
+import com.jpsoft.employment.modules.base.entity.WishInfo;
+import com.jpsoft.employment.modules.base.entity.WishInfoUserRecord;
+import com.jpsoft.employment.modules.base.service.LoveProjectService;
+import com.jpsoft.employment.modules.base.service.StudentAspirationsService;
+import com.jpsoft.employment.modules.base.service.WishInfoService;
+import com.jpsoft.employment.modules.base.service.WishInfoUserRecordService;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.sys.entity.DataDictionary;
+import com.jpsoft.employment.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.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/api/love")
+@Api(description = "爱心项目")
+public class LoveApi {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private LoveProjectService loveProjectService;
+    @Autowired
+    private WishInfoUserRecordService wishInfoUserRecordService;
+    @Autowired
+    private StudentAspirationsService studentAspirationsService;
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+
+    @ApiOperation(value="心愿单列表")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="title", value="名称", required=false, paramType="query"),
+    })
+    public MessageResult list(
+            String title,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
+        MessageResult msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+        if (StringUtils.isNotEmpty(title)) {
+            searchParams.put("title","%" + title + "%");
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        Page<LoveProject> page = loveProjectService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="心愿单详情")
+    @GetMapping("edit/{id}")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="id", value="ID", required=true, paramType="query"),
+    })
+    public MessageResult<LoveProject> edit(@PathVariable("id") String id){
+        MessageResult<LoveProject> msgResult = new MessageResult<>();
+
+        try {
+            LoveProject loveProject = loveProjectService.get(id);
+
+            if (loveProject != null) {
+                msgResult.setResult(true);
+                msgResult.setData(loveProject);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}

+ 3 - 3
web/src/main/java/com/jpsoft/employment/modules/base/api/WishApi.java

@@ -8,6 +8,7 @@ import com.jpsoft.employment.modules.base.service.WishInfoService;
 import com.jpsoft.employment.modules.base.service.WishInfoUserRecordService;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
 import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
 import com.jpsoft.employment.modules.sys.entity.DataDictionary;
 import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
 import io.swagger.annotations.Api;
@@ -47,8 +48,7 @@ public class WishApi {
     public MessageResult list(
             String title,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
-            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
-            @RequestAttribute String subject){
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
         MessageResult msgResult = new MessageResult<>();
 
         Map<String,Object> searchParams = new HashMap<>();
@@ -62,7 +62,7 @@ public class WishApi {
         Page<WishInfo> page = wishInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
         msgResult.setResult(true);
-        msgResult.setData(page.getResult());
+        msgResult.setData(PojoUtils.pageWrapper(page));
 
         return msgResult;
     }