springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/CommunityConvenientApi.java
@@ -12,6 +12,7 @@ import com.panzhihua.common.model.dtos.community.convenient.*; import com.panzhihua.common.model.vos.community.convenient.ConvenientElevatingPointVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientGoodsCategoryVO; import com.panzhihua.common.utlis.MimeTypeUtils; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Value; @@ -397,4 +398,38 @@ return communityService.deletePoint(pointId, this.getUserId()); } @ApiOperation(value = "新增商品分类") @PostMapping("/goodsCategory/add") public R addGoodsCategory(@RequestBody @Validated(AddGroup.class) ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { convenientGoodsCategoryDTO.setCreatedBy(this.getUserId()); convenientGoodsCategoryDTO.setAreaCode(this.getAreaCode()); return communityService.addGoodsCategory(convenientGoodsCategoryDTO); } @ApiOperation(value = "编辑商品分类") @PutMapping("/goodsCategory/put") public R putGoodsCategory(@RequestBody @Validated(PutGroup.class) ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { convenientGoodsCategoryDTO.setUpdatedBy(this.getUserId()); return communityService.putGoodsCategory(convenientGoodsCategoryDTO); } @ApiOperation(value = "删除商品分类") @DeleteMapping("/goodsCategory/delete") public R deleteGoodsCategory(@RequestParam("categoryId") @ApiParam(value = "商品分类id", required = true) Long categoryId) { return communityService.deleteGoodsCategory(categoryId, this.getUserId()); } @ApiOperation(value = "查询商品分类详情", response = ConvenientGoodsCategoryVO.class) @GetMapping("/goodsCategory/get") public R getGoodsCategory(@RequestParam("categoryId") @ApiParam(value = "商品分类id", required = true) Long categoryId) { return communityService.getGoodsCategory(categoryId); } @ApiOperation(value = "分页查询商品分类", response = ConvenientGoodsCategoryVO.class) @PostMapping("/goodsCategory/page") public R pageGoodsCategory(@RequestBody PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO) { pageConvenientGoodsCategoryDTO.setAreaCode(this.getAreaCode()); return communityService.pageGoodsCategory(pageConvenientGoodsCategoryDTO); } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/ConvenientGoodsCategoryDTO.java
New file @@ -0,0 +1,46 @@ 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: ConvenientGoodsCategoryDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 新增/编辑商品务分类 * @author: yh * @date: 2022-10-21 09:36:09 */ @Data @ApiModel("新增/编辑商品务分类") public class ConvenientGoodsCategoryDTO { @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; private String areaCode; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/convenient/PageConvenientGoodsCategoryDTO.java
New file @@ -0,0 +1,28 @@ package com.panzhihua.common.model.dtos.community.convenient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @title: PageConvenientGoodsCategoryDTO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 分页查询商品分类请求参数 * @author: yh * @date: 2022-10-21 09:36:09 */ @Data @ApiModel("分页查询商品分类请求参数") public class PageConvenientGoodsCategoryDTO { @ApiModelProperty("分类名称") private String name; @ApiModelProperty(value = "分页-当前页数", example = "1") private Long pageNum; @ApiModelProperty(value = "分页-每页记录数", example = "10") private Long pageSize; private String areaCode; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/convenient/ConvenientGoodsCategoryVO.java
New file @@ -0,0 +1,40 @@ package com.panzhihua.common.model.vos.community.convenient; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; /** * @title: ConvenientGoodsCategoryVO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商品分类信息 * @author: yh * @date: 2022-10-21 09:36:09 */ @Data @ApiModel("商品分类信息") public class ConvenientGoodsCategoryVO { @ApiModelProperty("分类ID") @JsonSerialize(using = ToStringSerializer.class) 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/service/community/CommunityService.java
@@ -10512,4 +10512,45 @@ */ @DeleteMapping("/point/delete") R deletePoint(@RequestParam("pointId") Long pointId, @RequestParam("operator") Long operator); /** * 新增商品分类 * @param convenientGoodsCategoryDTO * @return */ @PostMapping("/goodsCategory/add") R addGoodsCategory(@RequestBody ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO); /** * 编辑 * @param convenientGoodsCategoryDTO * @return */ @PutMapping("/goodsCategory/put") R putGoodsCategory(@RequestBody ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO); /** * 删除商品分类 * @param categoryId * @return */ @DeleteMapping("/goodsCategory/delete") R deleteGoodsCategory(@RequestParam("categoryId") Long categoryId, @RequestParam("operator") Long operator); /** * 获取商品分类详情 * @param categoryId * @return */ @GetMapping("/goodsCategory/get") R getGoodsCategory(@RequestParam("categoryId") Long categoryId); /** * 分页查询商品分类 * @param pageConvenientGoodsCategoryDTO * @return */ @PostMapping("/goodsCategory/page") R pageGoodsCategory(@RequestBody PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ConvenientApi.java
@@ -64,6 +64,9 @@ @Resource private ConvenientElevatingPointService convenientElevatingPointService; @Resource private ConvenientGoodsCategoryService convenientGoodsCategoryService; /** * 社区后台分页查询便民服务商家 * @@ -739,5 +742,55 @@ @DeleteMapping("/point/delete") public R deletePoint(@RequestParam("pointId") Long pointId, @RequestParam("operator") Long operator) { return convenientElevatingPointService.deletePoint(pointId,operator); } } /** * 新增商品分类 * @param convenientGoodsCategoryDTO * @return */ @PostMapping("/goodsCategory/add") public R addGoodsCategory(@RequestBody ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { return convenientGoodsCategoryService.addGoodsCategory(convenientGoodsCategoryDTO); } /** * 编辑 * @param convenientGoodsCategoryDTO * @return */ @PutMapping("/goodsCategory/put") public R putGoodsCategory(@RequestBody ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { return convenientGoodsCategoryService.putGoodsCategory(convenientGoodsCategoryDTO); } /** * 删除商品分类 * @param categoryId * @return */ @DeleteMapping("/goodsCategory/delete") public R deleteGoodsCategory(@RequestParam("categoryId") Long categoryId, @RequestParam("operator") Long operator) { return convenientGoodsCategoryService.deleteGoodsCategoryById(categoryId, operator); } /** * 获取商品分类详情 * @param categoryId * @return */ @GetMapping("/goodsCategory/get") public R getGoodsCategory(@RequestParam("categoryId") Long categoryId) { return convenientGoodsCategoryService.getGoodsCategoryById(categoryId); } /** * 分页查询商品分类 * @param pageConvenientGoodsCategoryDTO * @return */ @PostMapping("/goodsCategory/page") public R pageGoodsCategory(@RequestBody PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO) { return convenientGoodsCategoryService.pageGoodsCategory(pageConvenientGoodsCategoryDTO); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ConvenientGoodsCategoryDAO.java
New file @@ -0,0 +1,60 @@ 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.PageConvenientGoodsCategoryDTO; import com.panzhihua.common.model.vos.community.convenient.ConvenientGoodsCategoryVO; import com.panzhihua.service_community.model.dos.ConvenientGoodsCategoryDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @ClassName: ConvenientGoodsCategoryDAO * @Author: yh * @Date: 2022/11/8 13:20 * @Description: 商品分类 */ @Mapper public interface ConvenientGoodsCategoryDAO extends BaseMapper<ConvenientGoodsCategoryDO> { /** * 分页查询便民服务分类 * * @param page 分页参数 * @param pageConvenientGoodsCategoryDTO * @return 服务分类详情 */ IPage<ConvenientGoodsCategoryVO> pageGoodsCategory(@Param("page") Page page, @Param("pageConvenientGoodsCategoryDTO") PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO); /** * 删除商家服务类型关系 * @param goodsId * @return */ int deleteGoodsCategoryRelation(@Param("goodsId") Long goodsId); /** * 获取商家服务范围 * @param goodsId * @return */ String selectCategoryScopeByGoodsId(@Param("goodsId") Long goodsId); /** * 获取商家服务类型 * @param goodsId * @return serviceIds */ List<Long> selectCategoryIdsForGoods(@Param("goodsId") Long goodsId); /** * 查看服务分类是否被引用 * @param categoryId * @return */ int checkCategoryIsUsing(@Param("categoryId") Long categoryId); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ConvenientGoodsCategoryDO.java
New file @@ -0,0 +1,67 @@ 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: ConvenientGoodsCategoryDO * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商品分类DO * @author: yh * @date: 2022-10-21 09:36:09 */ @Data @TableName(value = "com_convenient_goods_categories") public class ConvenientGoodsCategoryDO implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(type = IdType.ASSIGN_ID) private Long id; /** * 分类名称 */ private String name; /** * 分类图标 */ private String icon; /** * 备注 */ private String remark; /** * 权重 */ private Integer weight; /** * 是否删除 */ private Boolean isDel; /** * 创建时间 */ private Date createdAt; /** * 创建人 */ private Long createdBy; /** * 更新时间 */ private Date updatedAt; /** * 更新人 */ private Long updatedBy; private String areaCode; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ConvenientGoodsCategoryService.java
New file @@ -0,0 +1,70 @@ package com.panzhihua.service_community.service; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.dtos.community.convenient.ConvenientGoodsCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientGoodsCategoryDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.service_community.model.dos.ConvenientGoodsCategoryDO; /** * @title: ConvenientGoodsCategoryService * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 便民服务分类服务类 * @author: hans * @date: 2021/09/16 10:31 */ public interface ConvenientGoodsCategoryService extends IService<ConvenientGoodsCategoryDO> { /** * 便民服务新增分类 * * @param convenientGoodsCategoryDTO * @return 新增结果 */ R addGoodsCategory(ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO); /** * 便民服务分类编辑 * * @param convenientGoodsCategoryDTO * @return 修改结果 */ R putGoodsCategory(ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO); /** * 便民服务分类删除 * * @param categoryId 便民服务分类id * @param operator 操作人员 * @return 删除结果 */ R deleteGoodsCategoryById(Long categoryId, Long operator); /** * 获取便民服务分类详情 * * @param categoryId 便民服务分类id * @return 分类详情 */ R getGoodsCategoryById(Long categoryId); /** * 分页查询便民服务分类 * * @param pageConvenientGoodsCategoryDTO * @return 分类详情 */ R pageGoodsCategory(PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO); /** * 获取所有便民服务分类 * * @return */ R getAllGoodsCategories(String areaCode); /** * 获取该社区商家数量大于0的分类 * @param communityId * @return */ } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ConvenientGoodsCategoryServiceImpl.java
New file @@ -0,0 +1,127 @@ package com.panzhihua.service_community.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.ConvenientGoodsCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.ConvenientServiceCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientGoodsCategoryDTO; import com.panzhihua.common.model.dtos.community.convenient.PageConvenientServiceCategoryDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.convenient.ConvenientGoodsCategoryVO; import com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO; import com.panzhihua.service_community.dao.ConvenientGoodsCategoryDAO; import com.panzhihua.service_community.dao.ConvenientServiceCategoryDAO; import com.panzhihua.service_community.model.dos.ConvenientGoodsCategoryDO; import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; import com.panzhihua.service_community.service.ConvenientGoodsCategoryService; import com.panzhihua.service_community.service.ConvenientServiceCategoryService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; import static java.util.Objects.isNull; /** * @title: ConvenientGoodsCategoryServiceImpl * @projectName: 成都呐喊信息技术有限公司-智慧社区项目 * @description: 商品分类服务实现类 * @author: yh * @date: 2022-10-21 09:36:09 */ @Service public class ConvenientGoodsCategoryServiceImpl extends ServiceImpl<ConvenientGoodsCategoryDAO, ConvenientGoodsCategoryDO> implements ConvenientGoodsCategoryService { @Override public R addGoodsCategory(ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { ConvenientGoodsCategoryDO convenientGoodsCategoryDO = new ConvenientGoodsCategoryDO(); BeanUtils.copyProperties(convenientGoodsCategoryDTO, convenientGoodsCategoryDO); convenientGoodsCategoryDO.setCreatedAt(new Date()); int result = this.baseMapper.insert(convenientGoodsCategoryDO); if (result > 0) { return R.ok(); } return R.fail("添加失败"); } @Override public R putGoodsCategory(ConvenientGoodsCategoryDTO convenientGoodsCategoryDTO) { ConvenientGoodsCategoryDO convenientGoodsCategoryDO = this.baseMapper.selectById(convenientGoodsCategoryDTO.getId()); if (isNull(convenientGoodsCategoryDO)) { return R.fail("分类id不存在"); } BeanUtils.copyProperties(convenientGoodsCategoryDTO, convenientGoodsCategoryDO); int result = this.baseMapper.updateById(convenientGoodsCategoryDO); if (result > 0) { return R.ok(); } return R.fail("更新失败"); } @Override public R deleteGoodsCategoryById(Long categoryId, Long operator) { if (isNull(categoryId)) { return R.fail("分类id不能为空"); } ConvenientGoodsCategoryDO convenientGoodsCategoryDO = this.baseMapper.selectById(categoryId); if (isNull(convenientGoodsCategoryDO)) { return R.fail("分类id不存在"); } int count = this.baseMapper.checkCategoryIsUsing(categoryId); if (count > 0) { return R.fail("该分类名称已被引用,无法删除!"); } convenientGoodsCategoryDO.setIsDel(true); convenientGoodsCategoryDO.setUpdatedBy(operator); int result = this.baseMapper.updateById(convenientGoodsCategoryDO); if (result > 0) { return R.ok(); } return R.fail("删除失败"); } @Override public R getGoodsCategoryById(Long goodsId) { if (isNull(goodsId)) { return R.fail("分类id不能为空"); } ConvenientGoodsCategoryDO convenientGoodsCategoryDO = this.baseMapper.selectById(goodsId); if (isNull(convenientGoodsCategoryDO)) { return R.fail("分类id不存在"); } ConvenientGoodsCategoryVO convenientGoodsCategoryVO = new ConvenientGoodsCategoryVO(); BeanUtils.copyProperties(convenientGoodsCategoryDO, convenientGoodsCategoryVO); return R.ok(convenientGoodsCategoryVO); } @Override public R pageGoodsCategory(PageConvenientGoodsCategoryDTO pageConvenientGoodsCategoryDTO) { Page page = new Page<>(); page.setSize(pageConvenientGoodsCategoryDTO.getPageSize()); page.setCurrent(pageConvenientGoodsCategoryDTO.getPageNum()); IPage<ConvenientGoodsCategoryVO> iPage = this.baseMapper.pageGoodsCategory(page, pageConvenientGoodsCategoryDTO); return R.ok(iPage); } @Override public R getAllGoodsCategories(String areaCode) { List<ConvenientGoodsCategoryVO> categoryVOList = new ArrayList<>(); List<ConvenientGoodsCategoryDO> categoryDOS = this.baseMapper.selectList(new QueryWrapper<ConvenientGoodsCategoryDO>() .lambda().eq(ConvenientGoodsCategoryDO::getAreaCode,areaCode).orderByDesc(ConvenientGoodsCategoryDO::getWeight)); if (!ObjectUtils.isEmpty(categoryDOS)) { categoryDOS.forEach(categoryDO -> { ConvenientGoodsCategoryVO categoryVO = new ConvenientGoodsCategoryVO(); BeanUtils.copyProperties(categoryDO, categoryVO); categoryVOList.add(categoryVO); }); } return R.ok(categoryVOList); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ConvenientGoodsCategoryMapper.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.ConvenientGoodsCategoryDAO"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientGoodsCategoryDO"> <id column="id" property="id"/> <id column="name" property="name"/> <id column="icon" property="icon"/> <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`,icon,remark,weight,is_del,created_at,created_by,updated_at,updated_by </sql> <select id="pageGoodsCategory" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientGoodsCategoryVO"> SELECT <include refid="Base_Column_List"/> FROM com_convenient_service_categories WHERE is_del = 0 <if test="pageConvenientGoodsCategoryDTO.name != null and pageConvenientGoodsCategoryDTO.name.trim() != """> AND `name` LIKE concat('%', #{pageConvenientGoodsCategoryDTO.name}, '%' ) </if> <if test="pageConvenientGoodsCategoryDTO.areaCode != null and pageConvenientGoodsCategoryDTO.areaCode.trim() != """> AND area_code = #{pageConvenientGoodsCategoryDTO.areaCode} </if> ORDER BY weight DESC </select> <delete id="deleteGoodsCategoryRelation"> DELETE FROM com_convenient_goods_scope WHERE goods_id = #{goodsId} </delete> <select id="selectCategoryScopeByGoodsId" resultType="java.lang.String"> SELECT GROUP_CONCAT(`goods_category_name`) serviceScope FROM com_convenient_goods_scope WHERE goods_id = #{goodsId} </select> <select id="selectCategoryIdsForGoods" resultType="java.lang.Long"> SELECT goods_category_id FROM com_convenient_goods_scope WHERE goods_id = #{goodsId} </select> <select id="checkCategoryIsUsing" resultType="java.lang.Integer"> SELECT COUNT(1) FROM com_convenient_goods_scope WHERE goods_category_id = #{categoryId} </select> </mapper>