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 da2c8f3e..7e8fa75f 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 @@ -1,4 +1,51 @@ package cc.hiver.mall.shoprelations.controller; +import cc.hiver.core.common.utils.ResultUtil; +import cc.hiver.core.common.vo.Result; +import cc.hiver.mall.shoprelations.entity.ShopRelations; +import cc.hiver.mall.shoprelations.service.ShopRelationsService; +import io.swagger.annotations.Api; +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.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 店铺关联 + * + * @author 王富康 + * @date 2024/8/3 + */ + +@Slf4j +@RestController +@Api(tags = "店铺关联接口") +@RequestMapping("/hiver/shopRelations/") +@Transactional public class ShopRelationsController { + + @Autowired + private ShopRelationsService shopRelationsService; + + // 新增店铺关联信息 + public Result addShopRelations(ShopRelations shopRelations) { + + if (StringUtils.isEmpty(shopRelations.getRelatedShopId())) { + return ResultUtil.error("关联店铺id不能为空"); + } + if (StringUtils.isEmpty(shopRelations.getAssociatedShopId())) { + return ResultUtil.error("被关联店铺id不能为空"); + } + try { + shopRelationsService.addShopRelations(shopRelations); + 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 f00a1221..9a4da655 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 @@ -1,4 +1,29 @@ package cc.hiver.mall.shoprelations.entity; -public class ShopRelations { +import cc.hiver.core.base.HiverBaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "店铺关联表") +@TableName(value = "t_shop_relations", autoResultMap = true) +public class ShopRelations extends HiverBaseEntity { + + @ApiModelProperty(value = "关联店铺id") + private String associatedShopId; + + @ApiModelProperty(value = "关联店铺名称") + private String associatedShopName; + + @ApiModelProperty(value = "被关联店铺id") + private String relatedShopId; + + @ApiModelProperty(value = "被关联店铺名称") + private String relatedShopName; + + @ApiModelProperty(value = "店主id") + private String shopOwnerId; + } 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 cf99f477..5cf95e46 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,4 +1,7 @@ package cc.hiver.mall.shoprelations.mapper; -public interface ShopRelationsMapper { +import cc.hiver.mall.shoprelations.entity.ShopRelations; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface ShopRelationsMapper extends BaseMapper { } 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 43c35a1b..b5d8ee1b 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 @@ -1,4 +1,7 @@ package cc.hiver.mall.shoprelations.service; -public class ShopRelationsService { +import cc.hiver.mall.shoprelations.entity.ShopRelations; + +public interface ShopRelationsService { + void addShopRelations(ShopRelations shopRelations); } 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 74918df2..b8012f85 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 @@ -1,4 +1,19 @@ package cc.hiver.mall.shoprelations.service.impl; -public class ShopRelationsServiceImpl { +import cc.hiver.mall.shoprelations.entity.ShopRelations; +import cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper; +import cc.hiver.mall.shoprelations.service.ShopRelationsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ShopRelationsServiceImpl implements ShopRelationsService { + + @Autowired + private ShopRelationsMapper shopRelationsMapper; + + @Override + public void addShopRelations(ShopRelations shopRelations) { + shopRelationsMapper.insert(shopRelations); + } }