Browse Source

数据统计接口

jz.kai 1 year ago
parent
commit
72ecc30d5d

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/LoveProjectDAO.java

@@ -15,4 +15,5 @@ public interface LoveProjectDAO {
 	int delete(String id);
 	List<LoveProject> list();
 	List<LoveProject> search(Map<String, Object> searchParams, List<Sort> sortList);
+	int countByType(String type);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/WishInfoUserRecordDAO.java

@@ -17,4 +17,5 @@ public interface WishInfoUserRecordDAO {
 	List<WishInfoUserRecord> search(Map<String, Object> searchParams, List<Sort> sortList);
 	int countByWish(String wishInfoId);
 	String getLastSerialNumber(String date);
+	int countByUser(String regUserId);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/LoveProject.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
+import java.util.List;
 
 import org.springframework.data.annotation.Transient;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -66,6 +67,10 @@ public class LoveProject {
 	@ApiModelProperty(value = "回馈方式")
 	private String[] feedbackMethodArray;
 
+	@Transient
+	@ApiModelProperty(value = "回馈方式")
+	List<FeedbackMethod> feedbackMethodList;
+
 
 	@ApiModelProperty(value = "类型(1:爱心项目,2:爱心捐献,3:志愿者,4:爱心帮扶)")
 	private String typeN;

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/LoveProjectService.java

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

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/WishInfoUserRecordService.java

@@ -16,4 +16,5 @@ public interface WishInfoUserRecordService {
 	Page<WishInfoUserRecord> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 	int countByWish(String wishInfoId);
 	String getLastSerialNumber(String date);
+	int countByUser(String regUserId);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/LoveProjectServiceImpl.java

@@ -67,4 +67,10 @@ public class LoveProjectServiceImpl implements LoveProjectService {
         
         return page;
 	}
+
+	@Override
+	public int countByType(String type) {
+		// TODO Auto-generated method stub
+		return loveProjectDAO.countByType(type);
+	}
 }

+ 5 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/WishInfoUserRecordServiceImpl.java

@@ -77,4 +77,9 @@ public class WishInfoUserRecordServiceImpl implements WishInfoUserRecordService
 	public String getLastSerialNumber(String date) {
 		return wishInfoUserRecordDAO.getLastSerialNumber(date);
 	}
+
+	@Override
+	public int countByUser(String regUserId) {
+		return wishInfoUserRecordDAO.countByUser(regUserId);
+	}
 }

+ 7 - 0
common/src/main/resources/mapper/base/LoveProject.xml

@@ -96,6 +96,13 @@
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_love_project where id_=#{0}
 	</select>
+	<select id="countByType" parameterType="string" resultType="int">
+		SELECT COUNT(*) FROM base_love_project
+		WHERE del_flag = 0
+		<if test="type != null">
+			AND type_ = #{type}
+		</if>
+	</select>
 	<select id="list" resultMap="LoveProjectMap">
 		select * from base_love_project
 	</select>

+ 7 - 0
common/src/main/resources/mapper/base/WishInfoUserRecord.xml

@@ -142,6 +142,13 @@
 		WHERE del_flag = 0
 		AND wish_info_id = #{0}
 	</select>
+	<select id="countByUser" parameterType="string" resultType="int">
+		SELECT COUNT(*) FROM base_wish_info_user_record
+		WHERE del_flag = 0
+		<if test="regUserId != null">
+			AND reg_user_id = #{regUserId}
+		</if>
+	</select>
 	<select id="list" resultMap="WishInfoUserRecordMap">
 		select * from base_wish_info_user_record
 	</select>

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

@@ -75,6 +75,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				//用户
 				.excludePathPatterns("/base/api/regUser/saveRegUser")
 				.excludePathPatterns("/base/api/regUser/getByOpenId")
+				.excludePathPatterns("/base/api/chart/dataTotal")
 				//心愿互换
 				.excludePathPatterns("/base/api/wish/list")
 				.excludePathPatterns("/base/api/wish/edit")

+ 85 - 0
web/src/main/java/com/jpsoft/employment/modules/base/api/ChartApi.java

@@ -0,0 +1,85 @@
+package com.jpsoft.employment.modules.base.api;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.FeedbackMethod;
+import com.jpsoft.employment.modules.base.entity.LoveProject;
+import com.jpsoft.employment.modules.base.service.FeedbackMethodService;
+import com.jpsoft.employment.modules.base.service.LoveProjectService;
+import com.jpsoft.employment.modules.base.service.StudentAspirationsService;
+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.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 javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/base/api/chart")
+@Api(description = "统计数据")
+public class ChartApi {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private LoveProjectService loveProjectService;
+    @Autowired
+    private WishInfoUserRecordService wishInfoUserRecordService;
+    @Autowired
+    private StudentAspirationsService studentAspirationsService;
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private FeedbackMethodService feedbackMethodService;
+
+    @ApiOperation(value="数据统计")
+    @RequestMapping(value = "dataTotal",method = RequestMethod.POST)
+    public MessageResult dataTotal(){
+        MessageResult msgResult = new MessageResult<>();
+        Map<String,Object> map = new HashMap<>();
+
+        Integer countWishRecord = wishInfoUserRecordService.countByUser(null);
+        Integer countLoveProject = loveProjectService.countByType(null);
+        Integer countAssist = 0;
+
+        map.put("countWishRecord",countWishRecord);
+        map.put("countLoveProject",countLoveProject);
+        map.put("countAssist",countAssist);
+
+        msgResult.setResult(true);
+        msgResult.setData(map);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="我的数据统计")
+    @RequestMapping(value = "dataMyTotal",method = RequestMethod.POST)
+    public MessageResult dataMyTotal(HttpServletRequest request){
+        MessageResult msgResult = new MessageResult<>();
+        String subject = (String)request.getAttribute("subject");
+        Map<String,Object> map = new HashMap<>();
+
+        Integer countWishRecord = wishInfoUserRecordService.countByUser(subject);
+        Integer countGood = 0;
+
+        map.put("countWishRecord",countWishRecord);
+        map.put("countGood",countGood);
+
+        msgResult.setResult(true);
+        msgResult.setData(map);
+
+        return msgResult;
+    }
+}

+ 20 - 7
web/src/main/java/com/jpsoft/employment/modules/base/api/LoveApi.java

@@ -1,13 +1,11 @@
 package com.jpsoft.employment.modules.base.api;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.FeedbackMethod;
 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.base.service.*;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
 import com.jpsoft.employment.modules.common.dto.Sort;
 import com.jpsoft.employment.modules.common.utils.PojoUtils;
@@ -40,14 +38,17 @@ public class LoveApi {
     private StudentAspirationsService studentAspirationsService;
     @Autowired
     private DataDictionaryService dataDictionaryService;
+    @Autowired
+    private FeedbackMethodService feedbackMethodService;
 
     @ApiOperation(value="项目列表")
     @RequestMapping(value = "list",method = RequestMethod.POST)
     @ApiImplicitParams({
             @ApiImplicitParam(name="title", value="名称", required=false, paramType="query"),
+            @ApiImplicitParam(name="type", value="类型(1:爱心项目,2:爱心捐献,3:志愿者,4:爱心帮扶)", required=false, paramType="query"),
     })
     public MessageResult list(
-            String title,
+            String title, String type,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize){
         MessageResult msgResult = new MessageResult<>();
@@ -56,6 +57,9 @@ public class LoveApi {
         if (StringUtils.isNotEmpty(title)) {
             searchParams.put("title","%" + title + "%");
         }
+        if (StringUtils.isNotEmpty(type)) {
+            searchParams.put("type",type);
+        }
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("create_time","desc"));
@@ -69,15 +73,24 @@ public class LoveApi {
     }
 
     @ApiOperation(value="项目详情")
-    @GetMapping("edit/{id}")
+    @RequestMapping(value = "edit",method = RequestMethod.POST)
     @ApiImplicitParams({
             @ApiImplicitParam(name="id", value="ID", required=true, paramType="query"),
     })
-    public MessageResult<LoveProject> edit(@PathVariable("id") String id){
+    public MessageResult<LoveProject> edit(String id){
         MessageResult<LoveProject> msgResult = new MessageResult<>();
 
         try {
             LoveProject loveProject = loveProjectService.get(id);
+            if(StringUtils.isNotEmpty(loveProject.getFeedbackMethod())){
+                String[] ids = loveProject.getFeedbackMethod().split(",");
+                List<FeedbackMethod> list = new ArrayList<>();
+                for(int i=0; i<ids.length; i++){
+                    FeedbackMethod feedbackMethod = feedbackMethodService.get(ids[i]);
+                    list.add(feedbackMethod);
+                }
+                loveProject.setFeedbackMethodList(list);
+            }
 
             if (loveProject != null) {
                 msgResult.setResult(true);

+ 1 - 1
web/src/main/resources/application-dev.yml

@@ -19,7 +19,7 @@ spring:
 
 logger:
   level: WARN
-  dir: E:\develop\javaproject\love-donation-server
+  dir: D:\Logs\love-donation-server
 
 wx:
   pay:

+ 5 - 4
web/src/main/resources/application.yml

@@ -63,8 +63,7 @@ spring:
     # Redis数据库索引(默认为0)
     database: 4
     # Redis服务器地址
-    host: 127.0.0.1
-    #host: 127.0.0.1
+    host: 192.168.33.20
     # Redis服务器连接端口
     port: 6379
     # Redis服务器连接密码(默认为空)
@@ -121,8 +120,10 @@ wx:
   appSecret: aaf8db83ff69c3716a62e3d5bd21c292
 applet:
   #小程序
-  appId: wx0526fcf6d276854f
-  appSecret: a55f9fef68b3d1dfdee5b5638b502cd4
+#  appId: wx0526fcf6d276854f
+#  appSecret: a55f9fef68b3d1dfdee5b5638b502cd4
+  appId: wx7eec18cd89b9d777
+  appSecret: 5a0aa258fda3e75097a80764dab73202
 
 #oss:
 #  accessKeyId: LTAILGOo7bwpkvnq