5 changed files with 97 additions and 4 deletions
@ -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获取关联的店铺信息
|
|||
} |
|||
|
|||
@ -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; |
|||
|
|||
} |
|||
|
|||
@ -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<ShopRelations> { |
|||
} |
|||
|
|||
@ -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); |
|||
} |
|||
|
|||
@ -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); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue