浏览代码

系统优化

woody 1 年之前
父节点
当前提交
7a5d5d35d8

+ 0 - 114
src/main/java/com/chelvc/cloud/maintain/controller/CommentController.java

@@ -1,114 +0,0 @@
-package com.chelvc.cloud.maintain.controller;
-
-import com.chelvc.cloud.vehicle.api.dto.CommentDTO;
-import com.chelvc.cloud.vehicle.api.param.CommentModifyParam;
-import com.chelvc.cloud.vehicle.api.param.CommentPagingParam;
-import com.chelvc.cloud.vehicle.api.service.CommentService;
-import com.chelvc.framework.base.annotation.UnifiedResponseBody;
-import com.chelvc.framework.base.model.Pagination;
-import com.chelvc.framework.base.util.ErrorUtils;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.validation.Valid;
-import javax.validation.constraints.Min;
-
-/**
- * 商家评论业务接口
- *
- * @author liude
- * @date 2023/5/24
- */
-@Validated
-@RestController
-@UnifiedResponseBody
-public class CommentController {
-    @DubboReference
-    private CommentService commentService;
-
-    /**
-     * id查找商家评论信息
-     *
-     * @param id 主键
-     * @return 信息
-     */
-    @GetMapping("/comment/{id}")
-    public CommentDTO getComment(@PathVariable("id") @Min(value = 1, message = "主键不能小于1") Long id) {
-        CommentDTO comment = this.commentService.getComment(id);
-        ErrorUtils.requireResource(comment, "该商家评论不存在");
-        return comment;
-    }
-
-    /**
-     *
-     * 更新商家评论
-     * @param param 更新参数
-     * @param id 主键
-     */
-    @PostMapping("/comment/{id}")
-    public void updateComment(@PathVariable("id") @Min(value = 1, message = "主键不能小于1") Long id,
-                               @RequestBody @Valid CommentModifyParam param) {
-        this.commentService.updateComment(id, param);
-    }
-
-
-    /**
-     * 添加商家评论
-     * @param param 修改参数
-     */
-    @PostMapping("/comment")
-    public void addComment(@RequestBody @Valid CommentModifyParam param) {
-        this.commentService.addComment(param);
-    }
-
-
-    /**
-     * 分页查询 主键
-     *
-     * @param param 分页参数
-     * @return
-     */
-    @GetMapping("/comment/paging")
-    public Pagination<CommentDTO> getCommentPaging(@RequestBody @Valid CommentPagingParam param) {
-        return this.commentService.getCommentPaging(param);
-    }
-
-
-    /**
-     * 浏览量加一
-     *
-     * @param id 主键
-     * @return
-     */
-    @PostMapping("/comment/addViewNumOne")
-    public boolean addViewNumOne(@PathVariable("id") @Min(value = 1, message = "主键不能小于1") Long id) {
-        return this.commentService.addViewNumOne(id);
-    }
-
-    /**
-     * 点赞
-     *
-     * @param id 主键
-     * @return
-     */
-    @PostMapping("/comment/addThumbsUpOne")
-    public boolean addThumbsUpOne(@PathVariable("id") @Min(value = 1, message = "主键不能小于1") Long id) {
-        return this.commentService.addThumbsUpOne(id);
-    }
-
-    /**
-     * 取消点赞
-     *
-     * @param id 主键
-     * @return
-     */
-    @PostMapping("/comment/cancelThumbsUp")
-    public boolean cancelThumbsUp(@PathVariable("id") @Min(value = 1, message = "主键不能小于1") Long id) {
-        return this.commentService.cancelThumbsUp(id);
-    }
-}

+ 0 - 54
src/main/java/com/chelvc/cloud/maintain/controller/CustomerController.java

