springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/CommunityConvenientApi.java
@@ -306,8 +306,7 @@ @ApiOperation(value = "新增便民服务商家") @PostMapping("/merchant/add") public R addMerchant(@RequestBody @Validated(AddGroup.class) ConvenientMerchantDTO convenientMerchantDTO) { // convenientMerchantDTO.setCreatedBy(this.getUserId()); convenientMerchantDTO.setCreatedBy(5L); convenientMerchantDTO.setCreatedBy(this.getUserId()); return communityService.addMerchant(convenientMerchantDTO); } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientMerchantDTO.java
@@ -21,7 +21,7 @@ import lombok.Data; /** * @title: AddConvenientMerchantDTO * @title: ConvenientMerchantDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 新增/编辑便民服务商家 * @author: hans springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientProductCategoryDTO.java
New file @@ -0,0 +1,43 @@ package com.panzhihua.common.model.dtos.community.convenient; import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** * @title: ConvenientProductCategoryDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 新增/编辑产品分类 * @author: hans * @date: 2021/09/20 10:32 */ @Data @ApiModel("新增/编辑产品分类") public class ConvenientProductCategoryDTO { @ApiModelProperty("分类ID") @NotNull(groups = {PutGroup.class}, message = "分类id不能为空") private Long id; @ApiModelProperty("分类名称") @NotBlank(groups = {AddGroup.class}, message = "分类名称不能为空") private String name; @ApiModelProperty("备注") private String remark; @ApiModelProperty("权重") @NotNull(groups = {AddGroup.class}, message = "权重不能为空") private Integer weight; @ApiModelProperty(value = "创建人", hidden = true) private Long createdBy; @ApiModelProperty(value = "更新人", hidden = true) private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientProductDTO.java
New file @@ -0,0 +1,55 @@ package com.panzhihua.common.model.dtos.community.convenient; import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; /** * @title: ConvenientProductDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 新增/编辑便民服务商家后台产品 * @author: hans * @date: 2021/09/20 20:32 */ @Data @ApiModel("新增/编辑便民服务商家后台产品") public class ConvenientProductDTO { @ApiModelProperty("产品ID") @NotNull(groups = {PutGroup.class}, message = "产品ID不能为空") private Long id; @ApiModelProperty("产品名称") @NotBlank(groups = {AddGroup.class}, message = "产品名称不能为空") @Length(groups = {AddGroup.class}, max = 20, message = "产品名称最多支持20个字符") private String name; @ApiModelProperty("产品介绍") private String introduction; @ApiModelProperty("所属分类") @NotNull(groups = {AddGroup.class}, message = "所属分类不能为空") private Long categoryId; @ApiModelProperty("产品规格") @NotEmpty(groups = {AddGroup.class}, message = "产品规格不能为空") private List<ConvenientProductSpecificationDTO> productSpecificationDTOList; @ApiModelProperty("上架状态,1.上架 0.下架") @NotNull(groups = {AddGroup.class}, message = "上架状态不能为空") private Integer onShelf; @ApiModelProperty(value = "创建人", hidden = true) private Long createdBy; @ApiModelProperty(value = "更新人", hidden = true) private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientProductSpecificationDTO.java
New file @@ -0,0 +1,48 @@ package com.panzhihua.common.model.dtos.community.convenient; import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.math.BigDecimal; /** * @title: ConvenientProductSpecificationDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 新增/编辑产品规格信息 * @author: hans * @date: 2021/09/20 20:46 */ @Data @ApiModel("新增/编辑产品规格信息") public class ConvenientProductSpecificationDTO { @ApiModelProperty("规格ID") @NotNull(message = "规格ID不能为空", groups = {PutGroup.class}) private Long id; @ApiModelProperty("规格名称") @NotBlank(message = "规格名称不能为空", groups = {AddGroup.class}) @Max(6) private String name; @ApiModelProperty("价格") @NotNull(message = "价格不能为空", groups = {AddGroup.class}) @Min(0) private BigDecimal price; @ApiModelProperty("产品图片") private String image; @ApiModelProperty(value = "创建人", hidden = true) private Long createdBy; @ApiModelProperty(value = "更新人", hidden = true) private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/DeleteConvenientProductDTO.java
New file @@ -0,0 +1,27 @@ package com.panzhihua.common.model.dtos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotEmpty; import java.util.List; /** * @title: DeleteConvenientProductDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 删除便民服务商家后台产品请求参数 * @author: hans * @date: 2021/09/21 16:25 */ @Data @ApiModel("删除便民服务商家后台产品请求参数") public class DeleteConvenientProductDTO { @ApiModelProperty(value = "需要删除的产品id集合", required = true) @NotEmpty(message = "产品id不能为空") private List<Long> ids; @ApiModelProperty(value = "处理人", hidden = true) private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/OnShelfOrOffShelfProductDTO.java
New file @@ -0,0 +1,32 @@ package com.panzhihua.common.model.dtos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; /** * @title: OnShelfOrOffShelfProductDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 上架/下架便民服务商家后台产品请求参数 * @author: hans * @date: 2021/09/21 16:42 */ @Data @ApiModel("上架/下架便民服务商家后台产品请求参数") public class OnShelfOrOffShelfProductDTO { @ApiModelProperty(value = "处理类型(1.上架 2.下架)", required = true, allowableValues = "1,2") @NotNull(message = "处理类型不能为空") private Integer type; @ApiModelProperty(value = "需要上架/下架的产品id集合", required = true) @NotEmpty(message = "需要上架/下架的产品id不能为空") private List<Long> ids; @ApiModelProperty(value = "处理人", hidden = true) private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientMerchantDTO.java
@@ -21,7 +21,7 @@ @ApiModelProperty("商家名称") private String name; @ApiModelProperty("商家名称") @ApiModelProperty("商家地址") private String address; @ApiModelProperty("咨询电话") springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientProductCategoryDTO.java
New file @@ -0,0 +1,26 @@ package com.panzhihua.common.model.dtos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: PageConvenientProductCategoryDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页查询产品分类请求参数 * @author: hans * @date: 2021/09/20 15:23 */ @Data @ApiModel("分页查询产品分类请求参数") public class PageConvenientProductCategoryDTO { @ApiModelProperty("分类名称") private String name; @ApiModelProperty(value = "分页-当前页数", example = "1") private Long pageNum; @ApiModelProperty(value = "分页-每页记录数", example = "10") private Long pageSize; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientProductDTO.java
New file @@ -0,0 +1,39 @@ package com.panzhihua.common.model.dtos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; /** * @title: PageConvenientProductDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页查询便民服务商家后台产品信息请求参数 * @author: hans * @date: 2021/09/21 16:12 */ @Data @ApiModel("分页查询便民服务商家后台产品信息请求参数") public class PageConvenientProductDTO { @ApiModelProperty("产品名称") private String name; @ApiModelProperty("产品分类id") private Long categoryId; @ApiModelProperty("上架状态(1.已上架 0.已下架)") private Integer onShelf; @ApiModelProperty(value = "分页-当前页数", example = "1") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageNum; @ApiModelProperty(value = "分页-每页记录数", example = "10") @NotNull(message = "分页参数不能为空") @Min(value = 1) private Long pageSize; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductCategoryVO.java
New file @@ -0,0 +1,37 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; /** * @title: ConvenientProductCategoryVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 产品分类信息 * @author: hans * @date: 2021/09/20 11:08 */ @Data @ApiModel("产品分类信息") public class ConvenientProductCategoryVO { @ApiModelProperty("分类ID") private Long id; @ApiModelProperty("分类名称") private String name; @ApiModelProperty("备注") private String remark; @ApiModelProperty("权重") private Integer weight; @ApiModelProperty("创建人") private String createdBy; @ApiModelProperty("创建时间") private Date createdAt; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductSpecificationVO.java
New file @@ -0,0 +1,38 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; /** * @title: ConvenientProductSpecificationVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 产品规格信息 * @author: hans * @date: 2021/09/20 20:43 */ @Data @ApiModel("产品规格信息") public class ConvenientProductSpecificationVO { @ApiModelProperty("规格ID") private Long id; @ApiModelProperty("规格名称") private String name; @ApiModelProperty("价格") private BigDecimal price; @ApiModelProperty("产品图片") private String image; @ApiModelProperty("规格所属产品ID") private Long productId; @ApiModelProperty("创建时间") private Date createdAt; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientProductVO.java
New file @@ -0,0 +1,43 @@ package com.panzhihua.common.model.vos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; /** * @title: ConvenientProductVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家后台产品信息 * @author: hans * @date: 2021/09/20 21:23 */ @Data @ApiModel("便民服务商家后台产品信息") public class ConvenientProductVO { @ApiModelProperty("产品ID") private Long id; @ApiModelProperty("产品名称") private String name; @ApiModelProperty("产品图片") private String image; @ApiModelProperty("产品介绍") private String introduction; @ApiModelProperty("所属分类") private Long categoryId; @ApiModelProperty("所属分类名称") private String categoryName; @ApiModelProperty("产品规格") private List<ConvenientProductSpecificationVO> productSpecificationVOList; @ApiModelProperty("上架状态,1.上架 0.下架") private Integer onShelf; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -4,9 +4,15 @@ import com.panzhihua.common.model.dtos.community.*; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.discuss.ComActDiscussDetailDTO; @@ -5820,4 +5826,93 @@ */ @GetMapping("/convenient/merchantInfo") R<ConvenientMerchantVO> getUserConvenientMerchantInfo(@RequestParam("userId") Long userId); /** * 新增便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ @PostMapping("/convenient/product-category/add") R addProductCategory(@RequestBody ConvenientProductCategoryDTO convenientProductCategoryDTO); /** * 编辑便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ @PutMapping("/convenient/product-category/put") R putProductCategory(@RequestBody ConvenientProductCategoryDTO convenientProductCategoryDTO); /** * 删除便民服务产品分类信息 * @param categoryId * @param operator * @return */ @DeleteMapping("/convenient/product-category/delete") R deleteProductCategory(@RequestParam("categoryId") Long categoryId, @RequestParam("operator") Long operator); /** * 获取便民服务产品分类详情 * @param categoryId * @return */ @GetMapping("/convenient/product-category/get") R getProductCategory(@RequestParam("categoryId") Long categoryId); /** * 分页查询便民服务产品分类信息 * @param pageConvenientProductCategoryDTO * @return */ @PostMapping("/convenient/product-category/page") R pageProductCategory(@RequestBody PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO); /** * 便民服务商家后台新增产品 * @param convenientProductDTO * @return */ @PostMapping("/convenient/product/add") R addProduct(@RequestBody ConvenientProductDTO convenientProductDTO); /** * 便民服务商家后台编辑产品 * @param convenientProductDTO * @return */ @PutMapping("/convenient/product/put") R putProduct(@RequestBody ConvenientProductDTO convenientProductDTO); /** * 便民服务商家后台获取产品详情 * @param productId * @return */ @GetMapping("/convenient/product/get") R getProduct(@RequestParam("productId") Long productId); /** * 便民服务商家后台分页获取产品信息 * @param pageConvenientProductDTO * @return */ @PostMapping("/convenient/product/page") R pageProduct(@RequestBody PageConvenientProductDTO pageConvenientProductDTO); /** * 便民服务商家后台删除产品信息 * @param deleteConvenientProductDTO * @return */ @DeleteMapping("/convenient/product/delete") R deleteProduct(@RequestBody DeleteConvenientProductDTO deleteConvenientProductDTO); /** * 便民服务商家后台上架/下架产品 * @param onShelfOrOffShelfProductDTO * @return */ @PutMapping("/convenient/product/onShelf-or-offShelf") R onShelfOrOffShelfProduct(@RequestBody OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ConvenientApi.java
@@ -1,18 +1,35 @@ package com.panzhihua.service_community.api; import java.util.List; import javax.annotation.Resource; import javax.validation.Valid; import com.panzhihua.common.model.dtos.community.ComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.ComCvtCategoryDTO; import com.panzhihua.common.model.dtos.community.ComCvtServeDTO; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessAppletsDTO; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.PageComCvtCategoryDTO; import com.panzhihua.common.model.dtos.community.PageComCvtServeDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DisableOrEnableConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientMerchantDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ResetPasswordConvenientMerchantDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.service_community.service.ComCvtBusinessService; import com.panzhihua.service_community.service.ComCvtCategoryService; import com.panzhihua.service_community.service.ComCvtServeService; import com.panzhihua.service_community.service.ConvenientMerchantService; import com.panzhihua.service_community.service.ConvenientProductCategoryService; import com.panzhihua.service_community.service.ConvenientProductService; import com.panzhihua.service_community.service.ConvenientServiceCategoryService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -22,21 +39,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.panzhihua.common.model.dtos.community.ComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.ComCvtCategoryDTO; import com.panzhihua.common.model.dtos.community.ComCvtServeDTO; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessAppletsDTO; import com.panzhihua.common.model.dtos.community.PageComCvtBusinessDTO; import com.panzhihua.common.model.dtos.community.PageComCvtCategoryDTO; import com.panzhihua.common.model.dtos.community.PageComCvtServeDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientServiceCategoryDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO; import com.panzhihua.service_community.service.ComCvtBusinessService; import com.panzhihua.service_community.service.ComCvtCategoryService; import com.panzhihua.service_community.service.ComCvtServeService; import lombok.extern.slf4j.Slf4j; import javax.annotation.Resource; import javax.validation.Valid; import java.util.List; /** * @description: 便民服务接口 @@ -62,6 +67,12 @@ @Resource private ConvenientMerchantService convenientMerchantService; @Resource private ConvenientProductCategoryService convenientProductCategoryService; @Resource private ConvenientProductService convenientProductService; /** * 社区后台分页查询便民服务商家 @@ -437,4 +448,115 @@ public R<ConvenientMerchantVO> getUserConvenientMerchantInfo(@RequestParam("userId") Long userId) { return convenientMerchantService.getUserConvenientMerchantInfo(userId); } /** * 新增便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ @PostMapping("/product-category/add") public R addProductCategory(@RequestBody ConvenientProductCategoryDTO convenientProductCategoryDTO) { return convenientProductCategoryService.addProductCategory(convenientProductCategoryDTO); } /** * 编辑便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ @PutMapping("/product-category/put") public R putProductCategory(@RequestBody ConvenientProductCategoryDTO convenientProductCategoryDTO) { return convenientProductCategoryService.putProductCategory(convenientProductCategoryDTO); } /** * 删除便民服务产品分类信息 * @param categoryId * @param operator * @return */ @DeleteMapping("/product-category/delete") public R deleteProductCategory(@RequestParam("categoryId") Long categoryId, @RequestParam("operator") Long operator) { return convenientProductCategoryService.deleteProductCategory(categoryId, operator); } /** * 获取便民服务产品分类详情 * @param categoryId * @return */ @GetMapping("/product-category/get") public R getProductCategory(@RequestParam("categoryId") Long categoryId) { return convenientProductCategoryService.getProductCategory(categoryId); } /** * 分页查询便民服务产品分类信息 * @param pageConvenientProductCategoryDTO * @return */ @PostMapping("/product-category/page") public R pageProductCategory(@RequestBody PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO) { return convenientProductCategoryService.pageProductCategory(pageConvenientProductCategoryDTO); } /** * 便民服务商家后台新增产品 * @param convenientProductDTO * @return */ @PostMapping("/product/add") public R addProduct(@RequestBody ConvenientProductDTO convenientProductDTO) { return convenientProductService.addProduct(convenientProductDTO); } /** * 便民服务商家后台编辑产品 * @param convenientProductDTO * @return */ @PutMapping("/product/put") public R putProduct(@RequestBody ConvenientProductDTO convenientProductDTO) { return convenientProductService.putProduct(convenientProductDTO); } /** * 便民服务商家后台获取产品详情 * @param productId * @return */ @GetMapping("/product/get") public R getProduct(@RequestParam("productId") Long productId) { return convenientProductService.getProduct(productId); } /** * 便民服务商家后台分页获取产品信息 * @param pageConvenientProductDTO * @return */ @PostMapping("/product/page") public R pageProduct(@RequestBody PageConvenientProductDTO pageConvenientProductDTO) { return convenientProductService.pageProduct(pageConvenientProductDTO); } /** * 便民服务商家后台删除产品信息 * @param deleteConvenientProductDTO * @return */ @DeleteMapping("/product/delete") public R deleteProduct(@RequestBody DeleteConvenientProductDTO deleteConvenientProductDTO) { return convenientProductService.deleteProduct(deleteConvenientProductDTO); } /** * 便民服务商家后台上架/下架产品 * @param onShelfOrOffShelfProductDTO * @return */ @PutMapping("/product/onShelf-or-offShelf") public R onShelfOrOffShelfProduct(@RequestBody OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO) { return convenientProductService.onShelfOrOffShelfProduct(onShelfOrOffShelfProductDTO); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductCategoryDAO.java
New file @@ -0,0 +1,29 @@ package com.panzhihua.service_community.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; /** * @title: ConvenientProductCategoryDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品分类DAO * @author: hans * @date: 2021/09/20 16:16 */ @Mapper public interface ConvenientProductCategoryDAO extends BaseMapper<ConvenientProductCategoryDO> { /** * 分页查询便民服务产品分类 * @param page 分页参数 * @param pageConvenientProductCategoryDTO * @return 产品分类详情 */ IPage<ConvenientProductCategoryVO> pageProductCategory(@Param("page") Page page, @Param("pageConvenientProductCategoryDTO") PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductDAO.java
New file @@ -0,0 +1,48 @@ package com.panzhihua.service_community.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.service_community.model.dos.ConvenientProductDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @title: ConvenientProductDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家后台产品DAO * @author: hans * @date: 2021/09/21 21:35 */ @Mapper public interface ConvenientProductDAO extends BaseMapper<ConvenientProductDO> { /** * 分页查询产品 * * @param page * @param pageConvenientProductDTO * @return */ IPage<ConvenientProductVO> pageProduct(@Param("page") Page page, @Param("pageConvenientProductDTO") PageConvenientProductDTO pageConvenientProductDTO); /** * 批量删除产品 * @param needDelIds * @return */ int batchDeleteByIds(@Param("needDelIds") List<Long> needDelIds); /** * 批量上架 * @param needDealIds * @param updatedBy * @param saleStatus * @return */ int batchOnShelfOrOffShelfByIds(@Param("needDealIds") List<Long> needDealIds, @Param("updatedBy") Long updatedBy, @Param("saleStatus") boolean saleStatus); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientProductSpecificationDAO.java
New file @@ -0,0 +1,40 @@ package com.panzhihua.service_community.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.panzhihua.service_community.model.dos.ConvenientProductSpecificationDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @title: ConvenientProductSpecificationDAO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品分类DAO * @author: hans * @date: 2021/09/21 21:56 */ @Mapper public interface ConvenientProductSpecificationDAO extends BaseMapper<ConvenientProductSpecificationDO> { /** * 批量插入产品规格 * @param productSpecificationDOList * @return */ int batchInsert(@Param("productSpecificationDOList") List<ConvenientProductSpecificationDO> productSpecificationDOList); /** * 删除传入ID以外的关联 * @param notNeedDelIds * @return */ int deleteLoseRelationSpecifications(@Param("notNeedDelIds") List<Long> notNeedDelIds); /** * 通过产品ID删除相关规格 * @param needDelProductIds * @return */ int batchDeleteByProductIds(@Param("needDelProductIds") List<Long> needDelProductIds); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientServiceCategoryDAO.java
@@ -60,4 +60,11 @@ * @return serviceIds */ List<Long> selectServiceIdsForMerchant(@Param("merchantId") Long merchantId); /** * 查看服务分类是否被引用 * @param categoryId * @return */ int checkCategoryIsUsing(@Param("categoryId") Long categoryId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientProductCategoryDO.java
New file @@ -0,0 +1,61 @@ package com.panzhihua.service_community.model.dos; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; import java.util.Date; /** * @title: ConvenientProductCategoryDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品分类DO * @author: hans * @date: 2021/09/20 16:12 */ @Data @TableName(value = "com_convenient_product_categories") public class ConvenientProductCategoryDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.AUTO) private Long id; /** * 分类名称 */ private String name; /** * 备注 */ private String remark; /** * 权重 */ private Integer weight; /** * 是否删除 */ private Boolean isDel; /** * 创建时间 */ private Date createdAt; /** * 创建人 */ private Long createdBy; /** * 更新时间 */ private Date updatedAt; /** * 更新人 */ private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientProductDO.java
New file @@ -0,0 +1,69 @@ package com.panzhihua.service_community.model.dos; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; import java.util.Date; /** * @title: ConvenientProductDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家DO * @author: hans * @date: 2021/09/16 21:01 */ @Data @TableName(value = "com_convenient_products") public class ConvenientProductDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.AUTO) private Long id; /** * 产品名称 */ private String name; /** * 产品分类id */ private Long categoryId; /** * 是否上架 */ private Boolean onShelf; /** * 产品介绍 */ private String introduction; /** * 是否删除 */ private Boolean isDel; /** * 浏览量 */ private Integer viewNum; /** * 创建时间 */ private Date createdAt; /** * 创建人 */ private Long createdBy; /** * 更新时间 */ private Date updatedAt; /** * 更新人 */ private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientProductSpecificationDO.java
New file @@ -0,0 +1,66 @@ package com.panzhihua.service_community.model.dos; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; /** * @title: ConvenientProductSpecificationDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品分类DO * @author: hans * @date: 2021/09/21 22:08 */ @Data @TableName(value = "com_convenient_product_specifications") public class ConvenientProductSpecificationDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.AUTO) private Long id; /** * 规格名称 */ private String name; /** * 价格 */ private BigDecimal price; /** * 产品规格图片 */ private String image; /** * 所属产品ID */ private Long productId; /** * 是否删除 */ private Boolean isDel; /** * 创建时间 */ private Date createdAt; /** * 创建人 */ private Long createdBy; /** * 更新时间 */ private Date updatedAt; /** * 更新人 */ private Long updatedBy; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientProductCategoryService.java
New file @@ -0,0 +1,53 @@ package com.panzhihua.service_community.service; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; /** * @title: ConvenientProductCategoryService * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品服务类 * @author: hans * @date: 2021/09/20 15:36 */ public interface ConvenientProductCategoryService extends IService<ConvenientProductCategoryDO> { /** * 新增便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ R addProductCategory(ConvenientProductCategoryDTO convenientProductCategoryDTO); /** * 编辑便民服务产品分类信息 * @param convenientProductCategoryDTO * @return */ R putProductCategory(ConvenientProductCategoryDTO convenientProductCategoryDTO); /** * 删除便民服务产品分类信息 * @param categoryId * @param operator * @return */ R deleteProductCategory(Long categoryId, Long operator); /** * 获取便民服务产品分类详情 * @param categoryId * @return */ R getProductCategory(Long categoryId); /** * 分页查询便民服务产品分类信息 * @param pageConvenientProductCategoryDTO * @return */ R pageProductCategory(PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientProductService.java
New file @@ -0,0 +1,61 @@ package com.panzhihua.service_community.service; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.service_community.model.dos.ConvenientProductDO; /** * @title: ConvenientProductService * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家后台产品服务类 * @author: hans * @date: 2021/09/21 21:02 */ public interface ConvenientProductService extends IService<ConvenientProductDO> { /** * 便民服务商家后台新增产品 * @param convenientProductDTO * @return */ R addProduct(ConvenientProductDTO convenientProductDTO); /** * 便民服务商家后台编辑产品 * @param convenientProductDTO * @return */ R putProduct(ConvenientProductDTO convenientProductDTO); /** * 便民服务商家后台获取产品详情 * @param productId * @return */ R getProduct(Long productId); /** * 便民服务商家后台分页获取产品信息 * @param pageConvenientProductDTO * @return */ R pageProduct(PageConvenientProductDTO pageConvenientProductDTO); /** * 便民服务商家后台删除产品信息 * @param deleteConvenientProductDTO * @return */ R deleteProduct(DeleteConvenientProductDTO deleteConvenientProductDTO); /** * 便民服务商家后台上架/下架产品 * @param onShelfOrOffShelfProductDTO * @return */ R onShelfOrOffShelfProduct(OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductCategoryServiceImpl.java
New file @@ -0,0 +1,96 @@ package com.panzhihua.service_community.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO; import com.panzhihua.service_community.dao.ConvenientProductCategoryDAO; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; import com.panzhihua.service_community.service.ConvenientProductCategoryService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.util.Date; import static java.util.Objects.isNull; /** * @title: ConvenientProductCategoryServiceImpl * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务产品分类服务实现类 * @author: hans * @date: 2021/09/20 16:13 */ @Service public class ConvenientProductCategoryServiceImpl extends ServiceImpl<ConvenientProductCategoryDAO, ConvenientProductCategoryDO> implements ConvenientProductCategoryService { @Override public R addProductCategory(ConvenientProductCategoryDTO convenientProductCategoryDTO) { ConvenientProductCategoryDO convenientProductCategoryDO = new ConvenientProductCategoryDO(); BeanUtils.copyProperties(convenientProductCategoryDTO, convenientProductCategoryDO); convenientProductCategoryDO.setCreatedAt(new Date()); int result = this.baseMapper.insert(convenientProductCategoryDO); if (result > 0) { return R.ok(); } return R.fail("添加失败"); } @Override public R putProductCategory(ConvenientProductCategoryDTO convenientProductCategoryDTO) { ConvenientProductCategoryDO convenientProductCategoryDO = this.baseMapper.selectById(convenientProductCategoryDTO.getId()); if (isNull(convenientProductCategoryDO)) { return R.fail("分类id不存在"); } BeanUtils.copyProperties(convenientProductCategoryDTO, convenientProductCategoryDO); int result = this.baseMapper.updateById(convenientProductCategoryDO); if (result > 0) { return R.ok(); } return R.fail("更新失败"); } @Override public R deleteProductCategory(Long categoryId, Long operator) { if (isNull(categoryId)) { return R.fail("分类id不能为空"); } ConvenientProductCategoryDO convenientProductCategoryDO = this.baseMapper.selectById(categoryId); if (isNull(convenientProductCategoryDO)) { return R.fail("分类id不存在"); } convenientProductCategoryDO.setIsDel(true); convenientProductCategoryDO.setUpdatedBy(operator); int result = this.baseMapper.updateById(convenientProductCategoryDO); if (result > 0) { return R.ok(); } return R.fail("删除失败"); } @Override public R getProductCategory(Long categoryId) { if (isNull(categoryId)) { return R.fail("分类id不能为空"); } ConvenientProductCategoryDO convenientProductCategoryDO = this.baseMapper.selectById(categoryId); if (isNull(convenientProductCategoryDO)) { return R.fail("分类id不存在"); } ConvenientProductCategoryVO convenientProductCategoryVO = new ConvenientProductCategoryVO(); BeanUtils.copyProperties(convenientProductCategoryDO, convenientProductCategoryVO); return R.ok(convenientProductCategoryVO); } @Override public R pageProductCategory(PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO) { Page page = new Page<>(); page.setSize(pageConvenientProductCategoryDTO.getPageSize()); page.setCurrent(pageConvenientProductCategoryDTO.getPageNum()); IPage<ConvenientProductCategoryVO> iPage = this.baseMapper.pageProductCategory(page, pageConvenientProductCategoryDTO); return R.ok(iPage); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientProductServiceImpl.java
New file @@ -0,0 +1,191 @@ package com.panzhihua.service_community.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductSpecificationDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductSpecificationVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.service_community.dao.ConvenientProductCategoryDAO; import com.panzhihua.service_community.dao.ConvenientProductDAO; import com.panzhihua.service_community.dao.ConvenientProductSpecificationDAO; import com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO; import com.panzhihua.service_community.model.dos.ConvenientProductDO; import com.panzhihua.service_community.model.dos.ConvenientProductSpecificationDO; import com.panzhihua.service_community.service.ConvenientProductService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; /** * @title: ConvenientProductServiceImpl * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务商家后台产品服务实现类 * @author: hans * @date: 2021/09/21 21:33 */ @Service public class ConvenientProductServiceImpl extends ServiceImpl<ConvenientProductDAO, ConvenientProductDO> implements ConvenientProductService { @Resource private ConvenientProductCategoryDAO convenientProductCategoryDAO; @Resource private ConvenientProductSpecificationDAO convenientProductSpecificationDAO; @Override @Transactional(rollbackFor = Exception.class) public R addProduct(ConvenientProductDTO convenientProductDTO) { ConvenientProductCategoryDO convenientProductCategoryDO = convenientProductCategoryDAO.selectById(convenientProductDTO.getCategoryId()); if (isNull(convenientProductCategoryDO)) { return R.fail("产品分类不存在"); } ConvenientProductDO convenientProductDO = new ConvenientProductDO(); BeanUtils.copyProperties(convenientProductDTO, convenientProductDO); Date nowDate = new Date(); convenientProductDO.setCreatedAt(nowDate); this.baseMapper.insert(convenientProductDO); Long productId = convenientProductDO.getId(); if (nonNull(productId)) { //规格 List<ConvenientProductSpecificationDTO> productSpecificationDTOList = convenientProductDTO.getProductSpecificationDTOList(); List<ConvenientProductSpecificationDO> productSpecificationDOList = productSpecificationDTOList.stream().map(specificationDTO -> { ConvenientProductSpecificationDO convenientProductSpecificationDO = new ConvenientProductSpecificationDO(); BeanUtils.copyProperties(specificationDTO, convenientProductSpecificationDO); convenientProductSpecificationDO.setProductId(productId); convenientProductSpecificationDO.setCreatedAt(nowDate); convenientProductSpecificationDO.setCreatedBy(convenientProductDTO.getCreatedBy()); return convenientProductSpecificationDO; }).collect(Collectors.toList()); convenientProductSpecificationDAO.batchInsert(productSpecificationDOList); } return R.ok(); } @Override @Transactional(rollbackFor = Exception.class) public R putProduct(ConvenientProductDTO convenientProductDTO) { Long productId = convenientProductDTO.getId(); Long updatedBy = convenientProductDTO.getUpdatedBy(); ConvenientProductDO convenientProductDO = this.baseMapper.selectById(productId); if (isNull(convenientProductDO)) { return R.fail("产品不存在"); } BeanUtils.copyProperties(convenientProductDTO, convenientProductDO); convenientProductDO.setUpdatedBy(updatedBy); this.baseMapper.updateById(convenientProductDO); List<ConvenientProductSpecificationDTO> productSpecificationDTOList = convenientProductDTO.getProductSpecificationDTOList(); List<Long> notNeedDelIds = productSpecificationDTOList.stream().filter(specificationDTO -> nonNull(specificationDTO.getId())) .map(ConvenientProductSpecificationDTO::getId).collect(Collectors.toList()); //删除已失去关联的规格 convenientProductSpecificationDAO.deleteLoseRelationSpecifications(notNeedDelIds); Date nowDate = new Date(); productSpecificationDTOList.forEach(specificationDTO -> { Long specificationId = specificationDTO.getId(); if (isNull(specificationId)) { //新增 ConvenientProductSpecificationDO convenientProductSpecificationDO = new ConvenientProductSpecificationDO(); BeanUtils.copyProperties(specificationDTO, convenientProductSpecificationDO); convenientProductSpecificationDO.setProductId(productId); convenientProductSpecificationDO.setCreatedAt(nowDate); convenientProductSpecificationDO.setCreatedBy(updatedBy); convenientProductSpecificationDAO.insert(convenientProductSpecificationDO); } else { //更新 ConvenientProductSpecificationDO convenientProductSpecificationDO = convenientProductSpecificationDAO.selectById(specificationId); BeanUtils.copyProperties(specificationDTO, convenientProductSpecificationDO); convenientProductSpecificationDO.setUpdatedBy(updatedBy); convenientProductSpecificationDAO.updateById(convenientProductSpecificationDO); } }); return R.ok(); } @Override public R getProduct(Long productId) { if (isNull(productId)) { return R.fail("产品ID不能为空"); } ConvenientProductDO convenientProductDO = this.baseMapper.selectById(productId); if (isNull(convenientProductDO)) { return R.fail("产品不存在"); } ConvenientProductVO convenientProductVO = new ConvenientProductVO(); BeanUtils.copyProperties(convenientProductDO, convenientProductVO); //查找产品规格 List<ConvenientProductSpecificationDO> convenientProductSpecificationDOList = convenientProductSpecificationDAO.selectList(new LambdaQueryWrapper<ConvenientProductSpecificationDO>() .eq(ConvenientProductSpecificationDO::getProductId, productId).eq(ConvenientProductSpecificationDO::getIsDel, false)); List<ConvenientProductSpecificationVO> convenientProductSpecificationVOList = new ArrayList<>(); if (!convenientProductSpecificationDOList.isEmpty()) { convenientProductSpecificationDOList.forEach(specificationDO -> { ConvenientProductSpecificationVO convenientProductSpecificationVO = new ConvenientProductSpecificationVO(); BeanUtils.copyProperties(specificationDO, convenientProductSpecificationVO); convenientProductSpecificationVOList.add(convenientProductSpecificationVO); }); } convenientProductVO.setProductSpecificationVOList(convenientProductSpecificationVOList); return R.ok(convenientProductVO); } @Override public R pageProduct(PageConvenientProductDTO pageConvenientProductDTO) { Page page = new Page<>(); page.setSize(pageConvenientProductDTO.getPageSize()); page.setCurrent(pageConvenientProductDTO.getPageNum()); IPage<ConvenientProductVO> productVOIPage = this.baseMapper.pageProduct(page, pageConvenientProductDTO); List<ConvenientProductVO> convenientProductVOList = productVOIPage.getRecords(); //图片填充 if (!convenientProductVOList.isEmpty()) { convenientProductVOList.forEach(product -> { ConvenientProductSpecificationDO specificationDO = convenientProductSpecificationDAO.selectList(new LambdaQueryWrapper<ConvenientProductSpecificationDO>() .eq(ConvenientProductSpecificationDO::getProductId, product.getId())).get(0); product.setImage(specificationDO.getImage()); }); } return R.ok(productVOIPage); } @Override @Transactional(rollbackFor = Exception.class) public R deleteProduct(DeleteConvenientProductDTO deleteConvenientProductDTO) { List<Long> needDelIds = deleteConvenientProductDTO.getIds(); //删除产品 int result = this.baseMapper.batchDeleteByIds(needDelIds); if (result > 0) { //删除规格 convenientProductSpecificationDAO.batchDeleteByProductIds(needDelIds); } return R.ok(); } @Override public R onShelfOrOffShelfProduct(OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO) { Integer type = onShelfOrOffShelfProductDTO.getType(); Long updatedBy = onShelfOrOffShelfProductDTO.getUpdatedBy(); List<Long> needDelIds = onShelfOrOffShelfProductDTO.getIds(); if (type.intValue() == 1) { //上架 this.baseMapper.batchOnShelfOrOffShelfByIds(needDelIds, updatedBy, true); } else if (type.intValue() == 2) { //下架 this.baseMapper.batchOnShelfOrOffShelfByIds(needDelIds, updatedBy, false); } else { return R.fail("处理类型错误"); } return R.ok(); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientServiceCategoryServiceImpl.java
@@ -22,6 +22,8 @@ import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; import com.panzhihua.service_community.service.ConvenientServiceCategoryService; import javax.annotation.Resource; /** * @title: ConvenientServiceCategoryServiceImpl * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 @@ -68,6 +70,10 @@ if (isNull(convenientServiceCategoryDO)) { return R.fail("分类id不存在"); } int count = this.baseMapper.checkCategoryIsUsing(categoryId); if (count > 0) { return R.fail("分类已被引用,无法删除"); } convenientServiceCategoryDO.setIsDel(true); convenientServiceCategoryDO.setUpdatedBy(operator); int result = this.baseMapper.updateById(convenientServiceCategoryDO); springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductCategoryMapper.xml
New file @@ -0,0 +1,32 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.service_community.dao.ConvenientProductCategoryDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientProductCategoryDO"> <id column="id" property="id" /> <id column="name" property="name" /> <id column="remark" property="remark" /> <id column="weight" property="weight" /> <id column="is_del" property="isDel" /> <id column="created_at" property="createdAt" /> <id column="created_by" property="createdBy" /> <id column="updated_at" property="updatedAt" /> <id column="updated_by" property="updatedBy" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id,`name`,remark,weight,is_del,created_at,created_by,updated_at,updated_by </sql> <select id="pageProductCategory" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO"> SELECT <include refid="Base_Column_List"/> FROM com_convenient_product_categories WHERE is_del = 0 <if test="pageConvenientProductCategoryDTO.name != null and pageConvenientProductCategoryDTO.name.trim() != """> AND `name` LIKE concat('%', #{pageConvenientProductCategoryDTO.name}, '%' ) </if> ORDER BY weight DESC </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductMapper.xml
New file @@ -0,0 +1,51 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.service_community.dao.ConvenientProductDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientProductDO"> <id column="id" property="id" /> <id column="name" property="name" /> <id column="category_id" property="categoryId" /> <id column="on_shelf" property="onShelf" /> <id column="introduction" property="introduction" /> <id column="is_del" property="isDel" /> <id column="view_num" property="viewNum" /> <id column="created_at" property="createdAt" /> <id column="created_by" property="createdBy" /> <id column="updated_at" property="updatedAt" /> <id column="updated_by" property="updatedBy" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id,`name`,category_id,on_shelf,introduction,is_del,view_num,created_at,created_by,updated_at,updated_by </sql> <update id="batchDeleteByIds"> UPDATE com_convenient_products SET is_del = 1 WHERE id IN <foreach collection="needDelIds" open="(" separator="," close=")" index="index" item="item"> #{item} </foreach> </update> <update id="batchOnShelfOrOffShelfByIds"> UPDATE com_convenient_products SET on_shelf = #{saleStatus}, updated_by = #{updatedBy} WHERE id IN <foreach collection="needDealIds" open="(" separator="," close=")" index="index" item="item"> #{item} </foreach> </update> <select id="pageProduct" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO"> SELECT ccp.name,ccpc.name AS categoryName,ccp.view_num,ccp.on_shelf FROM com_convenient_products ccp LEFT JOIN com_convenient_product_categories ccpc ON ccp.category_id = ccpc.id WHERE ccp.is_del = 0 <if test="pageConvenientProductDTO.name != null and pageConvenientProductDTO.name != """> AND ccp.name LIKE CONCAT('%', #{pageConvenientProductDTO.name}, '%') </if> <if test="pageConvenientProductDTO.categoryId != null and pageConvenientProductDTO.categoryId != 0"> AND ccp.category_id = #{pageConvenientProductDTO.categoryId} </if> <if test="pageConvenientProductDTO.onShelf != null"> AND ccp.on_shelf = #{pageConvenientProductDTO.onShelf} </if> </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientProductSpecificationMapper.xml
New file @@ -0,0 +1,46 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.panzhihua.service_community.dao.ConvenientProductSpecificationDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientProductSpecificationDO"> <id column="id" property="id" /> <id column="name" property="name" /> <id column="price" property="price" /> <id column="image" property="image" /> <id column="product_id" property="productId" /> <id column="is_del" property="isDel" /> <id column="created_at" property="createdAt" /> <id column="created_by" property="createdBy" /> <id column="updated_at" property="updatedAt" /> <id column="updated_by" property="updatedBy" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id,`name`,price,image,product_id,is_del,created_at,created_by,updated_at,updated_by </sql> <insert id="batchInsert"> INSERT INTO `com_convenient_product_specifications`(name,price,image,product_id,created_at,created_by) VALUES <foreach collection="productSpecificationDOList" item="item" index="index" separator="," > (#{item.name}, #{item.price}, #{item.image}, #{item.productId}, #{item.createdAt}, #{item.createdBy}) </foreach> </insert> <update id="deleteLoseRelationSpecifications" parameterType="java.util.List"> UPDATE com_convenient_product_specifications SET is_del = 1 WHERE id NOT IN <foreach collection="notNeedDelIds" open="(" separator="," close=")" index="index" item="item"> #{item} </foreach> </update> <update id="batchDeleteByProductIds"> UPDATE com_convenient_product_specifications SET is_del = 1 WHERE id IN <foreach collection="needDelProductIds" open="(" separator="," close=")" index="index" item="item"> #{item} </foreach> </update> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientServiceCategoryMapper.xml
@@ -42,4 +42,7 @@ <select id="selectServiceIdsForMerchant" resultType="java.lang.Long"> SELECT service_category_id FROM com_convenient_service_scope WHERE merchant_id = #{merchantId} </select> <select id="checkCategoryIsUsing" resultType="java.lang.Integer"> SELECT COUNT(1) FROM com_convenient_service_scope WHERE service_category_id = #{categoryId} </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/ConvenientApi.java
@@ -1,34 +1,46 @@ package com.panzhihua.shop_backstage.api; import javax.annotation.Resource; import javax.validation.Valid; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONObject; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.interfaces.ShopOperLog; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.DeleteConvenientProductDTO; import com.panzhihua.common.model.dtos.community.convenient.OnShelfOrOffShelfProductDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientProductDTO; import com.panzhihua.common.model.dtos.user.ConvenientResetPasswordDTO; import com.panzhihua.common.model.vos.LoginReturnVO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductCategoryVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientProductVO; import com.panzhihua.common.model.vos.shop.LoginMerchantUserInfoVO; import com.panzhihua.common.model.vos.user.ChangePasswordVO; import com.panzhihua.common.service.auth.TokenService; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.service.user.UserService; import com.panzhihua.common.validated.AddGroup; import com.panzhihua.common.validated.PutGroup; import com.panzhihua.shop_backstage.model.vos.LoginBody; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.validation.Valid; /** * @title: ConvenientApi @@ -114,4 +126,80 @@ return R.fail("获取登陆商家用户信息失败"); } } @ApiOperation(value = "新增产品分类") @PostMapping("/product-category/add") public R addProductCategory(@RequestBody @Validated(AddGroup.class) ConvenientProductCategoryDTO convenientProductCategoryDTO) { convenientProductCategoryDTO.setCreatedBy(this.getUserId()); return communityService.addProductCategory(convenientProductCategoryDTO); } @ApiOperation(value = "编辑产品分类") @PutMapping("/product-category/put") public R putProductCategory(@RequestBody @Validated(PutGroup.class) ConvenientProductCategoryDTO convenientProductCategoryDTO) { convenientProductCategoryDTO.setUpdatedBy(this.getUserId()); return communityService.putProductCategory(convenientProductCategoryDTO); } @ApiOperation(value = "删除产品分类") @DeleteMapping("/product-category/delete") public R deleteProductCategory(@RequestParam("categoryId") @ApiParam(value = "产品分类id", required = true) Long categoryId) { return communityService.deleteProductCategory(categoryId, this.getUserId()); } @ApiOperation(value = "查询产品分类详情", response = ConvenientProductCategoryVO.class) @GetMapping("/product-category/get") public R getProductCategory(@RequestParam("categoryId") @ApiParam(value = "产品分类id", required = true) Long categoryId) { return communityService.getProductCategory(categoryId); } @ApiOperation(value = "分页查询产品分类", response = ConvenientProductCategoryVO.class) @PostMapping("/product-category/page") public R pageProductCategory(@RequestBody PageConvenientProductCategoryDTO pageConvenientProductCategoryDTO) { return communityService.pageProductCategory(pageConvenientProductCategoryDTO); } @ApiOperation(value = "便民服务商家后台新增产品") @PostMapping("/product/add") public R addProduct(@RequestBody @Validated(AddGroup.class) ConvenientProductDTO convenientProductDTO) { convenientProductDTO.setCreatedBy(this.getUserId()); return communityService.addProduct(convenientProductDTO); } @ApiOperation(value = "便民服务商家后台编辑产品") @PutMapping("/product/put") public R putProduct(@RequestBody @Validated(PutGroup.class) ConvenientProductDTO convenientProductDTO) { convenientProductDTO.setUpdatedBy(this.getUserId()); return communityService.putProduct(convenientProductDTO); } @ApiOperation(value = "便民服务商家后台查询产品详情", response = ConvenientProductVO.class) @GetMapping("/product/get") public R getProduct(@RequestParam("productId") Long productId) { return communityService.getProduct(productId); } @ApiOperation(value = "便民服务商家后台分页查询产品", response = ConvenientProductVO.class) @PostMapping("/product/page") public R pageProduct(@RequestBody PageConvenientProductDTO pageConvenientProductDTO) { return communityService.pageProduct(pageConvenientProductDTO); } @ApiOperation(value = "便民服务商家后台删除产品") @DeleteMapping("/product/delete") public R deleteProduct(@RequestBody @Valid DeleteConvenientProductDTO deleteConvenientProductDTO) { deleteConvenientProductDTO.setUpdatedBy(this.getUserId()); return communityService.deleteProduct(deleteConvenientProductDTO); } @ApiOperation(value = "上架/下架产品") @PutMapping("/product/onShelf-or-offShelf") public R onShelfOrOffShelfProduct(@RequestBody @Valid OnShelfOrOffShelfProductDTO onShelfOrOffShelfProductDTO) { onShelfOrOffShelfProductDTO.setUpdatedBy(this.getUserId()); return communityService.onShelfOrOffShelfProduct(onShelfOrOffShelfProductDTO); } }