店铺装修接口
This commit is contained in:
parent
b29eb348e5
commit
a6c0143d29
|
|
@ -0,0 +1,51 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.extend.ShopExtendDTO;
|
||||
import com.czg.account.entity.ShopExtend;
|
||||
import com.czg.account.service.ShopExtendService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺拓展配置/装修
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/shopExtend")
|
||||
public class ShopExtendController {
|
||||
@Resource
|
||||
private ShopExtendService shopExtendService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺拓展参数
|
||||
* @param autoKey key名称
|
||||
* @return 参数列表
|
||||
*/
|
||||
@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 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "shopExtend:edit", name = "店铺拓展参数修改")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopExtendDTO shopExtendDTO) {
|
||||
return CzgResult.success(shopExtendService.edit(StpKit.USER.getShopId(), shopExtendDTO));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
package com.czg.account.dto.extend;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopExtendDTO {
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
@NotNull
|
||||
private String autokey;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
@NotEmpty
|
||||
private String value;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_extend")
|
||||
public class ShopExtend implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商户Id
|
||||
*/
|
||||
private Integer shopId;
|
||||
|
||||
/**
|
||||
* img:图片;text:文本;
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 自定义key
|
||||
*/
|
||||
private String autoKey;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private String detail;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.extend.ShopExtendDTO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopExtend;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface ShopExtendService extends IService<ShopExtend> {
|
||||
|
||||
Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopExtend;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface ShopExtendMapper extends BaseMapper<ShopExtend> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.extend.ShopExtendDTO;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopExtend;
|
||||
import com.czg.account.service.ShopExtendService;
|
||||
import com.czg.service.account.mapper.ShopExtendMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExtend> implements ShopExtendService{
|
||||
|
||||
@Override
|
||||
public Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO) {
|
||||
ShopExtend shopExtend = queryChain().eq(ShopExtend::getShopId, shopId).eq(ShopExtend::getAutoKey, shopExtendDTO.getAutokey()).one();
|
||||
if (shopExtend == null) {
|
||||
throw new ApiNotPrintException("key有误");
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(shopExtendDTO, shopExtend);
|
||||
shopExtend.setAutoKey(null);
|
||||
return update(shopExtend, new QueryWrapper().eq(ShopExtend::getShopId, shopId).eq(ShopExtend::getAutoKey, shopExtendDTO.getAutokey()));
|
||||
}
|
||||
}
|
||||
|
|
@ -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.czg.service.account.mapper.ShopExtendMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -28,7 +28,7 @@ public class Main {
|
|||
// String packageName = "product";
|
||||
// String packageName = "order";
|
||||
|
||||
String tableName = "tb_shop_table_code";
|
||||
String tableName = "tb_shop_extend";
|
||||
String author = "zs";
|
||||
//是否生成DTO实体 默认生成
|
||||
boolean isGenerateDto = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue