Browse Source

增加店铺关联,临时提交

cangku
wangfukang 2 years ago
parent
commit
06e6416394
  1. 1
      hiver-admin/src/main/resources/application.yml
  2. 28
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/controller/ShopRelationsController.java
  3. 19
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/entity/ShopRelations.java
  4. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java
  5. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/ShopRelationsService.java
  6. 16
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/service/impl/ShopRelationsServiceImpl.java
  7. 5
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java
  8. 38
      hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml

1
hiver-admin/src/main/resources/application.yml

@ -339,6 +339,7 @@ ignored:
- /hiver/app/purchase/getPurchaseListOfSupplier - /hiver/app/purchase/getPurchaseListOfSupplier
- /hiver/app/purchase/cancelPurchase - /hiver/app/purchase/cancelPurchase
- /hiver/shopRelations/addShopRelations - /hiver/shopRelations/addShopRelations
- /hiver/shopRelations/getShopRelations
# 限流及黑名单不拦截的路径 # 限流及黑名单不拦截的路径
limitUrls: limitUrls:
- /**/*.js - /**/*.js

28
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.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -44,13 +45,13 @@ public class ShopRelationsController {
*/ */
@RequestMapping(value = "/addShopRelations", method = RequestMethod.POST) @RequestMapping(value = "/addShopRelations", method = RequestMethod.POST)
@ApiOperation("新增店铺关联信息") @ApiOperation("新增店铺关联信息")
public Result addShopRelations(ShopRelations shopRelations) { public Result addShopRelations(@RequestBody ShopRelations shopRelations) {
if (StringUtils.isEmpty(shopRelations.getRelatedShopId())) { if (StringUtils.isEmpty(shopRelations.getShopOwnerId())) {
return ResultUtil.error("关联店铺id不能为空"); return ResultUtil.error("店主id不能为空");
} }
if (StringUtils.isEmpty(shopRelations.getAssociatedShopId())) { if (StringUtils.isEmpty(shopRelations.getShopId())) {
return ResultUtil.error("被关联店铺id不能为空"); return ResultUtil.error("店铺id不能为空");
} }
try { try {
shopRelationsService.addShopRelations(shopRelations); 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获取关联的店铺信息 * 根据店铺id获取关联的店铺信息
* *

19
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) @TableName(value = "t_shop_relations", autoResultMap = true)
public class ShopRelations extends HiverBaseEntity { public class ShopRelations extends HiverBaseEntity {
@ApiModelProperty(value = "关联店铺id") @ApiModelProperty(value = "创建人姓名")
private String associatedShopId; private String createByName;
@ApiModelProperty(value = "关联店铺名称") @ApiModelProperty(value = "分组名称")
private String associatedShopName; private String groupName;
@ApiModelProperty(value = "关联店铺id") @ApiModelProperty(value = "关联店铺id")
private String relatedShopId; private String shopId;
@ApiModelProperty(value = "关联店铺名称") @ApiModelProperty(value = "关联店铺名称")
private String relatedShopName; private String shopName;
@ApiModelProperty(value = "店主id") @ApiModelProperty(value = "店主id")
private String shopOwnerId; private String shopOwnerId;
@ApiModelProperty(value = "店主id")
private String shopOwnerName;
} }

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/mapper/ShopRelationsMapper.java

@ -1,12 +1,11 @@
package cc.hiver.mall.shoprelations.mapper; package cc.hiver.mall.shoprelations.mapper;
import cc.hiver.mall.shoprelations.entity.ShopRelations; import cc.hiver.mall.shoprelations.entity.ShopRelations;
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
public interface ShopRelationsMapper extends BaseMapper<ShopRelations> { public interface ShopRelationsMapper extends BaseMapper<ShopRelations> {
List<ShopRelationsVo> getShopRelations(@Param("shopId") String shopId); List<ShopRelations> getShopRelations(@Param("shopId") String shopId);
} }

2
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); void addShopRelations(ShopRelations shopRelations);
List<ShopRelationsVo> getShopRelations(String shopId); List<ShopRelationsVo> getShopRelations(String shopId);
void deleteShopRelations(String id);
} }

16
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
@ -22,6 +23,19 @@ public class ShopRelationsServiceImpl implements ShopRelationsService {
@Override @Override
public List<ShopRelationsVo> getShopRelations(String shopId) { public List<ShopRelationsVo> getShopRelations(String shopId) {
return shopRelationsMapper.getShopRelations(shopId); List<ShopRelations> shopRelations = shopRelationsMapper.getShopRelations(shopId);
List<ShopRelationsVo> 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);
} }
} }

5
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/shoprelations/vo/ShopRelationsVo.java

@ -1,12 +1,11 @@
package cc.hiver.mall.shoprelations.vo; package cc.hiver.mall.shoprelations.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ShopRelationsVo { public class ShopRelationsVo {
@ApiModelProperty(value = "关联id")
private String id;
@ApiModelProperty(value = "关联店铺名称") @ApiModelProperty(value = "关联店铺名称")
private String shopName; private String shopName;

38
hiver-modules/hiver-mall/src/main/resources/mapper/ShopRelationsMapper.xml

@ -0,0 +1,38 @@
<?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="cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.shoprelations.entity.ShopRelations">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="shop_owner_id" jdbcType="VARCHAR" property="shopOwnerId" />
<result column="shop_owner_name" jdbcType="VARCHAR" property="shopOwnerName" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="shop_name" jdbcType="VARCHAR" property="shopName" />
</resultMap>
<sql id="Base_Column_List">
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
</sql>
<insert id="insert" parameterType="cc.hiver.mall.shoprelations.entity.ShopRelations">
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})
</insert>
<select id="getShopRelations" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_shop_relations
where shop_id like concat('%',#{shopId},'%')
</select>
</mapper>
Loading…
Cancel
Save