“xubinhui 2 năm trước cách đây
mục cha
commit
b64bc965c0

+ 64 - 2
src/main/java/com/izouma/nineth/domain/Rice.java

@@ -38,12 +38,13 @@ public class Rice extends BaseEntity {
     @ApiModelProperty("等级")
     @ApiModelProperty("等级")
     private Long level;
     private Long level;
 
 
-    @ApiModelProperty("水滴次数")
-    private Long waterDropCount;
 
 
     @ApiModelProperty("签到次数")
     @ApiModelProperty("签到次数")
     private Long signCount;
     private Long signCount;
 
 
+    @ApiModelProperty("助力次数")
+    private Long helpCount =0L;
+
     @ApiModelProperty("上次签到时间")
     @ApiModelProperty("上次签到时间")
     private Long lastSignInTime;
     private Long lastSignInTime;
 
 
@@ -63,5 +64,66 @@ public class Rice extends BaseEntity {
     private Integer InviteCount = 0;
     private Integer InviteCount = 0;
 
 
 
 
+    @ApiModelProperty("水滴总数")
+    private Long waterDropCount=0L;
+
+    @ApiModelProperty("水滴之签到")
+    private Long numberOfSingnIn ;
+
+    @ApiModelProperty("水滴之邀请")
+    private Long numberOfInviteFriends= 0L;
+
+    @ApiModelProperty("水滴之助力")
+    private Long numberOfHelpOthers= 0L;
+
+    @ApiModelProperty("水滴之积分兑换")
+    private Long numberOfScoreExchanged= 0L;
+
+    @ApiModelProperty("水滴之活动")
+    private Long numberOfActivity= 0L;
+
+
+
+
+
+    public Long getWaterDropCount() {
+        return waterDropCount == null ? 0L : waterDropCount;
+    }
+
+    public Long getNumberOfSingnIn() {
+        return numberOfSingnIn == null ? 0L : numberOfSingnIn;
+    }
+
+    public Long getNumberOfInviteFriends() {
+        return numberOfInviteFriends == null ? 0L : numberOfInviteFriends;
+    }
+
+    public Long getNumberOfHelpOthers() {
+        return numberOfHelpOthers == null ? 0L : numberOfHelpOthers;
+    }
+
+    public Long getNumberOfScoreExchanged() {
+        return numberOfScoreExchanged == null ? 0L : numberOfScoreExchanged;
+    }
+
+    public Long getNumberOfActivity() {
+        return numberOfActivity == null ? 0L : numberOfActivity;
+    }
+
+
+    public Long getLevel() {
+        return level == null ? 0L : level;
+    }
+
+    public Long getSignCount() {
+        return signCount == null ? 0L : signCount;
+    }
+
+    public Long getHelpCount() {
+        return helpCount == null ? 0L : helpCount;
+    }
+
+
+
 
 
 }
 }

+ 56 - 0
src/main/java/com/izouma/nineth/domain/RiceWaterTypeForWatreing.java

@@ -0,0 +1,56 @@
+package com.izouma.nineth.domain;
+
+
+import com.izouma.nineth.enums.RiceBubbleStatus;
+import com.izouma.nineth.enums.RiceWaterType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import java.time.LocalDateTime;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@ApiModel("水稻水滴类型对应浇水")
+public class RiceWaterTypeForWatreing  extends BaseEntity {
+
+    @ApiModelProperty("用户ID")
+    @Column(name = "user_id")
+    private Long userId;
+
+    @ApiModelProperty("类型:水滴,活动积分,积分,经验值")
+    @Enumerated(EnumType.STRING)
+    private RiceWaterType type;
+
+
+    @ApiModelProperty("类型数量")
+    private Long counts;
+
+    @ApiModelProperty("气泡状态类型,未点击,已点击,已过期")
+    @Column(name = "rice_bubble_status")
+    private RiceBubbleStatus riceBubbleStatus;
+
+    @ApiModelProperty("气泡创建时间")
+    @Column(name = "bubble_created_at")
+    private LocalDateTime bubbleCreatedAt;
+
+    public  Long getCounts(){
+        return  counts == null ? 0 : counts;
+    }
+
+
+
+}
+
+
+
+
+

+ 21 - 0
src/main/java/com/izouma/nineth/enums/RiceBubbleStatus.java

