店铺装修接口修改

This commit is contained in:
张松 2025-02-27 10:11:14 +08:00
parent 36a40f11e5
commit b1ac95722f
4 changed files with 121 additions and 7 deletions

View File

@ -32,11 +32,7 @@ public class ShopExtendController {
@SaAdminCheckPermission(value = "shopExtend:list", name = "店铺拓展参数列表")
@GetMapping
public CzgResult<List<ShopExtend>> list(String autoKey) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopExtend::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(autoKey)) {
queryWrapper.eq(ShopExtend::getAutoKey, autoKey);
}
return CzgResult.success(shopExtendService.list(queryWrapper));
return CzgResult.success(shopExtendService.listInfo(StpKit.USER.getShopId(), autoKey));
}
/**

View File

@ -1,5 +1,6 @@
package com.czg.account.entity;
import cn.hutool.core.util.StrUtil;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@ -39,7 +40,7 @@ public class ShopExtend implements Serializable {
/**
* 商户Id
*/
private Integer shopId;
private Long shopId;
/**
* img:图片text:文本
@ -74,5 +75,45 @@ public class ShopExtend implements Serializable {
private LocalDateTime createTime;
private String detail;
/**
* index_bg店铺首页背景图
* my_bg 我的页面背景图
* member_bg会员卡页面背景图
* shopinfo_bg商品列表顶部背景图
* @param autokey
*/
public void initAutoKey(String autokey,long shopId) {
if (StrUtil.isBlank(name)) {
switch (autokey) {
case "index_bg":
this.name = "首页";
this.detail="建议尺寸: 375*600 ";
this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png";
break;
case "my_bg":
this.name = "个人中心";
this.detail="建议尺寸: 375*200";
this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png";
break;
case "member_bg":
this.name = "会员卡";
this.detail="建议尺寸: 315*152";
this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/member_bg.png";
break;
case "shopinfo_bg":
this.name = "商品列表";
this.detail="建议尺寸: 375*120";
this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png";
break;
case "ticket_logo":
this.name = "小票logo";
this.detail="建议尺寸: 417*139";
this.value = "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20241022/eeee8e85c66947e5bcaebf687381b5d6.png";
break;
}
}
this.type="img";
this.shopId=shopId;
this.autoKey = autokey;
}
}

View File

@ -4,6 +4,8 @@ import com.czg.account.dto.extend.ShopExtendDTO;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopExtend;
import java.util.List;
/**
* 店铺扩展信息 服务层
*
@ -14,4 +16,5 @@ public interface ShopExtendService extends IService<ShopExtend> {
Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO);
List<ShopExtend> listInfo(Long shopId, String autoKey);
}

View File

@ -1,8 +1,10 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.extend.ShopExtendDTO;
import com.czg.exception.ApiNotPrintException;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopExtend;
@ -10,6 +12,9 @@ import com.czg.account.service.ShopExtendService;
import com.czg.service.account.mapper.ShopExtendMapper;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* 店铺扩展信息 服务层实现
*
@ -18,6 +23,11 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExtend> implements ShopExtendService{
private final static Map<String, String> KEY_MAP = Map.of(
"index_bg", "首页",
"my_bg", "我的页面背景图",
"member_bg", ""
);
@Override
public Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO) {
@ -30,4 +40,68 @@ public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExt
shopExtend.setAutoKey(null);
return update(shopExtend, new QueryWrapper().eq(ShopExtend::getShopId, shopId).eq(ShopExtend::getAutoKey, shopExtendDTO.getAutokey()));
}
@Override
public List<ShopExtend> listInfo(Long shopId, String autoKey) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopExtend::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(autoKey)) {
queryWrapper.eq(ShopExtend::getAutoKey, autoKey);
}
List<ShopExtend> shopExtends = list(queryWrapper);
shopExtends = checkAndInitialize(shopExtends, shopId);
return shopExtends;
}
public List<ShopExtend> checkAndInitialize(List<ShopExtend> shopExtendList, long shopId) {
List<ShopExtend> newRecords = new ArrayList<>();
List<String> requiredAutoKeys = Arrays.asList("index_bg", "my_bg", "member_bg", "shopinfo_bg","ticket_logo");
if (shopExtendList.isEmpty()) {
for (String key : requiredAutoKeys) {
ShopExtend newRecord = new ShopExtend();
newRecord.initAutoKey(key, shopId);
newRecords.add(newRecord);
}
saveBatch(newRecords);
return newRecords;
} else {
for (ShopExtend shopExtend : shopExtendList) {
switch (shopExtend.getAutoKey()) {
case "index_bg":
shopExtend.setName("首页");
break;
case "my_bg":
shopExtend.setName("个人中心");
break;
case "member_bg":
shopExtend.setName("会员卡");
break;
case "shopinfo_bg":
shopExtend.setName("商品列表");
break;
case "ticket_logo":
shopExtend.setName("小票logo");
break;
}
}
Set<String> existingAutoKeys = shopExtendList.stream()
.map(ShopExtend::getAutoKey)
.collect(Collectors.toSet());
List<String> missingAutoKeys = requiredAutoKeys.stream()
.filter(key -> !existingAutoKeys.contains(key))
.toList();
for (String key : missingAutoKeys) {
ShopExtend newRecord = new ShopExtend();
newRecord.initAutoKey(key, shopId);
newRecords.add(newRecord);
}
saveBatch(newRecords);
shopExtendList.addAll(newRecords);
return shopExtendList;
}
}
}