@@ -1,54 +0,0 @@
-package com.chelvc.cloud.maintain.controller;
-
-import com.chelvc.cloud.maintain.copier.UserCopier;
-import com.chelvc.cloud.maintain.vo.UserVO;
-import com.chelvc.cloud.uc.api.dto.UserDTO;
-import com.chelvc.cloud.uc.api.param.UserModifyParam;
-import com.chelvc.cloud.uc.api.service.UserService;
-import com.chelvc.framework.base.annotation.UnifiedResponseBody;
-import com.chelvc.framework.base.context.SessionContextHolder;
-import com.chelvc.framework.base.util.ErrorUtils;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.validation.Valid;
-
-/**
- * 会员接口
- *
- * @author 七仔
- * @date 2023/5/22
- */
-@Validated
-@RestController
-@UnifiedResponseBody
-public class CustomerController {
-    @DubboReference
-    private UserService userService;
-
-    /**
-     * 获取用户信息
-     *
-     * @return 用户信息
-     */
-    @GetMapping("/customer")
-    public UserVO getCustomer() {
-        UserDTO user = this.userService.getUser(SessionContextHolder.getId());
-        ErrorUtils.requireResource(user, "用户不存在");
-        return UserCopier.INSTANCE.copying(user);
-    }
-
-    /**
-     * 修改用户信息
-     *
-     * @param param 修改参数
-     */
-    @PutMapping("/customer")
-    public void updateCustomer(@RequestBody @Valid UserModifyParam param) {
-        this.userService.updateUser(SessionContextHolder.getId(), param);
-    }
-}

+ 17 - 8
src/main/java/com/chelvc/cloud/maintain/controller/IndexController.java

@@ -11,6 +11,7 @@ import com.chelvc.cloud.vehicle.api.param.NearbyQueryParam;
 import com.chelvc.cloud.vehicle.api.service.MerchantService;
 import com.chelvc.framework.base.annotation.UnifiedResponseBody;
 import com.chelvc.framework.base.context.ApplicationContextHolder;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author Woody
  * @date 2023/5/4
  */
+@Slf4j
 @Validated
 @RestController
 @UnifiedResponseBody
