Просмотр исходного кода

每日签到页面接口开发

WangChanghua 1 год назад
Родитель
Сommit
8469907e68

+ 36 - 0
src/main/java/com/chelvc/cloud/maintain/controller/SignController.java

@@ -1,12 +1,28 @@
 package com.chelvc.cloud.maintain.controller;
 
+import com.chelvc.cloud.maintain.copier.ScoreCopier;
+import com.chelvc.cloud.maintain.vo.ScoreVO;
+import com.chelvc.cloud.maintain.vo.SignIndexVO;
+import com.chelvc.cloud.uc.api.constant.ScoreOrigin;
+import com.chelvc.cloud.uc.api.dto.ScoreDTO;
+import com.chelvc.cloud.uc.api.dto.SignDTO;
+import com.chelvc.cloud.uc.api.param.ScorePagingParam;
+import com.chelvc.cloud.uc.api.service.ScoreService;
 import com.chelvc.cloud.uc.api.service.SignService;
 import com.chelvc.framework.base.annotation.UnifiedResponseBody;
+import com.chelvc.framework.base.model.Pagination;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * 签到接口
  *
@@ -19,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
 public class SignController {
     @DubboReference
     private SignService signService;
+    @DubboReference
+    private ScoreService scoreService;
 
     /**
      * 用户签到
@@ -27,4 +45,22 @@ public class SignController {
     public void sign() {
         this.signService.sign();
     }
+
+    /**
+     * 每日签到页面信息
+     *
+     * @return 每日签到页面信息
+     */
+    @GetMapping("/sign/index")
+    public SignIndexVO getCustomerSign() {
+        SignIndexVO sign = SignIndexVO.builder().build();
+        SignDTO todaySign = this.signService.getTodaySign();
+        if (ObjectUtils.isEmpty(todaySign) || todaySign.getSignDay() == null) {
+            sign.setSignDay(0);
+        } else {
+            sign.setSignDay(todaySign.getSignDay());
+        }
+        sign.setSignScore(this.scoreService.countScoreValue(ScoreOrigin.SIGN.name()));
+        return sign;
+    }
 }

+ 30 - 0
src/main/java/com/chelvc/cloud/maintain/vo/SignIndexVO.java

@@ -0,0 +1,30 @@
+package com.chelvc.cloud.maintain.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.SuperBuilder;
+
+import java.io.Serializable;
+
+/**
+ * 每日签到页面信息
+ *
+ * @author 七仔
+ * @date 2023/5/26
+ */
+@Data
+@SuperBuilder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SignIndexVO implements Serializable {
+    /**
+     * 连续签到数
+     */
+    private Integer signDay;
+
+    /**
+     * 签到总积分
+     */
+    private Long signScore;
+}