@@ -0,0 +1,21 @@
+package com.izouma.nineth.enums;
+
+
+public enum RiceBubbleStatus {
+
+    NOT_CLICKED("未点击"),
+    CLICKED("已点击"),
+    EXPIRED("已过期");
+
+
+
+    private final String description;
+
+    RiceBubbleStatus(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 20 - 0
src/main/java/com/izouma/nineth/enums/RiceWaterType.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.enums;
+
+public enum RiceWaterType {
+    DAILY_CHECK_IN("每日签到"),
+    INVITE_FRIENDS("邀请好友"),
+    FRIENDS_HELP("好友助力"),
+    REDEEM("积分兑换"),
+    ACTIVITY_AWARD("活动奖励");
+
+
+    private final String description;
+
+    RiceWaterType(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 3 - 0
src/main/java/com/izouma/nineth/repo/RiceInviteRepo.java

@@ -35,6 +35,9 @@ public interface RiceInviteRepo extends JpaRepository<RiceInvite, Long>, JpaSpec
     @Query("SELECT COUNT(r) FROM RiceInvite r WHERE r.helpeeId = :helpeeId AND r.createTime >= :todayStartTime AND r.createTime < :todayEndTime")
     @Query("SELECT COUNT(r) FROM RiceInvite r WHERE r.helpeeId = :helpeeId AND r.createTime >= :todayStartTime AND r.createTime < :todayEndTime")
     int countRiceInviteBy(@Param("helpeeId") Long helpeeId, @Param("todayStartTime") Long todayStartTime, @Param("todayEndTime") Long todayEndTime);
     int countRiceInviteBy(@Param("helpeeId") Long helpeeId, @Param("todayStartTime") Long todayStartTime, @Param("todayEndTime") Long todayEndTime);
 
 
+    @Query("SELECT COUNT(r) FROM RiceInvite r WHERE r.helperId = :helperId AND r.createTime >= :todayStartTime AND r.createTime < :todayEndTime")
+    int countRiceInviteByHelperId(@Param("helperId") Long helperId, @Param("todayStartTime") Long todayStartTime, @Param("todayEndTime") Long todayEndTime);
+
 
 
 
 
 }
 }

+ 16 - 0
src/main/java/com/izouma/nineth/repo/RiceWaterTypeForWatreingRepo.java

@@ -0,0 +1,16 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.RiceWaterTypeForWatreing;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+
+public interface RiceWaterTypeForWatreingRepo extends JpaRepository<RiceWaterTypeForWatreing, Long>, JpaSpecificationExecutor<RiceWaterTypeForWatreing> {
+    @Query("update RiceWaterTypeForWatreing t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+}

+ 82 - 98
src/main/java/com/izouma/nineth/service/RiceService.java

@@ -43,7 +43,7 @@ public class RiceService {
     private              RiceOperationRecordRepo     riceOperationRecordRepo;
     private              RiceOperationRecordRepo     riceOperationRecordRepo;
     private              UserRepo                    userRepo;
     private              UserRepo                    userRepo;
     private              SysConfigService            sysConfigService;
     private              SysConfigService            sysConfigService;
-    private RiceInviteRepo  riceInviteRepo;
+    private              RiceInviteRepo              riceInviteRepo;
 
 
     public Page<Rice> all(PageQuery pageQuery) {
     public Page<Rice> all(PageQuery pageQuery) {
         return riceRepo.findAll(JpaUtils.toSpecification(pageQuery, Rice.class), JpaUtils.toPageRequest(pageQuery));
         return riceRepo.findAll(JpaUtils.toSpecification(pageQuery, Rice.class), JpaUtils.toPageRequest(pageQuery));
@@ -60,7 +60,7 @@ public class RiceService {
             User user = byId.get();
             User user = byId.get();
             nickname = user.getNickname();
             nickname = user.getNickname();
             avatar = user.getAvatar();
             avatar = user.getAvatar();
-            phone= user.getPhone();
+            phone = user.getPhone();
         } else {
         } else {
             throw new BusinessException("用户不存在");
             throw new BusinessException("用户不存在");
         }
         }
@@ -78,7 +78,6 @@ public class RiceService {
             rice.setNickname(nickname);
             rice.setNickname(nickname);
             rice.setPhone(phone);
             rice.setPhone(phone);
             rice.setLevel(0L);
             rice.setLevel(0L);
-            rice.setWaterDropCount(0L);
             rice.setSignCount(0L);
             rice.setSignCount(0L);
             rice.setSelfScore(0L);
             rice.setSelfScore(0L);
             rice.setSelfActivityScore(0L);
             rice.setSelfActivityScore(0L);
@@ -113,8 +112,6 @@ public class RiceService {
         Optional<Rice> byUserId = riceRepo.findByUserId(authId);
         Optional<Rice> byUserId = riceRepo.findByUserId(authId);
         if (byUserId.isPresent()) {
         if (byUserId.isPresent()) {
             Rice rice = byUserId.get();
             Rice rice = byUserId.get();
-            empiricalValue = rice.getEmpiricalValue();
-
             JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
             JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
             JsonArray jsonArray = jsonReader.readArray();
             JsonArray jsonArray = jsonReader.readArray();
 
 
@@ -171,6 +168,7 @@ public class RiceService {
         if (byUserId.isPresent()) {
         if (byUserId.isPresent()) {
             Rice rice = byUserId.get();
             Rice rice = byUserId.get();
             int i = riceInviteRepo.countRiceInviteBy(rice.getUserId(), getTodayStartTime(), getTodayEndTime());
             int i = riceInviteRepo.countRiceInviteBy(rice.getUserId(), getTodayStartTime(), getTodayEndTime());
+            int InviteHelpOthersCounts = riceInviteRepo.countRiceInviteByHelperId(authId, getTodayStartTime(), getTodayEndTime());
 
 
             Long lastSignInTime = rice.getLastSignInTime();
             Long lastSignInTime = rice.getLastSignInTime();
             Long currentTime = System.currentTimeMillis();
             Long currentTime = System.currentTimeMillis();
@@ -179,16 +177,16 @@ public class RiceService {
             Boolean isInvited;
             Boolean isInvited;
             Boolean isCanExchangeScore;
             Boolean isCanExchangeScore;
 
 
-            if(rice.getSelfActivityScore()<10&&rice.getSelfScore()>=2){
-                isCanExchangeScore=true;
-            }else {
-                isCanExchangeScore=false;
+            if (rice.getSelfActivityScore() < 10 && rice.getSelfScore() >= 2) {
+                isCanExchangeScore = true;
+            } else {
+                isCanExchangeScore = false;
             }
             }
 
 
-            if(i==0){
+            if (i == 0) {
                 isInvited = false;
                 isInvited = false;
 
 
-            }else {
+            } else {
                 isInvited = true;
                 isInvited = true;
             }
             }
 
 
@@ -204,8 +202,9 @@ public class RiceService {
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
-                        .add("isInvited",isInvited)
-                .add("isCanExchangeScore",isCanExchangeScore);
+                        .add("isInvited", isInvited)
+                        .add("isCanExchangeScore", isCanExchangeScore)
+                        .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
             }
             }
             // 判断今天是否已经签到过
             // 判断今天是否已经签到过
             if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
             if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
@@ -213,15 +212,17 @@ public class RiceService {
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
-                        .add("isInvited",isInvited)
-                .add("isCanExchangeScore",isCanExchangeScore);
+                        .add("isInvited", isInvited)
+                        .add("isCanExchangeScore", isCanExchangeScore)
+                        .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
             } else {
             } else {
                 return R.success("未签到").add("isSignedIn", false)
                 return R.success("未签到").add("isSignedIn", false)
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("exchangeCount", rice.getExchangeCount() == null ? 0 : rice.getExchangeCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("waterDropCount", rice.getWaterDropCount())
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
                         .add("isCanExchangeActivityScoreForWater", isCanExchangeActivityScoreForWater)
-                        .add("isInvited",isInvited)
-                .add("isCanExchangeScore",isCanExchangeScore);
+                        .add("isInvited", isInvited)
+                        .add("isCanExchangeScore", isCanExchangeScore)
+                        .add("InviteHelpOthersCounts", InviteHelpOthersCounts);
             }
             }
         }
         }
         return R.error("查询失败");
         return R.error("查询失败");
@@ -232,15 +233,9 @@ public class RiceService {
      * 获取当前用户积分
      * 获取当前用户积分
      */
      */
     public R<String> getCurrentScore() {
     public R<String> getCurrentScore() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long authId = authenticatedUser.getId();
-        Optional<Rice> byUserId = riceRepo.findByUserId(authId);
-        if (byUserId.isPresent()) {
-            Rice rice = byUserId.get();
-            Long selfScore = rice.getSelfScore();
-            return R.success("获取到当前用户积分").add("selfScore", selfScore);
-        }
-        return R.error("获取失败");
+        Rice rice = riceRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()).orElseThrow(new BusinessException("用户不存在"));
+        Long selfScore = rice.getSelfScore();
+        return R.success("获取到当前用户积分").add("selfScore", selfScore);
     }
     }
 
 
 
 
@@ -256,6 +251,7 @@ public class RiceService {
     }
     }
 
 
 
 
+    //一个获取积分排行榜的接口
     public List<RiceDTO> getTop100(Long userId) {
     public List<RiceDTO> getTop100(Long userId) {
         List<Rice> top100Rices = riceRepo.findTop100OrderByEmpiricalValueDesc();
         List<Rice> top100Rices = riceRepo.findTop100OrderByEmpiricalValueDesc();
         List<RiceDTO> result = new ArrayList<>();
         List<RiceDTO> result = new ArrayList<>();
@@ -354,8 +350,7 @@ public class RiceService {
     //浇水
     //浇水
     public R<? extends Object> watering() {
     public R<? extends Object> watering() {
         // 获取当前用户 ID,
         // 获取当前用户 ID,
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long authId = authenticatedUser.getId();
+        Long authId = SecurityUtils.getAuthenticatedUser().getId();
         Optional<Rice> byUserId = riceRepo.findByUserId(authId);
         Optional<Rice> byUserId = riceRepo.findByUserId(authId);
         if (byUserId.isPresent()) {
         if (byUserId.isPresent()) {
             Rice rice = byUserId.get();
             Rice rice = byUserId.get();
@@ -368,7 +363,7 @@ public class RiceService {
             }
             }
             // 浇水成功,更新水滴次数,经验值加2
             // 浇水成功,更新水滴次数,经验值加2
             rice.setWaterDropCount(waterDropCount - 1);
             rice.setWaterDropCount(waterDropCount - 1);
-            rice.setEmpiricalValue(rice.getEmpiricalValue() + 2);
+            rice.setEmpiricalValue(rice.getEmpiricalValue() + 10);
             riceRepo.save(rice);
             riceRepo.save(rice);
             createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, rice
             createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, rice
                     .getWaterDropCount());
                     .getWaterDropCount());
@@ -390,8 +385,8 @@ public class RiceService {
     public Long getTodayWateringCount(Long userId) {
     public Long getTodayWateringCount(Long userId) {
         List<RiceUserWaterDropRecord> records = riceUserWaterDropRecordRepo.findByUserId(userId);
         List<RiceUserWaterDropRecord> records = riceUserWaterDropRecordRepo.findByUserId(userId);
         Long count = records.stream()
         Long count = records.stream()
-                .filter(RiceUserWaterDropRecord::isToday)
-                .count();
+                            .filter(RiceUserWaterDropRecord::isToday)
+                            .count();
         return count;
         return count;
     }
     }
 
 
@@ -417,7 +412,7 @@ public class RiceService {
             }
             }
             if (currentEmpiricalValue >= start && currentEmpiricalValue < nextStart) {
             if (currentEmpiricalValue >= start && currentEmpiricalValue < nextStart) {
                 Long levelUpEmpiricalValue = nextStart - currentEmpiricalValue;
                 Long levelUpEmpiricalValue = nextStart - currentEmpiricalValue;
-                Long waterDropNeededForLevelUp = levelUpEmpiricalValue / 2;
+                Long waterDropNeededForLevelUp = levelUpEmpiricalValue / 10;
                 return waterDropNeededForLevelUp;
                 return waterDropNeededForLevelUp;
             }
             }
         }
         }
@@ -427,86 +422,75 @@ public class RiceService {
 
 
     //签到
     //签到
     public R<?> signIn(Long userId) {
     public R<?> signIn(Long userId) {
-        Optional<Rice> byUserId = riceRepo.findByUserId(userId);
-        if (byUserId.isPresent()) {
-            Rice rice = byUserId.get();
-            Long lastSignInTime = rice.getLastSignInTime();
-            Long currentTime = System.currentTimeMillis();
-            Long beforeWaterDropCount = rice.getWaterDropCount();
-            Long beforeEmpiricalValue = rice.getEmpiricalValue();
-            // 判断上次签到时间是否为空,如果为空,则默认为从未签到过
-            if (lastSignInTime == null) {
-                rice.setWaterDropCount(rice.getWaterDropCount() + 1);
-                rice.setSignCount(rice.getSignCount() + 1);
-                rice.setLastSignInTime(currentTime);
-                riceRepo.save(rice);
-                createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
-                        .getWaterDropCount());
-                return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
-            }
-            // 判断今天是否已经签到过
-            if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(currentTime))) {
-                return R.error("今天已经签到过了").add("can", false);
-            }
-            // 签到成功,水滴数加1,签到次数加1,更新签到时间
+        Rice rice = riceRepo.findByUserId(userId).orElseThrow(new BusinessException("没找到用户"));
+        Long lastSignInTime = rice.getLastSignInTime();
+        Long beforeWaterDropCount = rice.getWaterDropCount();
+        // 判断上次签到时间是否为空,如果为空,则默认为从未签到过
+        if (lastSignInTime == null) {
             rice.setWaterDropCount(rice.getWaterDropCount() + 1);
             rice.setWaterDropCount(rice.getWaterDropCount() + 1);
             rice.setSignCount(rice.getSignCount() + 1);
             rice.setSignCount(rice.getSignCount() + 1);
-            rice.setLastSignInTime(currentTime);
+            rice.setLastSignInTime(System.currentTimeMillis());
+            rice.setNumberOfSingnIn(rice.getNumberOfSingnIn() + 1);
             riceRepo.save(rice);
             riceRepo.save(rice);
             createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
             createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
                     .getWaterDropCount());
                     .getWaterDropCount());
             return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
             return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
         }
         }
-        return R.error("签到失败").add("can", false);
-    }
-
+        // 判断今天是否已经签到过
+        if (DateUtils.isSameDay(new Date(lastSignInTime), new Date(System.currentTimeMillis()))) {
+            return R.error("今天已经签到过了").add("can", false);
+        }
+        // 签到成功,水滴数加1,签到次数加1,更新签到时间
+        rice.setWaterDropCount(rice.getWaterDropCount() + 1);
+        rice.setSignCount(rice.getSignCount() + 1);
+        rice.setLastSignInTime(System.currentTimeMillis());
+        riceRepo.save(rice);
 
 
-    //积分兑换水滴
-    public R<?> exchangeScoreForWaterDrop(User authenticatedUser) {
-        Long authId = authenticatedUser.getId();
-        Optional<Rice> byUserId = riceRepo.findByUserId(authId);
-        if (byUserId.isPresent()) {
-            Rice rice = byUserId.get();
-            Long selfScore = rice.getSelfScore();
-            Long beforeSelfScore = rice.getSelfScore();
-            Integer waterDropCount = Math.toIntExact(rice.getWaterDropCount());
-            Long beforeWaterDropCount = rice.getWaterDropCount();
+        createRiceOperationRecord(userId, RiceOperationType.WATER_DROP, (long) 1, beforeWaterDropCount, rice
+                .getWaterDropCount());
+        return R.success("签到成功").add("can", true).add("waterDropCount", rice.getWaterDropCount());
 
 
-            // 每次兑换需要消耗的积分和最大兑换次数
-            int exchangeScore = 2;
-            int maxExchangeCount = 10;
 
 
-            // 计算当前可兑换的次数和消耗的积分
-//            if (rice.getExchangeCount() == null) {
-//                rice.setExchangeCount(0);
-//            }
+    }
 
 
-            if (rice.getExchangeCount() == 10) {
-                return R.error("您今天已经兑换十次了.").add("waterDropCount", rice.getWaterDropCount());
-            }
-            int exchangeCount = Math.min((int) (selfScore / exchangeScore), maxExchangeCount - rice.getExchangeCount());
-            int totalScore = exchangeCount * exchangeScore;
 
 
-            if (exchangeCount > 0) {
-                rice.setSelfScore(selfScore - totalScore);
-                rice.setWaterDropCount((long) (waterDropCount + exchangeCount));
-                rice.setExchangeCount(rice.getExchangeCount()+exchangeCount);
-                riceRepo.save(rice);
-                createRiceOperationRecord(authId, RiceOperationType.WATER_DROP, (long) exchangeCount, beforeWaterDropCount, rice
-                        .getWaterDropCount());
+    //积分兑换水滴
+    public R<?> exchangeScoreForWaterDrop(User authenticatedUser) {
+        Rice rice = riceRepo.findByUserId(authenticatedUser.getId()).orElseThrow(new BusinessException("没找到用户"));
+        //获取当前的积分
+        Long selfScore = rice.getSelfScore();
+        Long beforeSelfScore = rice.getSelfScore();
+        Integer waterDropCount = Math.toIntExact(rice.getWaterDropCount());
+        Long beforeWaterDropCount = rice.getWaterDropCount();
+        // 每次兑换需要消耗的积分和最大兑换次数
+        int exchangeScore = 10;
+        int maxExchangeCount = 10;
+        if (rice.getExchangeCount() == 10) {
+            return R.error("您今天已经兑换十次了.").add("waterDropCount", rice.getWaterDropCount()).add("exchangeCount", rice.getExchangeCount());
+        }
+        int exchangeCount = Math.min((int) (selfScore / exchangeScore), maxExchangeCount - rice.getExchangeCount());
+        int totalScore = exchangeCount * exchangeScore;
+
+        if (exchangeCount > 0) {
+            rice.setSelfScore(selfScore - totalScore);
+            rice.setWaterDropCount((long) (waterDropCount + exchangeCount));
+            rice.setNumberOfScoreExchanged(rice.getNumberOfScoreExchanged()+exchangeCount);
+            rice.setExchangeCount(rice.getExchangeCount() + exchangeCount);
+            riceRepo.save(rice);
+            createRiceOperationRecord(authenticatedUser.getId(), RiceOperationType.WATER_DROP, (long) exchangeCount, beforeWaterDropCount, rice
+                    .getWaterDropCount());
 
 
-                createRiceOperationRecord(authId, RiceOperationType.SELF_SCORE, (long) totalScore, beforeSelfScore, rice
-                        .getSelfScore());
-                return R.success("兑换成功").add("exchangeCount", exchangeCount)
-                        .add("waterDropCount", rice.getWaterDropCount());
-            } else if (exchangeCount == 0) {
-                return R.error("兑换失败,当前积分不足").add("waterDropCount", rice.getWaterDropCount());
+            createRiceOperationRecord(authenticatedUser.getId(), RiceOperationType.SELF_SCORE, (long) totalScore, beforeSelfScore, rice
+                    .getSelfScore());
+            return R.success("兑换成功").add("exchangeCount", exchangeCount)
+                    .add("waterDropCount", rice.getWaterDropCount());
+        } else if (exchangeCount == 0) {
+            return R.error("兑换失败,当前积分不足").add("waterDropCount", rice.getWaterDropCount()).add("exchangeCount", rice.getExchangeCount());
 
 
-            } else {
-                return R.error("兑换失败,当前积分不足").add("exchangeCount", rice.getExchangeCount()).add("waterDropCount", rice.getWaterDropCount());
-            }
+        } else {
+            return R.error("兑换失败,当前积分不足").add("exchangeCount", rice.getExchangeCount()).add("waterDropCount", rice.getWaterDropCount());
         }
         }
-        return R.error("兑换失败,用户不存在");
+
     }
     }
 
 
 
 
@@ -550,7 +534,7 @@ public class RiceService {
                 .getId(), RiceOperationType.WATER_DROP, exchangedWaterDropCount, beforeWaterDropCount, rice
                 .getId(), RiceOperationType.WATER_DROP, exchangedWaterDropCount, beforeWaterDropCount, rice
                 .getWaterDropCount());
                 .getWaterDropCount());
         createRiceOperationRecord(authenticatedUser
         createRiceOperationRecord(authenticatedUser
-                .getId(), RiceOperationType.SELF_ACTIVITY_SCORE, (Long) exchangedWaterDropCount * 2, currentActivityPoints, rice
+                .getId(), RiceOperationType.SELF_ACTIVITY_SCORE, exchangedWaterDropCount * 2, currentActivityPoints, rice
                 .getSelfActivityScore());
                 .getSelfActivityScore());
 
 
         return R.success("兑换成功").add("counts", exchangedWaterDropCount);
         return R.success("兑换成功").add("counts", exchangedWaterDropCount);

+ 20 - 0
src/main/java/com/izouma/nineth/service/RiceWaterTypeForWatreingService.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.RiceWaterTypeForWatreing;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.repo.RiceWaterTypeForWatreingRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class RiceWaterTypeForWatreingService {
+
+    private RiceWaterTypeForWatreingRepo riceWaterTypeForWatreingRepo;
+
+    public Page<RiceWaterTypeForWatreing> all(PageQuery pageQuery) {
+        return riceWaterTypeForWatreingRepo.findAll(JpaUtils.toSpecification(pageQuery, RiceWaterTypeForWatreing.class), JpaUtils.toPageRequest(pageQuery));
+    }
+}

+ 36 - 63
src/main/java/com/izouma/nineth/web/RiceController.java

@@ -28,18 +28,18 @@ import java.util.*;
 @AllArgsConstructor
 @AllArgsConstructor
 @Slf4j
 @Slf4j
 public class RiceController extends BaseController {
 public class RiceController extends BaseController {
-    private RiceService riceService;
-    private RiceRepo riceRepo;
-    private UserDetailService userDetailService;
-    private UserDetailRepo userDetailRepo;
-    private UserService userService;
-    private UserRepo userRepo;
-    private RiceInviteRepo RiceInviteRepo;
-    private RiceInviteService RiceInviteService;
-    private SysConfigService sysConfigService;
-    private SysConfigRepo sysConfigRepo;
-    private static final int MAX_NICKNAME_LENGTH = 14;
-    private static final String UPDATE_SUCCESS_MSG = "修改成功";
+    private              RiceService       riceService;
+    private              RiceRepo          riceRepo;
+    private              UserDetailService userDetailService;
+    private              UserDetailRepo    userDetailRepo;
+    private              UserService       userService;
+    private              UserRepo          userRepo;
+    private              RiceInviteRepo    RiceInviteRepo;
+    private              RiceInviteService RiceInviteService;
+    private              SysConfigService  sysConfigService;
+    private              SysConfigRepo     sysConfigRepo;
+    private static final int               MAX_NICKNAME_LENGTH = 14;
+    private static final String            UPDATE_SUCCESS_MSG  = "修改成功";
 
 
     @PreAuthorize("hasRole('ADMIN')")
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     @PostMapping("/save")
@@ -51,6 +51,7 @@ public class RiceController extends BaseController {
         }
         }
         return riceRepo.save(record);
         return riceRepo.save(record);
     }
     }
+
     @PreAuthorize("hasRole('ADMIN')")
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     @PostMapping("/all")
     public Page<Rice> all(@RequestBody PageQuery pageQuery) {
     public Page<Rice> all(@RequestBody PageQuery pageQuery) {
@@ -86,8 +87,7 @@ public class RiceController extends BaseController {
     //点击水稻游戏后对riceuser进行初始化赋值
     //点击水稻游戏后对riceuser进行初始化赋值
     @GetMapping("/current")
     @GetMapping("/current")
     public R<Rice> getCurrentUser() throws BusinessException {
     public R<Rice> getCurrentUser() throws BusinessException {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        return R.success(riceService.getCurrentRiceUser(authenticatedUser));
+        return R.success(riceService.getCurrentRiceUser(SecurityUtils.getAuthenticatedUser()));
     }
     }
 
 
     //修改用户昵称
     //修改用户昵称
@@ -99,11 +99,7 @@ public class RiceController extends BaseController {
     //等级显示
     //等级显示
     @GetMapping("/showLevel")
     @GetMapping("/showLevel")
     public R<Map<String, Object>> getCurrentLevel() {
     public R<Map<String, Object>> getCurrentLevel() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long authId = authenticatedUser.getId();
-        Optional<Rice> byUserId = riceRepo.findByUserId(authId);
-        if (byUserId.isPresent()) {
-            Rice rice = byUserId.get();
+        Rice rice = riceRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()).orElseThrow(new BusinessException("用户不存在"));
             Map<String, Object> currentLevel = riceService.getCurrentLevel(rice.getEmpiricalValue());
             Map<String, Object> currentLevel = riceService.getCurrentLevel(rice.getEmpiricalValue());
             Long riceLevel = (Long) currentLevel.get("currentLevel");
             Long riceLevel = (Long) currentLevel.get("currentLevel");
             Double levelUpPercentage = (Double) currentLevel.get("levelUpPercentage");
             Double levelUpPercentage = (Double) currentLevel.get("levelUpPercentage");
@@ -113,9 +109,6 @@ public class RiceController extends BaseController {
             responseData.put("riceLevel", currentLevel);
             responseData.put("riceLevel", currentLevel);
             responseData.put("levelUpPercentage", levelUpPercentage);
             responseData.put("levelUpPercentage", levelUpPercentage);
             return R.success(responseData).add("msg", "查询成功");
             return R.success(responseData).add("msg", "查询成功");
-        } else {
-            throw new BusinessException("用户不存在");
-        }
     }
     }
 
 
     //获取用户积分
     //获取用户积分
@@ -127,21 +120,14 @@ public class RiceController extends BaseController {
     //一个获取积分排行榜的接口
     //一个获取积分排行榜的接口
     @GetMapping("/scoreRanking")
     @GetMapping("/scoreRanking")
     public R<List<RiceDTO>> getTop100AndSelf() {
     public R<List<RiceDTO>> getTop100AndSelf() {
-        // 获取当前用户的id,假设这个方法可以获取当前用户的id
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long authId = authenticatedUser.getId();
-        List<RiceDTO> top100 = riceService.getTop100(authId);
-        return R.success(top100);
+        return R.success(riceService.getTop100(SecurityUtils.getAuthenticatedUser().getId()));
     }
     }
 
 
 
 
     //只获取自己的排名
     //只获取自己的排名
     @GetMapping("/riceUserRank")
     @GetMapping("/riceUserRank")
     public R<?> getRiceUserRank() {
     public R<?> getRiceUserRank() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long userId = authenticatedUser.getId();
-
-        return riceService.getRiceUserRank(userId);
+        return riceService.getRiceUserRank(SecurityUtils.getAuthenticatedUser().getId());
     }
     }
 
 
 
 
@@ -155,24 +141,16 @@ public class RiceController extends BaseController {
     //获取今日已浇水次数和还需浇水次数升级的接口
     //获取今日已浇水次数和还需浇水次数升级的接口
     @GetMapping("/watering/count")
     @GetMapping("/watering/count")
     public R<?> getWateringCount() {
     public R<?> getWateringCount() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long userId = authenticatedUser.getId();
-        Long todayWateringCount = riceService.getTodayWateringCount(userId);
-        Optional<Rice> byUserId = riceRepo.findByUserId(userId);
-        if (byUserId.isPresent()) {
-            Rice rice = byUserId.get();
+        Long todayWateringCount = riceService.getTodayWateringCount(SecurityUtils.getAuthenticatedUser().getId());
+        Rice rice = riceRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()).orElseThrow(new BusinessException("没找到记录"));
             Long waterDropNeededForLevelUp = riceService.getWaterDropNeededForLevelUp(rice);
             Long waterDropNeededForLevelUp = riceService.getWaterDropNeededForLevelUp(rice);
             return R.success(Map.of("todayWateringCount", todayWateringCount, "waterDropNeededForLevelUp", waterDropNeededForLevelUp));
             return R.success(Map.of("todayWateringCount", todayWateringCount, "waterDropNeededForLevelUp", waterDropNeededForLevelUp));
-        }
-        return R.error("获取用户信息失败");
     }
     }
 
 
     //签到
     //签到
     @GetMapping("/signin")
     @GetMapping("/signin")
     public R<?> signIn() {
     public R<?> signIn() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        Long authId = authenticatedUser.getId();
-        return riceService.signIn(authId);
+        return riceService.signIn(SecurityUtils.getAuthenticatedUser().getId());
     }
     }
 
 
 
 
@@ -185,19 +163,18 @@ public class RiceController extends BaseController {
     //积分兑换水滴
     //积分兑换水滴
     @GetMapping("/exchangeScoreForWaterDrop")
     @GetMapping("/exchangeScoreForWaterDrop")
     public R<?> exchangeScoreForWaterDrop() {
     public R<?> exchangeScoreForWaterDrop() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        return riceService.exchangeScoreForWaterDrop(authenticatedUser);
+        return riceService.exchangeScoreForWaterDrop(SecurityUtils.getAuthenticatedUser());
     }
     }
 
 
 
 
     //活动积分兑换水滴
     //活动积分兑换水滴
     @GetMapping("/exchangeActivityScoreForWaterDrop")
     @GetMapping("/exchangeActivityScoreForWaterDrop")
     public R<?> exchangeActivityScoreForWaterDrop() {
     public R<?> exchangeActivityScoreForWaterDrop() {
-        User authenticatedUser = SecurityUtils.getAuthenticatedUser();
-        return riceService.exchangeActivityScoreForWaterDrop(authenticatedUser);
+        return riceService.exchangeActivityScoreForWaterDrop(SecurityUtils.getAuthenticatedUser());
     }
     }
 
 
 
 
+    //测试添加用户
     @GetMapping("/newRiceUser")
     @GetMapping("/newRiceUser")
     public R<?> newRiceUser() {
     public R<?> newRiceUser() {
         User authenticatedUser = SecurityUtils.getAuthenticatedUser();
         User authenticatedUser = SecurityUtils.getAuthenticatedUser();
@@ -215,19 +192,18 @@ public class RiceController extends BaseController {
 
 
         UUID uuid = UUID.randomUUID();
         UUID uuid = UUID.randomUUID();
         Rice rice = new Rice();
         Rice rice = new Rice();
-            rice.setUserId(generateUniqueId());
-            rice.setAvatar(avatar);
-            rice.setNickname(nickname);
-            rice.setLevel(0L);
-            rice.setWaterDropCount(0L);
-            rice.setSignCount(0L);
-            rice.setSelfScore(0L);
-            rice.setSelfActivityScore(0L);
-            rice.setEmpiricalValue(0L);
-            riceRepo.save(rice);
-            return R.success("添加成功");
-        }
-
+        rice.setUserId(generateUniqueId());
+        rice.setAvatar(avatar);
+        rice.setNickname(nickname);
+        rice.setLevel(0L);
+        rice.setWaterDropCount(0L);
+        rice.setSignCount(0L);
+        rice.setSelfScore(0L);
+        rice.setSelfActivityScore(0L);
+        rice.setEmpiricalValue(0L);
+        riceRepo.save(rice);
+        return R.success("添加成功");
+    }
 
 
 
 
     public static Long generateUniqueId() {
     public static Long generateUniqueId() {
@@ -238,10 +214,7 @@ public class RiceController extends BaseController {
     }
     }
 
 
 
 
-
-
-
-    }
+}
 
 
 
 
 
 

+ 16 - 15
src/main/java/com/izouma/nineth/web/RiceInviteController.java

@@ -110,21 +110,6 @@ public class RiceInviteController extends BaseController {
         }
         }
 
 
 
 
-        // 检查助力者是否已经助力过其他用户
-        Optional<RiceInvite> helperRice = riceInviteRepo.findByHelperIdAndCreateTimeBetween(helperId, getTodayStartTime(), getTodayEndTime());
-        if (helperRice.isPresent()) {
-            Optional<Rice> byUserId = riceRepo.findByUserId(helpeeId);
-            String avatar = null;
-            String nickname = null;
-            if (byUserId.isPresent()) {
-                Rice rice = byUserId.get();
-                avatar = rice.getAvatar();
-                nickname = rice.getNickname();
-
-            }
-            return R.error("您今天已经助力过其他用户,请勿重复助力").add("avatar", avatar).add("nickname", nickname);
-        }
-
         // 检查被助力者是否已经被别人助力
         // 检查被助力者是否已经被别人助力
         Optional<RiceInvite> helpeeRice = riceInviteRepo.findByHelpeeIdAndDelIsFalseAndCreateTimeBetween(helpeeId, getTodayStartTime(), getTodayEndTime());
         Optional<RiceInvite> helpeeRice = riceInviteRepo.findByHelpeeIdAndDelIsFalseAndCreateTimeBetween(helpeeId, getTodayStartTime(), getTodayEndTime());
         if (helpeeRice.isPresent()) {
         if (helpeeRice.isPresent()) {
@@ -152,12 +137,23 @@ public class RiceInviteController extends BaseController {
             Rice rice = byUserId.get();
             Rice rice = byUserId.get();
         }
         }
 
 
+        //助力者助力次数加一
+        Rice rice1 = riceRepo.findByUserId(helperId).orElseThrow(new BusinessException("没有找到记录"));
+        rice1.setHelpCount(rice1.getHelpCount() + 1);
+        if(rice1.getHelpCount()==2){
+            Long BeforeWaterDropCount = rice1.getWaterDropCount();
+            rice1.setWaterDropCount(rice1.getWaterDropCount()+1);
+            rice1.setNumberOfHelpOthers(rice1.getNumberOfHelpOthers()+1);
+            createRiceOperationRecord(helpeeId, RiceOperationType.WATER_DROP, 1L,BeforeWaterDropCount , rice1.getWaterDropCount());
+        }
+
         // 增加被助力者的水滴数
         // 增加被助力者的水滴数
         Optional<Rice> rice = riceRepo.findByUserId(helpeeId);
         Optional<Rice> rice = riceRepo.findByUserId(helpeeId);
         if (rice.isPresent()) {
         if (rice.isPresent()) {
             Rice helpee = rice.get();
             Rice helpee = rice.get();
             Long beforeWaterDropCount = helpee.getWaterDropCount();
             Long beforeWaterDropCount = helpee.getWaterDropCount();
             helpee.setWaterDropCount(helpee.getWaterDropCount() + 1);
             helpee.setWaterDropCount(helpee.getWaterDropCount() + 1);
+            helpee.setNumberOfInviteFriends(helpee.getNumberOfInviteFriends()+1);
             riceRepo.save(helpee);
             riceRepo.save(helpee);
             createRiceOperationRecord(helpeeId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, helpee.getWaterDropCount());
             createRiceOperationRecord(helpeeId, RiceOperationType.WATER_DROP, 1L, beforeWaterDropCount, helpee.getWaterDropCount());
         } else {
         } else {
@@ -169,6 +165,11 @@ public class RiceInviteController extends BaseController {
     }
     }
 
 
 
 
+
+
+
+
+
     private void createRiceOperationRecord(Long userId, RiceOperationType type, Long amount, Long beforeAmount, Long afterAmount) {
     private void createRiceOperationRecord(Long userId, RiceOperationType type, Long amount, Long beforeAmount, Long afterAmount) {
         RiceOperationRecord record = new RiceOperationRecord();
         RiceOperationRecord record = new RiceOperationRecord();
         record.setUserId(userId);
         record.setUserId(userId);

+ 60 - 0
src/main/java/com/izouma/nineth/web/RiceWaterTypeForWatreingController.java

@@ -0,0 +1,60 @@
+package com.izouma.nineth.web;
+import com.izouma.nineth.domain.RiceWaterTypeForWatreing;
+import com.izouma.nineth.service.RiceWaterTypeForWatreingService;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.RiceWaterTypeForWatreingRepo;
+import com.izouma.nineth.utils.ObjUtils;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/riceWaterTypeForWatreing")
+@AllArgsConstructor
+public class RiceWaterTypeForWatreingController extends BaseController {
+    private RiceWaterTypeForWatreingService riceWaterTypeForWatreingService;
+    private RiceWaterTypeForWatreingRepo riceWaterTypeForWatreingRepo;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/save")
+    public RiceWaterTypeForWatreing save(@RequestBody RiceWaterTypeForWatreing record) {
+        if (record.getId() != null) {
+            RiceWaterTypeForWatreing orig = riceWaterTypeForWatreingRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
+            ObjUtils.merge(orig, record);
+            return riceWaterTypeForWatreingRepo.save(orig);
+        }
+        return riceWaterTypeForWatreingRepo.save(record);
+    }
+
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<RiceWaterTypeForWatreing> all(@RequestBody PageQuery pageQuery) {
+        return riceWaterTypeForWatreingService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public RiceWaterTypeForWatreing get(@PathVariable Long id) {
+        return riceWaterTypeForWatreingRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @PostMapping("/del/{id}")
+    public void del(@PathVariable Long id) {
+        riceWaterTypeForWatreingRepo.softDelete(id);
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<RiceWaterTypeForWatreing> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+}
+

+ 17 - 1
src/main/vue/src/router.js

@@ -1989,6 +1989,22 @@ const router = new Router({
                     meta: {
                     meta: {
                        title: '元域名叫价',
                        title: '元域名叫价',
                     },
                     },
+               },
+                {
+                    path: '/riceWaterTypeForWatreingEdit',
+                    name: 'RiceWaterTypeForWatreingEdit',
+                    component: () => import(/* webpackChunkName: "riceWaterTypeForWatreingEdit" */ '@/views/RiceWaterTypeForWatreingEdit.vue'),
+                    meta: {
+                       title: '水稻水滴类型浇水气泡编辑',
+                    },
+                },
+                {
+                    path: '/riceWaterTypeForWatreingList',
+                    name: 'RiceWaterTypeForWatreingList',
+                    component: () => import(/* webpackChunkName: "riceWaterTypeForWatreingList" */ '@/views/RiceWaterTypeForWatreingList.vue'),
+                    meta: {
+                       title: '水稻水滴类型浇水气泡',
+                    },
                }
                }
                 /**INSERT_LOCATION**/
                 /**INSERT_LOCATION**/
             ]
             ]
@@ -2049,4 +2065,4 @@ router.beforeEach((to, from, next) => {
     }
     }
 });
 });
 
 
-export default router;
+export default router;

+ 114 - 0
src/main/vue/src/views/RiceWaterTypeForWatreingEdit.vue

@@ -0,0 +1,114 @@
+<template>
+    <div class="edit-view">
+        <page-title>
+            <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
+            <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
+                删除
+            </el-button>
+            <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+        </page-title>
+        <div class="edit-view__content-wrapper">
+            <div class="edit-view__content-section">
+                <el-form :model="formData" :rules="rules" ref="form" label-width="232px" label-position="right"
+                         size="small"
+                         style="max-width: 500px;">
+                        <el-form-item prop="userId" label="用户ID">
+                                    <el-input-number type="number" v-model="formData.userId"></el-input-number>
+                        </el-form-item>
+                        <el-form-item prop="type" label="类型:水滴,活动积分,积分,经验值">
+                                    <el-select v-model="formData.type" clearable filterable placeholder="请选择">
+                                        <el-option
+                                                v-for="item in typeOptions"
+                                                :key="item.value"
+                                                :label="item.label"
+                                                :value="item.value">
+                                        </el-option>
+                                    </el-select>
+                        </el-form-item>
+                        <el-form-item prop="Counts" label="类型数量">
+                                    <el-input-number type="number" v-model="formData.Counts"></el-input-number>
+                        </el-form-item>
+                    <el-form-item class="form-submit">
+                        <el-button @click="onSave" :loading="saving" type="primary">
+                            保存
+                        </el-button>
+                        <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
+                            删除
+                        </el-button>
+                        <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
+                    </el-form-item>
+                </el-form>
+            </div>
+        </div>
+    </div>
+</template>
+<script>
+    export default {
+        name: 'RiceWaterTypeForWatreingEdit',
+        created() {
+            if (this.$route.query.id) {
+                this.$http
+                    .get('riceWaterTypeForWatreing/get/' + this.$route.query.id)
+                    .then(res => {
+                        this.formData = res;
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    });
+            }
+        },
+        data() {
+            return {
+                saving: false,
+                formData: {
+                },
+                rules: {
+                },
+                typeOptions: [{"label":"每日签到","value":"DAILY_CHECK_IN"},{"label":"邀请好友","value":"INVITE_FRIENDS"},{"label":"好友助力","value":"FRIENDS_HELP"},{"label":"积分兑换","value":"REDEEM"},{"label":"活动奖励","value":"ACTIVITY_AWARD"}],
+            }
+        },
+        methods: {
+            onSave() {
+                this.$refs.form.validate((valid) => {
+                    if (valid) {
+                        this.submit();
+                    } else {
+                        return false;
+                    }
+                });
+            },
+            submit() {
+                let data = {...this.formData};
+
+                this.saving = true;
+                this.$http
+                    .post('/riceWaterTypeForWatreing/save', data, {body: 'json'})
+                    .then(res => {
+                        this.saving = false;
+                        this.$message.success('成功');
+                        this.$router.go(-1);
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.saving = false;
+                        this.$message.error(e.error);
+                    });
+            },
+            onDelete() {
+                this.$confirm('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post(`/riceWaterTypeForWatreing/del/${this.formData.id}`)
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.$router.go(-1);
+                }).catch(e => {
+                    if (e !== 'cancel') {
+                        console.log(e);
+                        this.$message.error((e || {}).error || '删除失败');
+                    }
+                })
+            },
+        }
+    }
+</script>
+<style lang="less" scoped></style>

+ 178 - 0
src/main/vue/src/views/RiceWaterTypeForWatreingList.vue

@@ -0,0 +1,178 @@
+<template>
+    <div  class="list-view">
+        <page-title>
+            <el-button @click="addRow" type="primary" icon="el-icon-plus" :disabled="fetchingData || downloading" class="filter-item">
+                新增
+            </el-button>
+            <el-button @click="download" icon="el-icon-upload2" :loading="downloading" :disabled="fetchingData" class="filter-item">
+                导出
+            </el-button>
+        </page-title>
+        <div class="filters-container">
+            <el-input
+                    placeholder="搜索..."
+                    v-model="search"
+                    clearable
+                    class="filter-item search"
+                    @keyup.enter.native="getData"
+            >
+                <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+            </el-input>
+        </div>
+        <el-table :data="tableData" row-key="id" ref="table"
+                  header-row-class-name="table-header-row"
+                  header-cell-class-name="table-header-cell"
+                  row-class-name="table-row" cell-class-name="table-cell"
+                  :height="tableHeight" v-loading="fetchingData">
+            <el-table-column v-if="multipleMode" align="center" type="selection"
+                             width="50">
+            </el-table-column>
+            <el-table-column prop="id" label="ID" width="100">
+            </el-table-column>
+                                <el-table-column prop="userId" label="用户ID"
+>
+                    </el-table-column>
+                    <el-table-column prop="type" label="类型:水滴,活动积分,积分,经验值"
+                            :formatter="typeFormatter"
+                        >
+                    </el-table-column>
+                    <el-table-column prop="Counts" label="类型数量"
+>
+                    </el-table-column>
+            <el-table-column
+                    label="操作"
+                    align="center"
+                    fixed="right"
+                    width="150">
+                <template slot-scope="{row}">
+                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <!-- <div class="multiple-mode-wrapper">
+                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button @click="operation1">批量操作1</el-button>
+                    <el-button @click="operation2">批量操作2</el-button>
+                    <el-button @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div> -->
+            <el-pagination background @size-change="onSizeChange"
+                           @current-change="onCurrentChange" :current-page="page"
+                           :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize"
+                           layout="total, sizes, prev, pager, next, jumper"
+                           :total="totalElements">
+            </el-pagination>
+        </div>
+
+    </div>
+</template>
+<script>
+    import { mapState } from "vuex";
+    import pageableTable from "@/mixins/pageableTable";
+
+    export default {
+        name: 'RiceWaterTypeForWatreingList',
+        mixins: [pageableTable],
+        data() {
+            return {
+                multipleMode: false,
+                search: "",
+                url: "/riceWaterTypeForWatreing/all",
+                downloading: false,
+                        typeOptions:[{"label":"每日签到","value":"DAILY_CHECK_IN"},{"label":"邀请好友","value":"INVITE_FRIENDS"},{"label":"好友助力","value":"FRIENDS_HELP"},{"label":"积分兑换","value":"REDEEM"},{"label":"活动奖励","value":"ACTIVITY_AWARD"}],
+            }
+        },
+        computed: {
+            selection() {
+                return this.$refs.table.selection.map(i => i.id);
+            }
+        },
+        methods: {
+                    typeFormatter(row, column, cellValue, index) {
+                        let selectedOption = this.typeOptions.find(i => i.value === cellValue);
+                        if (selectedOption) {
+                            return selectedOption.label;
+                        }
+                        return '';
+                    },
+            beforeGetData() {
+                return { search: this.search, query: { del: false } };
+            },
+            toggleMultipleMode(multipleMode) {
+                this.multipleMode = multipleMode;
+                if (!multipleMode) {
+                    this.$refs.table.clearSelection();
+                }
+            },
+            addRow() {
+                this.$router.push({
+                    path: "/riceWaterTypeForWatreingEdit",
+                    query: {
+                        ...this.$route.query
+                    }
+                });
+            },
+            editRow(row) {
+                this.$router.push({
+                    path: "/riceWaterTypeForWatreingEdit",
+                    query: {
+                    id: row.id
+                    }
+                });
+            },
+            download() {
+                this.downloading = true;
+                this.$axios
+                    .get("/riceWaterTypeForWatreing/excel", { 
+                        responseType: "blob",
+                        params: { size: 10000 }
+                    })
+                    .then(res => {
+                        console.log(res);
+                        this.downloading = false;
+                        const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                        const link = document.createElement("a");
+                        link.href = downloadUrl;
+                        link.setAttribute(
+                            "download",
+                            res.headers["content-disposition"].split("filename=")[1]
+                        );
+                        document.body.appendChild(link);
+                        link.click();
+                        link.remove();
+                    })
+                    .catch(e => {
+                        console.log(e);
+                        this.downloading = false;
+                        this.$message.error(e.error);
+                    });
+            },
+            operation1() {
+                this.$notify({
+                    title: '提示',
+                    message: this.selection
+                });
+            },
+            operation2() {
+                this.$message('操作2');
+            },
+            deleteRow(row) {
+                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post(`/riceWaterTypeForWatreing/del/${row.id}`)
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                }).catch(e => {
+                    if (e !== 'cancel') {
+                        this.$message.error(e.error);
+                    }
+                })
+            },
+        }
+    }
+</script>
+<style lang="less" scoped>
+</style>