@@ -39,7 +41,7 @@ public class IndexController {
      * @return 距离(米)
      */
     private int getNearbyDistance() {
-        return ApplicationContextHolder.getProperty("platform.nearby.distance", int.class, 20000);
+        return ApplicationContextHolder.getSafeProperty("platform.nearby.distance", int.class, 20000);
     }
 
     /**
@@ -70,13 +72,20 @@ public class IndexController {
         NearbyQueryParam query = NearbyQueryParam.builder().longitude(param.getLongitude())
                 .latitude(param.getLatitude()).distance(this.getNearbyDistance()).build();
         CustomerIndexVO index = CustomerIndexVO.builder().build();
-        index.setConfiguration(this.getConfiguration());
-        index.setRecommendMerchants(
-                MerchantCopier.INSTANCE.copying(this.merchantService.listRecommendMerchants(query, 4))
-        );
-        index.setNearbyMerchants(
-                MerchantCopier.INSTANCE.copying(this.merchantService.listNearbyMerchants(query, 4))
-        );
+
+        // 加载附近商家列表
+        try {
+            index.setNears(MerchantCopier.INSTANCE.copying(this.merchantService.listNearbyMerchants(query, 4)));
+        } catch (Exception e) {
+            log.error("Nearby merchants load failed", e);
+        }
+
+        // 加载推荐商家列表
+        try {
+            index.setRecommends(MerchantCopier.INSTANCE.copying(this.merchantService.listRecommendMerchants(query, 4)));
+        } catch (Exception e) {
+            log.error("Recommend merchants load failed", e);
+        }
         return index;
     }
 }

+ 0 - 62
src/main/java/com/chelvc/cloud/maintain/controller/ScoreController.java

@@ -1,62 +0,0 @@
-package com.chelvc.cloud.maintain.controller;
-
-import com.chelvc.cloud.maintain.copier.ScoreCopier;
-import com.chelvc.cloud.maintain.vo.ScoreVO;
-import com.chelvc.cloud.uc.api.dto.ScoreDTO;
-import com.chelvc.cloud.uc.api.param.ScorePagingParam;
-import com.chelvc.cloud.uc.api.service.ScoreService;
-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.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.validation.Valid;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * 积分接口
- *
- * @author 七仔
- * @date 2023/5/9
- */
-@Validated
-@RestController
-@UnifiedResponseBody
-public class ScoreController {
-    @DubboReference
-    private ScoreService scoreService;
-
-    /**
-     * 查询用户积分记录分页信息
-     *
-     * @param param 查询参数
-     * @return 积分明细分页信息
-     */
-    @GetMapping("/score/paging")
-    public Pagination<ScoreVO> getCustomerScorePaging(@Valid ScorePagingParam param) {
-        Pagination<ScoreDTO> pagination = this.scoreService.getScorePaging(param);
-        List<ScoreDTO> records = pagination.getRecords();
-        if (CollectionUtils.isEmpty(records)) {
-            return Pagination.empty();
-        }
-
-        // 构建积分明细信息
-        List<ScoreVO> scoreDetails = records.stream().map(o -> ScoreCopier.INSTANCE.copying(o))
-                .collect(Collectors.toList());
-        return pagination.convert(scoreDetails);
-    }
-
-    /**
-     * 获取会员总积分
-     *
-     * @return 会员总积分
-     */
-    @GetMapping("/totalScore")
-    public Long getTotalScore() {
-        return this.scoreService.getTotalScore();
-    }
-}

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

@@ -1,15 +1,9 @@
 package com.chelvc.cloud.maintain.controller;
 
-import com.chelvc.cloud.maintain.vo.SignIndexVO;
-import com.chelvc.cloud.uc.api.constant.ScoreOrigin;
-import com.chelvc.cloud.uc.api.dto.SignDTO;
-import com.chelvc.cloud.uc.api.service.ScoreService;
 import com.chelvc.cloud.uc.api.service.SignService;
 import com.chelvc.framework.base.annotation.UnifiedResponseBody;
 import org.apache.dubbo.config.annotation.DubboReference;
-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;
 
@@ -25,8 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
 public class SignController {
     @DubboReference
     private SignService signService;
-    @DubboReference
-    private ScoreService scoreService;
 
     /**
      * 用户签到
@@ -35,22 +27,4 @@ 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;
-    }
 }

+ 0 - 12
src/main/java/com/chelvc/cloud/maintain/copier/MerchantCopier.java

@@ -6,9 +6,7 @@ import java.util.List;
 import com.chelvc.cloud.maintain.vo.MerchantVO;
 import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
 import org.mapstruct.Builder;
-import org.mapstruct.IterableMapping;
 import org.mapstruct.Mapper;
-import org.mapstruct.Named;
 import org.mapstruct.factory.Mappers;
 
 /**
@@ -24,21 +22,11 @@ public interface MerchantCopier {
      */
     MerchantCopier INSTANCE = Mappers.getMapper(MerchantCopier.class);
 
-    /**
-     * 商家信息拷贝
-     *
-     * @param merchant 商家信息
-     * @return 商家信息
-     */
-    @Named("dto2vo")
-    MerchantVO copying(MerchantDTO merchant);
-
     /**
      * 商家信息拷贝
      *
      * @param merchants 商家信息集合
      * @return 商家信息列表
      */
-    @IterableMapping(qualifiedByName = "dto2vo")
     List<MerchantVO> copying(Collection<MerchantDTO> merchants);
 }

+ 0 - 44
src/main/java/com/chelvc/cloud/maintain/copier/ScoreCopier.java

@@ -1,44 +0,0 @@
-package com.chelvc.cloud.maintain.copier;
-
-import com.chelvc.cloud.maintain.vo.ScoreVO;
-import com.chelvc.cloud.uc.api.dto.ScoreDTO;
-import org.mapstruct.Builder;
-import org.mapstruct.IterableMapping;
-import org.mapstruct.Mapper;
-import org.mapstruct.Named;
-import org.mapstruct.factory.Mappers;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * 积分记录对象拷贝接口
- *
- * @author 七仔
- * @Date 2023/4/22
- **/
-@Mapper(builder = @Builder(disableBuilder = true))
-public interface ScoreCopier {
-    /**
-     * 对象拷贝接口实例
-     */
-    ScoreCopier INSTANCE = Mappers.getMapper(ScoreCopier.class);
-
-    /**
-     * 积分记录拷贝
-     *
-     * @param score 积分记录
-     * @return 积分记录
-     */
-    @Named("dto2vo")
-    ScoreVO copying(ScoreDTO score);
-
-    /**
-     * 积分记录拷贝
-     *
-     * @param scores 积分记录集合
-     * @return 积分记录列表
-     */
-    @IterableMapping(qualifiedByName = "dto2vo")
-    List<ScoreVO> copying(Collection<ScoreDTO> scores);
-}

+ 0 - 44
src/main/java/com/chelvc/cloud/maintain/copier/UserCopier.java

@@ -1,44 +0,0 @@
-package com.chelvc.cloud.maintain.copier;
-
-import com.chelvc.cloud.maintain.vo.UserVO;
-import com.chelvc.cloud.uc.api.dto.UserDTO;
-import org.mapstruct.Builder;
-import org.mapstruct.IterableMapping;
-import org.mapstruct.Mapper;
-import org.mapstruct.Named;
-import org.mapstruct.factory.Mappers;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * 用户对象拷贝接口
- *
- * @author 七仔
- * @Date 2023/5/22
- **/
-@Mapper(builder = @Builder(disableBuilder = true))
-public interface UserCopier {
-    /**
-     * 对象拷贝接口实例
-     */
-    UserCopier INSTANCE = Mappers.getMapper(UserCopier.class);
-
-    /**
-     * 用户信息拷贝
-     *
-     * @param user 用户信息
-     * @return 用户信息
-     */
-    @Named("dto2vo")
-    UserVO copying(UserDTO user);
-
-    /**
-     * 用户信息拷贝
-     *
-     * @param users 用户信息集合
-     * @return 用户信息列表
-     */
-    @IterableMapping(qualifiedByName = "dto2vo")
-    List<UserVO> copying(Collection<UserDTO> users);
-}

+ 5 - 5
src/main/java/com/chelvc/cloud/maintain/vo/AdvertisementVO.java

@@ -3,7 +3,7 @@ package com.chelvc.cloud.maintain.vo;
 import java.io.Serializable;
 
 import com.chelvc.cloud.vehicle.api.constant.Adsource;
-import com.chelvc.cloud.vehicle.api.constant.Adtype;
+import com.chelvc.framework.base.model.Media;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -21,9 +21,9 @@ import lombok.experimental.SuperBuilder;
 @AllArgsConstructor
 public class AdvertisementVO implements Serializable {
     /**
-     * 广告类型
+     * 媒体类型
      */
-    private Adtype type;
+    private Media type;
 
     /**
      * 广告来源
@@ -31,9 +31,9 @@ public class AdvertisementVO implements Serializable {
     private Adsource source;
 
     /**
-     * 广告图片
+     * 封面图片
      */
-    private String image;
+    private String cover;
 
     /**
      * 跳转地址

+ 2 - 7
src/main/java/com/chelvc/cloud/maintain/vo/CustomerIndexVO.java

@@ -19,18 +19,13 @@ import lombok.experimental.SuperBuilder;
 @NoArgsConstructor
 @AllArgsConstructor
 public class CustomerIndexVO implements Serializable {
-    /**
-     * 配置信息
-     */
-    private ConfigurationVO configuration;
-
     /**
      * 推荐商家列表
      */
-    private List<MerchantVO> recommendMerchants;
+    private List<MerchantVO> recommends;
 
     /**
      * 附件商家列表
      */
-    private List<MerchantVO> nearbyMerchants;
+    private List<MerchantVO> nears;
 }

+ 0 - 51
src/main/java/com/chelvc/cloud/maintain/vo/ScoreVO.java

@@ -1,51 +0,0 @@
-package com.chelvc.cloud.maintain.vo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.experimental.SuperBuilder;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 积分记录信息
- *
- * @Author 七仔
- * @Date 2023/4/14
- */
-@Data
-@SuperBuilder
-@NoArgsConstructor
-@AllArgsConstructor
-public class ScoreVO implements Serializable {
-    /**
-     * 主键
-     */
-    private Long id;
-
-    /**
-     * 用户ID
-     */
-    private Long userId;
-
-    /**
-     * 积分值
-     */
-    private Integer value;
-
-    /**
-     * 积分来源
-     */
-    private String origin;
-
-    /**
-     * 积分备注
-     */
-    private String remark;
-
-    /**
-     * 创建时间
-     */
-    private Date createTime;
-}

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

@@ -1,30 +0,0 @@
-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;
-}

+ 0 - 67
src/main/java/com/chelvc/cloud/maintain/vo/UserVO.java

@@ -1,67 +0,0 @@
-package com.chelvc.cloud.maintain.vo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.experimental.SuperBuilder;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 用户信息
- *
- * @author 七仔
- * @date 2023/5/22
- */
-@Data
-@SuperBuilder
-@NoArgsConstructor
-@AllArgsConstructor
-public class UserVO implements Serializable {
-    /**
-     * 主键
-     */
-    private Long id;
-
-    /**
-     * 用户昵称
-     */
-    private String nickname;
-
-    /**
-     * 手机号码
-     */
-    private String mobile;
-
-    /**
-     * 用户头像
-     */
-    private String avatar;
-
-    /**
-     * 角色主键列表
-     */
-    private List<Long> roleIds;
-
-    /**
-     * 性别
-     */
-    private String gender;
-
-    /**
-     * 常用地
-     */
-    private String city;
-
-    /**
-     * 个人介绍
-     */
-    private String introduction;
-
-    /**
-     * 生日
-     */
-    private Date birthday;
-}