Browse Source

添加根据成长值id查询成长值记录

huangshuwen 4 years ago
parent
commit
d7a9d44ce1

+ 9 - 0
member-services/src/main/java/com/liangjian/dataplatform/member/controller/UserGrowthLogController.java

@@ -21,6 +21,15 @@ public class UserGrowthLogController {
     @Autowired
     private IUserGrowthLogService iUserGrowthLogService;
 
+    @GetMapping("/logById")
+    @ApiOperation(value = "通过id查询成长值记录")
+    public ResultObject<UserGrowthLog> query(@ApiParam(value = "id",required = true) @RequestParam String id) {
+        return iUserGrowthLogService.queryById(id)
+                .map(i -> ResultObject.success(i))
+                .orElse(ResultObject.error("找不到成长值记录"));
+    }
+
+
     @GetMapping("/logs")
     @ApiOperation(value = "查询成长值记录")
     public Page<UserGrowthLog> query(@ApiParam(value = "页数", required = true) @RequestParam Integer page,

+ 4 - 0
member-services/src/main/java/com/liangjian/dataplatform/member/service/IUserGrowthLogService.java

@@ -3,12 +3,16 @@ package com.liangjian.dataplatform.member.service;
 import com.liangjian.dataplatform.member.entity.po.elasticsearch.UserGrowthLog;
 import org.springframework.data.domain.Page;
 
+import java.util.Optional;
+
 /**
  * @Author: 黄子奇
  * @Date: 2019/11/16
  */
 public interface IUserGrowthLogService {
 
+    Optional<UserGrowthLog> queryById(String id);
+
     Page<UserGrowthLog> queryBySecretPhone(String secretPhone, Integer page, Integer size);
 
     Page<UserGrowthLog> queryBySecretPhoneAndIncrease(String secretPhone, boolean increase, Integer page, Integer size);

+ 6 - 0
member-services/src/main/java/com/liangjian/dataplatform/member/service/impl/UserGrowthLogService.java

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * @Author: 黄子奇
@@ -22,6 +23,11 @@ public class UserGrowthLogService implements IUserGrowthLogService {
     @Autowired
     private UserGrowthLogRepository userGrowthLogRepository;
 
+    @Override
+    public Optional<UserGrowthLog> queryById(String id) {
+        return userGrowthLogRepository.findById(id);
+    }
+
     @Override
     public Page<UserGrowthLog> queryBySecretPhone(String secretPhone, Integer page, Integer size) {
         Pageable pageable = PageRequest.of(page,size, Sort.Direction.DESC,"crtDate");