From 06e6416394e35174f357f1d1febb0e6d7223616e Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 4 Aug 2024 11:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=97=E9=93=BA=E5=85=B3?= =?UTF-8?q?=E8=81=94,=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 1 + .../controller/ShopRelationsController.java | 28 +++++++++++--- .../shoprelations/entity/ShopRelations.java | 19 ++++++---- .../mapper/ShopRelationsMapper.java | 3 +- .../service/ShopRelationsService.java | 2 + .../impl/ShopRelationsServiceImpl.java | 16 +++++++- .../shoprelations/vo/ShopRelationsVo.java | 5 +-- .../resources/mapper/ShopRelationsMapper.xml | 38 +++++++++++++++++++ 8 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index 41083a4f..3e5f8769 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -339,6 +339,7 @@ ignored: - /hiver/app/purchase/getPurchaseListOfSupplier - /hiver/app/purchase/cancelPurchase - /hiver/shopRelations/addShopRelations + - /hiver/shopRelations/getShopRelations # 限流及黑名单不拦截的路径 limitUrls: - /**/*.js diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/controller/ShopRelationsController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/controller/ShopRelationsController.java index d328c414..562694ec 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/controller/ShopRelationsController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/controller/ShopRelationsController.java @@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -44,13 +45,13 @@ public class ShopRelationsController { */ @RequestMapping(value = "/addShopRelations", method = RequestMethod.POST) @ApiOperation("新增店铺关联信息") - public Result addShopRelations(ShopRelations shopRelations) { + public Result addShopRelations(@RequestBody ShopRelations shopRelations) { - if (StringUtils.isEmpty(shopRelations.getRelatedShopId())) { - return ResultUtil.error("关联店铺id不能为空"); + if (StringUtils.isEmpty(shopRelations.getShopOwnerId())) { + return ResultUtil.error("店主id不能为空"); } - if (StringUtils.isEmpty(shopRelations.getAssociatedShopId())) { - return ResultUtil.error("被关联店铺id不能为空"); + if (StringUtils.isEmpty(shopRelations.getShopId())) { + return ResultUtil.error("店铺id不能为空"); } try { shopRelationsService.addShopRelations(shopRelations); @@ -61,6 +62,23 @@ public class ShopRelationsController { } } + // 删除分组 + @RequestMapping(value = "/deleteShopRelations", method = RequestMethod.POST) + @ApiOperation("删除店铺关联信息") + public Result deleteShopRelations(String id) { + + if (StringUtils.isEmpty(id)) { + return ResultUtil.error("id不能为空"); + } + try { + shopRelationsService.deleteShopRelations(id); + return ResultUtil.success("删除店铺关联信息成功"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResultUtil.error("删除店铺关联信息失败"); + } + } + /** * 根据店铺id获取关联的店铺信息 * diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/entity/ShopRelations.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/entity/ShopRelations.java index 9a4da655..7165d531 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/entity/ShopRelations.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/entity/ShopRelations.java @@ -11,19 +11,22 @@ import lombok.Data; @TableName(value = "t_shop_relations", autoResultMap = true) public class ShopRelations extends HiverBaseEntity { - @ApiModelProperty(value = "关联店铺id") - private String associatedShopId; + @ApiModelProperty(value = "创建人姓名") + private String createByName; - @ApiModelProperty(value = "关联店铺名称") - private String associatedShopName; + @ApiModelProperty(value = "分组名称") + private String groupName; - @ApiModelProperty(value = "被关联店铺id") - private String relatedShopId; + @ApiModelProperty(value = "关联店铺id") + private String shopId; - @ApiModelProperty(value = "被关联店铺名称") - private String relatedShopName; + @ApiModelProperty(value = "关联店铺名称") + private String shopName; @ApiModelProperty(value = "店主id") private String shopOwnerId; + @ApiModelProperty(value = "店主id") + private String shopOwnerName; + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java index 0d09d2ff..7d8aa4e1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java @@ -1,12 +1,11 @@ package cc.hiver.mall.shoprelations.mapper; import cc.hiver.mall.shoprelations.entity.ShopRelations; -import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import java.util.List; public interface ShopRelationsMapper extends BaseMapper { - List getShopRelations(@Param("shopId") String shopId); + List getShopRelations(@Param("shopId") String shopId); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/ShopRelationsService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/ShopRelationsService.java index bfe0e0d8..e70a337d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/ShopRelationsService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/ShopRelationsService.java @@ -9,4 +9,6 @@ public interface ShopRelationsService { void addShopRelations(ShopRelations shopRelations); List getShopRelations(String shopId); + + void deleteShopRelations(String id); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/impl/ShopRelationsServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/impl/ShopRelationsServiceImpl.java index b29fbbc9..3cdeb7a8 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/impl/ShopRelationsServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/impl/ShopRelationsServiceImpl.java @@ -7,6 +7,7 @@ import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; @Service @@ -22,6 +23,19 @@ public class ShopRelationsServiceImpl implements ShopRelationsService { @Override public List getShopRelations(String shopId) { - return shopRelationsMapper.getShopRelations(shopId); + List shopRelations = shopRelationsMapper.getShopRelations(shopId); + List shopRelationsVo = new ArrayList<>(); + if(shopRelations != null && !shopRelations.isEmpty()){ + for (ShopRelations shopRelation : shopRelations) { + String groupShopId = shopRelation.getShopId(); + String shopName = shopRelation.getShopName(); + } + } + return shopRelationsVo; + } + + @Override + public void deleteShopRelations(String id) { + shopRelationsMapper.deleteById(id); } } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java index 569d54df..de1a9b70 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java @@ -1,12 +1,11 @@ package cc.hiver.mall.shoprelations.vo; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +@Data public class ShopRelationsVo { - @ApiModelProperty(value = "关联id") - private String id; - @ApiModelProperty(value = "关联店铺名称") private String shopName; diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml new file mode 100644 index 00000000..30a805bd --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + id, create_by,create_by_name, create_time, del_flag, update_by, update_time, + group_name,shop_owner_id, shop_owner_name,shop_id,shop_name + + + insert into t_shop_relations (id, create_by, create_by_name, create_time, del_flag, update_by, update_time, + group_name,shop_owner_id, shop_owner_name,shop_id,shop_name) + values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, + #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, + #{groupName,jdbcType=VARCHAR},#{shopOwnerId,jdbcType=VARCHAR},#{shopOwnerName,jdbcType=VARCHAR}, + #{shopId,jdbcType=VARCHAR},#{shopName,jdbcType=VARCHAR}) + + + \ No newline at end of file