添加商铺拓展信息
This commit is contained in:
parent
51bf8bab32
commit
b99ab76617
@ -0,0 +1,57 @@
|
||||
package com.cpop.jambox.business.entity;
|
||||
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 果酱校区拓展表 实体类。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Table(value = "cp_j_store_extend", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false)
|
||||
public class StoreExtend extends BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 校区/店铺id
|
||||
*/
|
||||
private String storeId;
|
||||
|
||||
/**
|
||||
* 云校区id
|
||||
*/
|
||||
private String storeCloudId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 是否删除(0否1是)
|
||||
*/
|
||||
@Column(isLogicDelete = true)
|
||||
private Boolean isDelete;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.jambox.business.mapper;
|
||||
|
||||
import com.cpop.jambox.business.entity.StoreExtend;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
/**
|
||||
* 果酱校区拓展表 映射层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
public interface StoreExtendMapper extends BaseMapper<StoreExtend> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.jambox.business.service;
|
||||
|
||||
import com.cpop.jambox.business.entity.StoreExtend;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 果酱校区拓展表 服务层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
public interface StoreExtendService extends IService<StoreExtend> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.cpop.jambox.business.service.impl;
|
||||
|
||||
import com.cpop.jambox.business.entity.StoreExtend;
|
||||
import com.cpop.jambox.business.mapper.StoreExtendMapper;
|
||||
import com.cpop.jambox.business.service.StoreExtendService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 果酱校区拓展表 服务层实现。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@Service("storeExtendService")
|
||||
public class StoreExtendServiceImpl extends ServiceImpl<StoreExtendMapper, StoreExtend> implements StoreExtendService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<?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.cpop.jambox.business.mapper.StoreExtendMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,35 @@
|
||||
package com.cpop.system.business.controller;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
import com.cpop.system.business.service.StoreService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统-店铺/校区表 控制层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "系统-店铺/校区表接口")
|
||||
@RequestMapping("/store")
|
||||
public class StoreController {
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.cpop.system.business.entity;
|
||||
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.cpop.core.base.enums.SourceType;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统-店铺/校区表 实体类。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Table(value = "cp_sys_store", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false)
|
||||
public class Store extends BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 店铺/校区id
|
||||
*/
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 店铺/校区名
|
||||
*/
|
||||
private String storeName;
|
||||
|
||||
/**
|
||||
* 品牌id
|
||||
*/
|
||||
private String brandId;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private SourceType sourceType;
|
||||
|
||||
/**
|
||||
* 逻辑删除(0否1是)
|
||||
*/
|
||||
@Column(isLogicDelete = true)
|
||||
private Boolean isDelete;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.system.business.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
|
||||
/**
|
||||
* 系统-店铺/校区表 映射层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
public interface StoreMapper extends BaseMapper<Store> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.system.business.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
|
||||
/**
|
||||
* 系统-店铺/校区表 服务层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
public interface StoreService extends IService<Store> {
|
||||
|
||||
}
|
||||
@ -1,20 +1,21 @@
|
||||
package com.cpop.system.business.service.impl;
|
||||
|
||||
import com.cpop.common.utils.bean.BeanUtils;
|
||||
import com.cpop.core.base.entity.LoginUser;
|
||||
import com.cpop.core.base.entity.PageDomain;
|
||||
import com.cpop.core.base.enums.SourceType;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.core.utils.SecurityUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.core.utils.sql.SqlUtils;
|
||||
import com.cpop.system.business.bo.BrandPageBo;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
import com.cpop.system.business.service.StoreService;
|
||||
import com.cpop.system.business.vo.BrandPageVo;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.row.Db;
|
||||
import com.mybatisflex.core.row.DbChain;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import com.mybatisflex.core.row.RowKey;
|
||||
import com.mybatisflex.core.row.*;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cpop.system.business.entity.Brand;
|
||||
import com.cpop.system.business.mapper.BrandMapper;
|
||||
@ -23,8 +24,14 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cpop.system.business.entity.table.BrandTableDef.BRAND;
|
||||
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
||||
|
||||
/**
|
||||
* 系统-品牌表 服务层实现。
|
||||
@ -39,12 +46,12 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
|
||||
* @descriptions 导入果酱品牌
|
||||
* @author DB
|
||||
* @date 2023/10/25 15:54
|
||||
* @param brandId 果酱品牌id
|
||||
* @param jamboxBrandId 果酱品牌id
|
||||
* @return: void
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importJamboxBrand(String brandId) {
|
||||
public void importJamboxBrand(String jamboxBrandId) {
|
||||
//获取果酱品牌信息
|
||||
Row brand;
|
||||
try {
|
||||
@ -52,7 +59,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
|
||||
brand = Db.selectOneByQuery(QueryWrapper.create()
|
||||
.select()
|
||||
.from("t_brand_info")
|
||||
.where("id = ?", brandId));
|
||||
.where("id = ?", jamboxBrandId));
|
||||
if (brand == null) {
|
||||
throw new ServiceException("获取果酱品牌失败,请联系相关人员");
|
||||
}
|
||||
@ -77,8 +84,9 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
|
||||
//果酱拓展表信息
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
RowKey brandKey = RowKey.SNOW_FLAKE_ID;
|
||||
DbChain.table("cp_j_brand_extend")
|
||||
.setId(RowKey.SNOW_FLAKE_ID)
|
||||
.setId(brandKey)
|
||||
.set("brand_id", sysBrand.getId())
|
||||
.set("brand_cloud_id", brand.getString("brandId"))
|
||||
.set("background_url", brand.getString("brandBg"))
|
||||
@ -87,6 +95,55 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
|
||||
.set("create_user_id", loginUser.getUserId())
|
||||
.set("update_user_id", loginUser.getUserId())
|
||||
.save();
|
||||
//导入果酱品牌关联校区
|
||||
importJamboxStore(jamboxBrandId,sysBrand.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @descriptions 导入果酱校区id
|
||||
* @author DB
|
||||
* @date 2023/10/26 18:30
|
||||
* @param jamboxBrandId 果酱品牌id
|
||||
* @param brandId 品牌id
|
||||
* @return: void
|
||||
*/
|
||||
private void importJamboxStore(String jamboxBrandId,String brandId) {
|
||||
//获取果酱校区信息
|
||||
List<Row> storeList;
|
||||
try {
|
||||
DataSourceKey.use("jambox");
|
||||
storeList = Db.selectListByQuery(QueryWrapper.create()
|
||||
.select("store_id as storeCloudId","mechanism as storeName","address")
|
||||
.from("t_mechanism_info")
|
||||
.where("brand_id = ?", jamboxBrandId));
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//导入数据
|
||||
if (storeList != null) {
|
||||
List<Store> stores = RowUtil.toEntityList(storeList, Store.class);
|
||||
stores.forEach(item->{
|
||||
item.setBrandId(brandId);
|
||||
item.setSourceType(SourceType.JAMBOX);
|
||||
});
|
||||
SpringUtils.getBean(StoreService.class).saveBatch(stores);
|
||||
//保存拓展表
|
||||
List<Row> storeExtends = new ArrayList<>();
|
||||
//果酱拓展表信息
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
for (int i = 0; i < storeList.size(); i++) {
|
||||
Row row = Row.ofKey(RowKey.SNOW_FLAKE_ID);
|
||||
row.set("store_cloud_id", storeList.get(i).getString("storeCloudId"));
|
||||
row.set("store_id", stores.get(i).getId());
|
||||
row.set("create_time", now);
|
||||
row.set("update_time", now);
|
||||
row.set("create_user_id", loginUser.getUserId());
|
||||
row.set("update_user_id", loginUser.getUserId());
|
||||
storeExtends.add(row);
|
||||
}
|
||||
Db.insertBatch("cp_j_store_extend", storeExtends);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.cpop.system.business.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
import com.cpop.system.business.mapper.StoreMapper;
|
||||
import com.cpop.system.business.service.StoreService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统-店铺/校区表 服务层实现。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@Service("storeService")
|
||||
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {
|
||||
|
||||
}
|
||||
7
Cpop-System/src/main/resources/mapper/StoreMapper.xml
Normal file
7
Cpop-System/src/main/resources/mapper/StoreMapper.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?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.cpop.system.business.mapper.StoreMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user