Commit 56faa65b by Lizh

优化服务的引入方式

parent be6c42f3
...@@ -798,7 +798,7 @@ public class CustomProductInfoServiceImpl implements CustomProductInfoService { ...@@ -798,7 +798,7 @@ public class CustomProductInfoServiceImpl implements CustomProductInfoService {
} }
List<Integer> diyIds = templates.stream().map(ProductTemplateInfoEntity::getDiyId) List<Integer> diyIds = templates.stream().map(ProductTemplateInfoEntity::getDiyId)
.filter(Objects::nonNull).distinct().collect(Collectors.toList()); .filter(Objects::nonNull).distinct().collect(Collectors.toList());
// 3. 查询 db_diy,SQL 层完成状态过滤 + FIND_IN_SET 权限过滤(对齐 TS:766-783) // 3. 查询 db_diy,通过 Domain XML 完成状态过滤 + FIND_IN_SET 权限过滤(对齐 TS:766-783)
final Integer userId = user.getId(); final Integer userId = user.getId();
List<Integer> statusList; List<Integer> statusList;
String userName = user.getName(); String userName = user.getName();
...@@ -807,15 +807,8 @@ public class CustomProductInfoServiceImpl implements CustomProductInfoService { ...@@ -807,15 +807,8 @@ public class CustomProductInfoServiceImpl implements CustomProductInfoService {
} else { } else {
statusList = Collections.singletonList(TemplateStatus.SHELF_CODE); statusList = Collections.singletonList(TemplateStatus.SHELF_CODE);
} }
List<DbDiyEntity> diys = dbDiyDomainService.list(new LambdaQueryWrapper<DbDiyEntity>() // FIND_IN_SET 逻辑已下沉至 DbDiyMapper.xml 的 selectByIdsWithUserPermission
.in(DbDiyEntity::getId, diyIds) List<DbDiyEntity> diys = dbDiyDomainService.selectByIdsWithUserPermission(diyIds, statusList, userId);
.in(DbDiyEntity::getStatus, statusList)
// user_ids 权限:NULL(对所有人开放)OR FIND_IN_SET(userId, user_ids) > 0
.and(w -> w.isNull(DbDiyEntity::getUserIds)
.or().apply("FIND_IN_SET({0}, user_ids) > 0", userId))
// ban_user_ids 排除:NULL(无人被禁止)OR FIND_IN_SET(userId, ban_user_ids) = 0
.and(w -> w.isNull(DbDiyEntity::getBanUserIds)
.or().apply("FIND_IN_SET({0}, ban_user_ids) = 0", userId)));
if (CollectionUtils.isEmpty(diys)) { if (CollectionUtils.isEmpty(diys)) {
return Collections.emptyList(); return Collections.emptyList();
} }
......
...@@ -7,6 +7,7 @@ import com.jomalls.custom.app.utils.BeanMapper; ...@@ -7,6 +7,7 @@ import com.jomalls.custom.app.utils.BeanMapper;
import com.jomalls.custom.app.utils.CustomAsserts; import com.jomalls.custom.app.utils.CustomAsserts;
import com.jomalls.custom.dal.entity.LogCustomProductEntity; import com.jomalls.custom.dal.entity.LogCustomProductEntity;
import com.jomalls.custom.domain.service.LogCustomProductDomainService; import com.jomalls.custom.domain.service.LogCustomProductDomainService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -21,23 +22,20 @@ import java.util.stream.Collectors; ...@@ -21,23 +22,20 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class LogCustomProductServiceImpl implements LogCustomProductService { public class LogCustomProductServiceImpl implements LogCustomProductService {
// 默认查询条数
private static final int DEFAULT_LIMIT = 100;
private final LogCustomProductDomainService logCustomProductDomainService; private final LogCustomProductDomainService logCustomProductDomainService;
public LogCustomProductServiceImpl(LogCustomProductDomainService logCustomProductDomainService) {
this.logCustomProductDomainService = logCustomProductDomainService;
}
@Override @Override
public List<LogCustomProductSnakeVO> getListByProductId(Integer productId) { public List<LogCustomProductSnakeVO> getListByProductId(Integer productId) {
CustomAsserts.nonNull(productId, "商品 ID 不能为空"); CustomAsserts.nonNull(productId, "商品 ID 不能为空");
// 按 product_id 查询日志,按 id 降序,限制 100 条防止数据膨胀 List<LogCustomProductEntity> logs =
List<LogCustomProductEntity> logs = logCustomProductDomainService.list( logCustomProductDomainService.selectByProductIdWithLimit(productId, DEFAULT_LIMIT);
new LambdaQueryWrapper<LogCustomProductEntity>()
.eq(LogCustomProductEntity::getProductId, productId)
.orderByDesc(LogCustomProductEntity::getId)
.last("LIMIT 100"));
return logs.stream() return logs.stream()
.map(e -> BeanMapper.snakeCase().convert(e, LogCustomProductSnakeVO.class)) .map(e -> BeanMapper.snakeCase().convert(e, LogCustomProductSnakeVO.class))
.collect(Collectors.toList()); .collect(Collectors.toList());
......
...@@ -70,8 +70,13 @@ public class BeanMapper { ...@@ -70,8 +70,13 @@ public class BeanMapper {
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
/** 默认(驼峰命名)单例 */
private static final BeanMapper INSTANCE = new BeanMapper();
/** 蛇形命名单例 */
private static final BeanMapper SNAKE_CASE_INSTANCE = new BeanMapper(SNAKE_CASE_MAPPER);
public static BeanMapper mapper() { public static BeanMapper mapper() {
return new BeanMapper(); return INSTANCE;
} }
/** /**
...@@ -83,7 +88,7 @@ public class BeanMapper { ...@@ -83,7 +88,7 @@ public class BeanMapper {
* @return 配置了 SNAKE_CASE 命名策略的 BeanMapper * @return 配置了 SNAKE_CASE 命名策略的 BeanMapper
*/ */
public static BeanMapper snakeCase() { public static BeanMapper snakeCase() {
return new BeanMapper(SNAKE_CASE_MAPPER); return SNAKE_CASE_INSTANCE;
} }
/** /**
......
...@@ -2,6 +2,11 @@ package com.jomalls.custom.enums; ...@@ -2,6 +2,11 @@ package com.jomalls.custom.enums;
import lombok.Getter; import lombok.Getter;
import org.springframework.http.HttpStatus;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @Author: Lizh * @Author: Lizh
...@@ -14,32 +19,32 @@ public enum CodeEnum { ...@@ -14,32 +19,32 @@ public enum CodeEnum {
/** /**
* 请求成功 * 请求成功
*/ */
SUCCESS(200, "OK"), SUCCESS(200, "OK", HttpStatus.OK),
/** /**
* 服务器内部错误 * 服务器内部错误
*/ */
FAIL(500, "Internal Server Error"), FAIL(500, "Internal Server Error", HttpStatus.INTERNAL_SERVER_ERROR),
/** /**
* 资源未找到 * 资源未找到
*/ */
NOT_FOUND(404, "Not Found"), NOT_FOUND(404, "Not Found", HttpStatus.NOT_FOUND),
/** /**
* 未授权访问 * 未授权访问
*/ */
UNAUTHORIZED(401, "Unauthorized"), UNAUTHORIZED(401, "Unauthorized", HttpStatus.UNAUTHORIZED),
/** /**
* 禁止访问 * 禁止访问
*/ */
FORBIDDEN(403, "Forbidden"), FORBIDDEN(403, "Forbidden", HttpStatus.FORBIDDEN),
/** /**
* 错误的请求 * 错误的请求
*/ */
BAD_REQUEST(400, "Bad Request"); BAD_REQUEST(400, "Bad Request", HttpStatus.BAD_REQUEST);
/** /**
* -- GETTER -- * -- GETTER --
...@@ -55,6 +60,13 @@ public enum CodeEnum { ...@@ -55,6 +60,13 @@ public enum CodeEnum {
* @return 状态消息描述 * @return 状态消息描述
*/ */
private final String msg; private final String msg;
/**
* -- GETTER --
* 获取状态消息描述
*
* @return 状态消息描述
*/
private final HttpStatus httpStatus;
/** /**
* 构造方法 * 构造方法
...@@ -62,9 +74,13 @@ public enum CodeEnum { ...@@ -62,9 +74,13 @@ public enum CodeEnum {
* @param code 状态码 * @param code 状态码
* @param msg 状态消息描述 * @param msg 状态消息描述
*/ */
CodeEnum(int code, String msg) { CodeEnum(int code, String msg, HttpStatus httpStatus) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
this.httpStatus = httpStatus;
} }
public static final Map<Integer, HttpStatus> MAP =
Arrays.stream(values()).collect(Collectors.toMap(CodeEnum::getCode, CodeEnum::getHttpStatus));
} }
package com.jomalls.custom.service.impl; package com.jomalls.custom.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -10,8 +11,10 @@ import com.jomalls.custom.page.Pageable; ...@@ -10,8 +11,10 @@ import com.jomalls.custom.page.Pageable;
import com.jomalls.custom.page.QueryCondition; import com.jomalls.custom.page.QueryCondition;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
/** /**
* @Author: Lizh * @Author: Lizh
...@@ -36,7 +39,13 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends Servic ...@@ -36,7 +39,13 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends Servic
*/ */
@Override @Override
public Collection<T> select(QueryCondition queryCondition) { public Collection<T> select(QueryCondition queryCondition) {
return this.list(); Map<String, Object> condition = queryCondition.getCondition();
if (CollectionUtils.isEmpty(condition)) {
return this.list();
}
QueryWrapper<T> wrapper = new QueryWrapper<>();
wrapper.allEq(condition, false);
return this.list(wrapper);
} }
/** /**
...@@ -49,7 +58,13 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends Servic ...@@ -49,7 +58,13 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends Servic
public IPage<T> selectPage(QueryCondition queryCondition) { public IPage<T> selectPage(QueryCondition queryCondition) {
Page<T> page = new Page<>(queryCondition.getCurrent(), queryCondition.getSize()); Page<T> page = new Page<>(queryCondition.getCurrent(), queryCondition.getSize());
page.setSearchCount(queryCondition.isSearchCount()); page.setSearchCount(queryCondition.isSearchCount());
return this.page(page); Map<String, Object> condition = queryCondition.getCondition();
if (CollectionUtils.isEmpty(condition)) {
return this.page(page);
}
QueryWrapper<T> wrapper = new QueryWrapper<>();
wrapper.allEq(condition, false);
return this.page(page, wrapper);
} }
/** /**
......
...@@ -3,6 +3,9 @@ package com.jomalls.custom.dal.mapper; ...@@ -3,6 +3,9 @@ package com.jomalls.custom.dal.mapper;
import com.jomalls.custom.dal.entity.DbDiyEntity; import com.jomalls.custom.dal.entity.DbDiyEntity;
import com.jomalls.custom.mapper.BaseMapper; import com.jomalls.custom.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author Lizh * @author Lizh
...@@ -12,4 +15,16 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,4 +15,16 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface DbDiyMapper extends BaseMapper<DbDiyEntity> { public interface DbDiyMapper extends BaseMapper<DbDiyEntity> {
/**
* 根据 ID 列表和状态查询模板,并按用户 ID 做权限过滤(FIND_IN_SET)
*
* @param ids diy ID 列表
* @param statusList 状态列表
* @param userId 当前用户 ID
* @return 过滤后的模板列表
*/
List<DbDiyEntity> selectByIdsWithUserPermission(@Param("ids") List<Integer> ids,
@Param("statusList") List<Integer> statusList,
@Param("userId") Integer userId);
} }
...@@ -3,6 +3,9 @@ package com.jomalls.custom.dal.mapper; ...@@ -3,6 +3,9 @@ package com.jomalls.custom.dal.mapper;
import com.jomalls.custom.dal.entity.LogCustomProductEntity; import com.jomalls.custom.dal.entity.LogCustomProductEntity;
import com.jomalls.custom.mapper.BaseMapper; import com.jomalls.custom.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author Lizh * @author Lizh
...@@ -12,4 +15,14 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,4 +15,14 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface LogCustomProductMapper extends BaseMapper<LogCustomProductEntity> { public interface LogCustomProductMapper extends BaseMapper<LogCustomProductEntity> {
/**
* 根据商品 ID 查询日志(按 id 降序,限制条数)
*
* @param productId 商品 ID
* @param limit 最大返回条数
* @return 日志列表
*/
List<LogCustomProductEntity> selectByProductIdWithLimit(@Param("productId") Integer productId,
@Param("limit") Integer limit);
} }
...@@ -3,6 +3,8 @@ package com.jomalls.custom.domain.service; ...@@ -3,6 +3,8 @@ package com.jomalls.custom.domain.service;
import com.jomalls.custom.dal.entity.DbDiyEntity; import com.jomalls.custom.dal.entity.DbDiyEntity;
import com.jomalls.custom.service.IBaseService; import com.jomalls.custom.service.IBaseService;
import java.util.List;
/** /**
* @author Lizh * @author Lizh
* @version 0.01 * @version 0.01
...@@ -11,5 +13,9 @@ import com.jomalls.custom.service.IBaseService; ...@@ -11,5 +13,9 @@ import com.jomalls.custom.service.IBaseService;
*/ */
public interface DbDiyDomainService extends IBaseService<DbDiyEntity> { public interface DbDiyDomainService extends IBaseService<DbDiyEntity> {
/**
* 根据 ID 列表和状态查询模板,并按用户 ID 做权限过滤(FIND_IN_SET)
*/
List<DbDiyEntity> selectByIdsWithUserPermission(List<Integer> ids, List<Integer> statusList, Integer userId);
} }
...@@ -3,6 +3,8 @@ package com.jomalls.custom.domain.service; ...@@ -3,6 +3,8 @@ package com.jomalls.custom.domain.service;
import com.jomalls.custom.dal.entity.LogCustomProductEntity; import com.jomalls.custom.dal.entity.LogCustomProductEntity;
import com.jomalls.custom.service.IBaseService; import com.jomalls.custom.service.IBaseService;
import java.util.List;
/** /**
* @author Lizh * @author Lizh
* @version 0.01 * @version 0.01
...@@ -11,5 +13,9 @@ import com.jomalls.custom.service.IBaseService; ...@@ -11,5 +13,9 @@ import com.jomalls.custom.service.IBaseService;
*/ */
public interface LogCustomProductDomainService extends IBaseService<LogCustomProductEntity> { public interface LogCustomProductDomainService extends IBaseService<LogCustomProductEntity> {
/**
* 根据商品 ID 查询日志(按 id 降序,限制条数)
*/
List<LogCustomProductEntity> selectByProductIdWithLimit(Integer productId, Integer limit);
} }
...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service;
* @date 2026-06-11 * @date 2026-06-11
*/ */
@Service @Service
public class CraftCenterDomainServiceImpl public class CraftCenterDomainServiceImpl extends BaseServiceImpl<CraftCenterMapper, CraftCenterEntity> implements CraftCenterDomainService {
extends BaseServiceImpl<CraftCenterMapper, CraftCenterEntity>
implements CraftCenterDomainService {
@Autowired @Autowired
public CraftCenterDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public CraftCenterDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -8,6 +8,8 @@ import org.apache.ibatis.session.SqlSessionFactory; ...@@ -8,6 +8,8 @@ import org.apache.ibatis.session.SqlSessionFactory;
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.List;
/** /**
* @author Lizh * @author Lizh
...@@ -22,6 +24,13 @@ public class DbDiyDomainServiceImpl extends BaseServiceImpl<DbDiyMapper,DbDiyEnt ...@@ -22,6 +24,13 @@ public class DbDiyDomainServiceImpl extends BaseServiceImpl<DbDiyMapper,DbDiyEnt
public DbDiyDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public DbDiyDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
super(sqlSessionFactory); super(sqlSessionFactory);
} }
// 自定义方法或者基础方法重写
@Override
public List<DbDiyEntity> selectByIdsWithUserPermission(List<Integer> ids, List<Integer> statusList, Integer userId) {
if (ids == null || ids.isEmpty()) {
return List.of();
}
return baseMapper.selectByIdsWithUserPermission(ids, statusList, userId);
}
} }
\ No newline at end of file
...@@ -20,9 +20,7 @@ import java.util.List; ...@@ -20,9 +20,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Service @Service
public class DbDiyXiaoguotuDomainServiceImpl public class DbDiyXiaoguotuDomainServiceImpl extends BaseServiceImpl<DbDiyXiaoguotuMapper, DbDiyXiaoguotuEntity> implements DbDiyXiaoguotuDomainService {
extends BaseServiceImpl<DbDiyXiaoguotuMapper, DbDiyXiaoguotuEntity>
implements DbDiyXiaoguotuDomainService {
@Autowired @Autowired
public DbDiyXiaoguotuDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public DbDiyXiaoguotuDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -8,6 +8,8 @@ import org.apache.ibatis.session.SqlSessionFactory; ...@@ -8,6 +8,8 @@ import org.apache.ibatis.session.SqlSessionFactory;
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.List;
/** /**
* @author Lizh * @author Lizh
...@@ -22,6 +24,10 @@ public class LogCustomProductDomainServiceImpl extends BaseServiceImpl<LogCustom ...@@ -22,6 +24,10 @@ public class LogCustomProductDomainServiceImpl extends BaseServiceImpl<LogCustom
public LogCustomProductDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public LogCustomProductDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
super(sqlSessionFactory); super(sqlSessionFactory);
} }
// 自定义方法或者基础方法重写
@Override
public List<LogCustomProductEntity> selectByProductIdWithLimit(Integer productId, Integer limit) {
return baseMapper.selectByProductIdWithLimit(productId, limit);
}
} }
\ No newline at end of file
...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service;
* @date 2026-06-12 * @date 2026-06-12
*/ */
@Service @Service
public class LogProductTemplateDomainServiceImpl public class LogProductTemplateDomainServiceImpl extends BaseServiceImpl<LogProductTemplateMapper, LogProductTemplateEntity> implements LogProductTemplateDomainService {
extends BaseServiceImpl<LogProductTemplateMapper, LogProductTemplateEntity>
implements LogProductTemplateDomainService {
@Autowired @Autowired
public LogProductTemplateDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public LogProductTemplateDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service;
* @date 2026-06-06 * @date 2026-06-06
*/ */
@Service @Service
public class ProductFactoryRelDomainServiceImpl public class ProductFactoryRelDomainServiceImpl extends BaseServiceImpl<ProductFactoryRelMapper, ProductFactoryRelEntity> implements ProductFactoryRelDomainService {
extends BaseServiceImpl<ProductFactoryRelMapper, ProductFactoryRelEntity>
implements ProductFactoryRelDomainService {
@Autowired @Autowired
public ProductFactoryRelDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public ProductFactoryRelDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -19,9 +19,7 @@ import java.util.List; ...@@ -19,9 +19,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Service @Service
public class ProductTemplateInfoDomainServiceImpl public class ProductTemplateInfoDomainServiceImpl extends BaseServiceImpl<ProductTemplateInfoMapper, ProductTemplateInfoEntity> implements ProductTemplateInfoDomainService {
extends BaseServiceImpl<ProductTemplateInfoMapper, ProductTemplateInfoEntity>
implements ProductTemplateInfoDomainService {
@Autowired @Autowired
public ProductTemplateInfoDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public ProductTemplateInfoDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -19,9 +19,7 @@ import java.util.List; ...@@ -19,9 +19,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Service @Service
public class ProductTemplateItemDomainServiceImpl public class ProductTemplateItemDomainServiceImpl extends BaseServiceImpl<ProductTemplateItemMapper, ProductTemplateItemEntity> implements ProductTemplateItemDomainService {
extends BaseServiceImpl<ProductTemplateItemMapper, ProductTemplateItemEntity>
implements ProductTemplateItemDomainService {
@Autowired @Autowired
public ProductTemplateItemDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public ProductTemplateItemDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,9 +15,7 @@ import org.springframework.stereotype.Service;
* @date 2026-06-05 * @date 2026-06-05
*/ */
@Service @Service
public class SysBillRuleDomainServiceImpl public class SysBillRuleDomainServiceImpl extends BaseServiceImpl<SysBillRuleMapper, SysBillRuleEntity> implements SysBillRuleDomainService {
extends BaseServiceImpl<SysBillRuleMapper, SysBillRuleEntity>
implements SysBillRuleDomainService {
@Autowired @Autowired
public SysBillRuleDomainServiceImpl(SqlSessionFactory sqlSessionFactory) { public SysBillRuleDomainServiceImpl(SqlSessionFactory sqlSessionFactory) {
......
...@@ -108,6 +108,23 @@ ...@@ -108,6 +108,23 @@
diy_remark diy_remark
</sql> </sql>
<!-- 按 ID + 状态 + 用户权限过滤查询 -->
<!-- FIND_IN_SET -->
<select id="selectByIdsWithUserPermission" resultMap="dbDiyMap">
SELECT <include refid="tableColumns"/>
FROM db_diy
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND status IN
<foreach collection="statusList" item="st" open="(" separator="," close=")">
#{st}
</foreach>
AND (user_ids IS NULL OR FIND_IN_SET(#{userId}, user_ids) &gt; 0)
AND (ban_user_ids IS NULL OR FIND_IN_SET(#{userId}, ban_user_ids) = 0)
</select>
<!-- 批量插入 --> <!-- 批量插入 -->
<insert id="insertBatchSomeColumn"> <insert id="insertBatchSomeColumn">
INSERT INTO db_diy (sku, title, en_name, idx, img_url, img_arr, bianma, content, leixing, sc_img_type, chima_now_render, render, parent_id, user_ids, ban_user_ids, type_id, status, create_date, default_diy_id, factory_id, print_type, material, craft_id, min_price, max_price, picture_status, remark, namespace, audit_id, audit_name, audit_date, shelf_date, template_id, category_id, allocation_id, allocation_name, expedited, bind_diy_ids, is_bind, usa_made, manufacturer, style_num, type, production_client, erp_sku_properties, push_user, new_standard, diy_remark) VALUES INSERT INTO db_diy (sku, title, en_name, idx, img_url, img_arr, bianma, content, leixing, sc_img_type, chima_now_render, render, parent_id, user_ids, ban_user_ids, type_id, status, create_date, default_diy_id, factory_id, print_type, material, craft_id, min_price, max_price, picture_status, remark, namespace, audit_id, audit_name, audit_date, shelf_date, template_id, category_id, allocation_id, allocation_name, expedited, bind_diy_ids, is_bind, usa_made, manufacturer, style_num, type, production_client, erp_sku_properties, push_user, new_standard, diy_remark) VALUES
......
...@@ -22,6 +22,15 @@ ...@@ -22,6 +22,15 @@
create_time create_time
</sql> </sql>
<!-- 根据商品 ID 查询日志(按 id 降序,限制条数) -->
<select id="selectByProductIdWithLimit" resultMap="logCustomProductMap">
SELECT <include refid="tableColumns"/>
FROM log_custom_product
WHERE product_id = #{productId}
ORDER BY id DESC
LIMIT #{limit}
</select>
<!-- 批量插入 --> <!-- 批量插入 -->
<insert id="insertBatchSomeColumn"> <insert id="insertBatchSomeColumn">
INSERT INTO log_custom_product (product_id, employee_id, employee_account, description, create_time) VALUES INSERT INTO log_custom_product (product_id, employee_id, employee_account, description, create_time) VALUES
......
...@@ -3,58 +3,87 @@ ...@@ -3,58 +3,87 @@
<mapper namespace="com.jomalls.custom.dal.mapper.SysUserMapper"> <mapper namespace="com.jomalls.custom.dal.mapper.SysUserMapper">
<!-- 通用查询列 --> <resultMap type="com.jomalls.custom.dal.entity.SysUserEntity" id="sysUserMap">
<sql id="Base_Column_List"> <result property="userId" column="user_id"/>
id, username, password, email, phone, status, created_at, updated_at <result property="deptId" column="dept_id"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="userType" column="user_type"/>
<result property="email" column="email"/>
<result property="phonenumber" column="phonenumber"/>
<result property="sex" column="sex"/>
<result property="avatar" column="avatar"/>
<result property="password" column="password"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="loginIp" column="login_ip"/>
<result property="loginDate" column="login_date"/>
<result property="pwdUpdateDate" column="pwd_update_date"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="tableColumns">
user_id, dept_id, user_name, nick_name, user_type,
email, phonenumber, sex, avatar, password,
status, del_flag, login_ip, login_date, pwd_update_date,
create_by, create_time, update_by, update_time, remark
</sql> </sql>
<!-- 根据用户名查询用户 --> <!-- 根据用户名查询用户 -->
<select id="selectByUsername" parameterType="java.lang.String" resultType="com.jomalls.custom.dal.entity.SysUserEntity"> <select id="selectByUsername" resultMap="sysUserMap">
SELECT SELECT <include refid="tableColumns"/>
<include refid="Base_Column_List"/>
FROM sys_user FROM sys_user
WHERE username = #{username} WHERE user_name = #{userName}
AND status = 1 AND status = '0'
AND del_flag = '0'
</select> </select>
<!-- 根据邮箱查询用户 --> <!-- 根据邮箱查询用户 -->
<select id="selectByEmail" parameterType="java.lang.String" resultType="com.jomalls.custom.dal.entity.SysUserEntity"> <select id="selectByEmail" resultMap="sysUserMap">
SELECT SELECT <include refid="tableColumns"/>
<include refid="Base_Column_List"/>
FROM sys_user FROM sys_user
WHERE email = #{email} WHERE email = #{email}
AND status = 1 AND status = '0'
AND del_flag = '0'
</select> </select>
<!-- 分页查询用户列表 --> <!-- 分页查询用户列表 -->
<select id="selectUserPage" parameterType="com.jomalls.custom.dal.entity.SysUserEntity" resultType="com.jomalls.custom.dal.entity.SysUserEntity"> <select id="selectUserPage" resultMap="sysUserMap">
SELECT SELECT <include refid="tableColumns"/>
<include refid="Base_Column_List"/>
FROM sys_user FROM sys_user
<where> WHERE del_flag = '0'
<if test="status != null"> <if test="status != null">
AND status = #{status} AND status = #{status}
</if> </if>
</where> ORDER BY create_time DESC
ORDER BY created_at DESC
</select> </select>
<!-- 查询所有启用状态的用户 --> <!-- 查询所有启用状态的用户 -->
<select id="selectAllActiveUsers" resultType="com.jomalls.custom.dal.entity.SysUserEntity"> <select id="selectAllActiveUsers" resultMap="sysUserMap">
SELECT SELECT <include refid="tableColumns"/>
<include refid="Base_Column_List"/>
FROM sys_user FROM sys_user
WHERE status = 1 WHERE status = '0'
ORDER BY created_at DESC AND del_flag = '0'
ORDER BY create_time DESC
</select> </select>
<!-- 批量插入 --> <!-- 批量插入 -->
<insert id="insertBatchSomeColumn"> <insert id="insertBatchSomeColumn">
INSERT INTO sys_user (username, password, email, phone, status, created_at, updated_at) VALUES INSERT INTO sys_user (user_name, nick_name, user_type,
email, phonenumber, sex, avatar, password,
status, del_flag, login_ip, login_date,
pwd_update_date, create_by, create_time, update_by, update_time, remark)
VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.username}, #{item.password}, #{item.email}, #{item.phone}, #{item.status}, #{item.createdAt}, #{item.updatedAt}) (#{item.userName}, #{item.nickName}, #{item.userType},
#{item.email}, #{item.phonenumber}, #{item.sex}, #{item.avatar}, #{item.password},
#{item.status}, #{item.delFlag}, #{item.loginIp}, #{item.loginDate},
#{item.pwdUpdateDate}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>
\ No newline at end of file
...@@ -13,7 +13,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -13,7 +13,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
*/ */
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
@EnableAspectJAutoProxy
public class CustomServerApplication { public class CustomServerApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -6,13 +6,18 @@ import com.jomalls.custom.app.exception.PermissionDeniedException; ...@@ -6,13 +6,18 @@ import com.jomalls.custom.app.exception.PermissionDeniedException;
import com.jomalls.custom.integrate.exception.RemoteServiceException; import com.jomalls.custom.integrate.exception.RemoteServiceException;
import com.jomalls.custom.app.exception.ServiceException; import com.jomalls.custom.app.exception.ServiceException;
import com.jomalls.custom.utils.R; import com.jomalls.custom.utils.R;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.stream.Collectors;
/** /**
* 全局异常处理切面 * 全局异常处理切面
*/ */
...@@ -31,6 +36,32 @@ public class CommonExceptionHandlerAdvice { ...@@ -31,6 +36,32 @@ public class CommonExceptionHandlerAdvice {
} }
/** /**
* @Valid 校验失败(请求体参数校验不通过)
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<R<Object>> handleMethodArgumentNotValid(MethodArgumentNotValidException e) {
String detail = e.getBindingResult().getFieldErrors().stream()
.map(fe -> fe.getField() + ": " + fe.getDefaultMessage())
.collect(Collectors.joining("; "));
log.debug("[ 参数校验失败 ] {}", detail);
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(R.fail(CodeEnum.BAD_REQUEST.getCode(), "参数校验失败: " + detail));
}
/**
* @Validated 校验失败(方法参数校验不通过)
*/
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<R<Object>> handleConstraintViolation(ConstraintViolationException e) {
String detail = e.getConstraintViolations().stream()
.map(ConstraintViolation::getMessage)
.collect(Collectors.joining("; "));
log.debug("[ 约束校验失败 ] {}", detail);
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(R.fail(CodeEnum.BAD_REQUEST.getCode(), "参数校验失败: " + detail));
}
/**
* token验证失败(返回401 未登录或登录已过期) * token验证失败(返回401 未登录或登录已过期)
*/ */
@ExceptionHandler(InvalidTokenException.class) @ExceptionHandler(InvalidTokenException.class)
...@@ -52,12 +83,16 @@ public class CommonExceptionHandlerAdvice { ...@@ -52,12 +83,16 @@ public class CommonExceptionHandlerAdvice {
/** /**
* 业务异常处理 * 业务异常处理
* <p>
* 根据异常携带的 code 映射 HTTP 状态码:403→FORBIDDEN, 401→UNAUTHORIZED,
* 404→NOT_FOUND, 400→BAD_REQUEST, 其余→INTERNAL_SERVER_ERROR。
* </p>
*/ */
@ExceptionHandler(ServiceException.class) @ExceptionHandler(ServiceException.class)
public ResponseEntity<R<Object>> handleServiceException(ServiceException e) { public ResponseEntity<R<Object>> handleServiceException(ServiceException e) {
log.debug("[ 业务异常 ] {}", e.getMessage(), e); log.debug("[ 业务异常 ] code={}, {}", e.getCode(), e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) HttpStatus httpStatus = CodeEnum.MAP.getOrDefault(e.getCode(), HttpStatus.INTERNAL_SERVER_ERROR);
.body(R.fail(e.getMessage())); return ResponseEntity.status(httpStatus).body(R.fail(e.getCode(), e.getMessage()));
} }
/** /**
......
...@@ -23,7 +23,6 @@ import jakarta.servlet.http.HttpServletResponse; ...@@ -23,7 +23,6 @@ import jakarta.servlet.http.HttpServletResponse;
* 负责用户登录权限检查,保存登录信息到线程本地变量 * 负责用户登录权限检查,保存登录信息到线程本地变量
*/ */
@Slf4j @Slf4j
@Component
public class SecurityInterceptor implements HandlerInterceptor { public class SecurityInterceptor implements HandlerInterceptor {
@Autowired @Autowired
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductBlacklist", description = "Controller") @Tag(name = "商品黑名单管理", description = "商品黑名单管理接口")
@RequestMapping("/customProductBlacklist") @RequestMapping("/customProductBlacklist")
@RequiredArgsConstructor
public class CustomProductBlacklistController { public class CustomProductBlacklistController {
@Autowired private final CustomProductBlacklistService customProductBlacklistService;
private CustomProductBlacklistService customProductBlacklistService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -9,8 +9,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -9,8 +9,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -24,12 +24,12 @@ import java.util.List; ...@@ -24,12 +24,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductCraftRel", description = "Controller") @Tag(name = "商品工艺关联管理", description = "商品工艺关联接口")
@RequestMapping("/customProductCraftRel") @RequestMapping("/customProductCraftRel")
@RequiredArgsConstructor
public class CustomProductCraftRelController { public class CustomProductCraftRelController {
@Autowired private final CustomProductCraftRelService customProductCraftRelService;
private CustomProductCraftRelService customProductCraftRelService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductDiyUserRel", description = "Controller") @Tag(name = "商品DIY用户关联管理", description = "商品DIY用户关联接口")
@RequestMapping("/customProductDiyUserRel") @RequestMapping("/customProductDiyUserRel")
@RequiredArgsConstructor
public class CustomProductDiyUserRelController { public class CustomProductDiyUserRelController {
@Autowired private final CustomProductDiyUserRelService customProductDiyUserRelService;
private CustomProductDiyUserRelService customProductDiyUserRelService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductFactoryPriceIntervalRel", description = "Controller") @Tag(name = "工厂价格区间管理", description = "工厂价格区间接口")
@RequestMapping("/customProductFactoryPriceIntervalRel") @RequestMapping("/customProductFactoryPriceIntervalRel")
@RequiredArgsConstructor
public class CustomProductFactoryPriceIntervalRelController { public class CustomProductFactoryPriceIntervalRelController {
@Autowired private final CustomProductFactoryPriceIntervalRelService customProductFactoryPriceIntervalRelService;
private CustomProductFactoryPriceIntervalRelService customProductFactoryPriceIntervalRelService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductFactoryPriceRel", description = "Controller") @Tag(name = "工厂价格关联管理", description = "工厂价格关联接口")
@RequestMapping("/customProductFactoryPriceRel") @RequestMapping("/customProductFactoryPriceRel")
@RequiredArgsConstructor
public class CustomProductFactoryPriceRelController { public class CustomProductFactoryPriceRelController {
@Autowired private final CustomProductFactoryPriceRelService customProductFactoryPriceRelService;
private CustomProductFactoryPriceRelService customProductFactoryPriceRelService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductImage", description = "Controller") @Tag(name = "商品图片管理", description = "商品图片管理接口")
@RequestMapping("/customProductImage") @RequestMapping("/customProductImage")
@RequiredArgsConstructor
public class CustomProductImageController { public class CustomProductImageController {
@Autowired private final CustomProductImageService customProductImageService;
private CustomProductImageService customProductImageService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -15,8 +15,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -15,8 +15,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -31,12 +31,12 @@ import java.util.Map; ...@@ -31,12 +31,12 @@ import java.util.Map;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/api/v2/product/info", description = "定制商品接口") @Tag(name = "定制商品管理", description = "定制商品管理接口")
@RequestMapping("/api/v2/product/info") @RequestMapping("/api/v2/product/info")
@RequiredArgsConstructor
public class CustomProductInfoController { public class CustomProductInfoController {
@Autowired private final CustomProductInfoService customProductInfoService;
private CustomProductInfoService customProductInfoService;
@Operation(summary = "创建商品", description = "创建商品") @Operation(summary = "创建商品", description = "创建商品")
@PostMapping("/create") @PostMapping("/create")
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductInfoProperty", description = "Controller") @Tag(name = "商品属性管理", description = "商品属性管理接口")
@RequestMapping("/customProductInfoProperty") @RequestMapping("/customProductInfoProperty")
@RequiredArgsConstructor
public class CustomProductInfoPropertyController { public class CustomProductInfoPropertyController {
@Autowired private final CustomProductInfoPropertyService customProductInfoPropertyService;
private CustomProductInfoPropertyService customProductInfoPropertyService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -7,8 +7,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -7,8 +7,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
...@@ -17,19 +17,19 @@ import java.util.List; ...@@ -17,19 +17,19 @@ import java.util.List;
/** /**
* 定制商品明细 Controller * 定制商品明细 Controller
* <p> * <p>
* 对齐 TS 项目 {@code ApiCustomProductItemController} * 对齐 TS 项目 {@code ApiCustomProductItemController}.
* *
* @author Lizh * @author Lizh
* @date 2026-06-12 * @date 2026-06-12
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/api/v2/product/item", description = "定制商品明细") @Tag(name = "定制商品明细", description = "定制商品明细接口")
@RequestMapping("/api/v2/product/item") @RequestMapping("/api/v2/product/item")
@RequiredArgsConstructor
public class CustomProductItemController { public class CustomProductItemController {
@Autowired private final CustomProductItemService customProductItemService;
private CustomProductItemService customProductItemService;
/** /**
* 根据商品 ID 获取明细集合 * 根据商品 ID 获取明细集合
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customProductWarehouseRel", description = "Controller") @Tag(name = "商品仓库关联管理", description = "商品仓库关联接口")
@RequestMapping("/customProductWarehouseRel") @RequestMapping("/customProductWarehouseRel")
@RequiredArgsConstructor
public class CustomProductWarehouseRelController { public class CustomProductWarehouseRelController {
@Autowired private final CustomProductWarehouseRelService customProductWarehouseRelService;
private CustomProductWarehouseRelService customProductWarehouseRelService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/customWarehouseInfo", description = "Controller") @Tag(name = "仓库信息管理", description = "仓库信息接口")
@RequestMapping("/customWarehouseInfo") @RequestMapping("/customWarehouseInfo")
@RequiredArgsConstructor
public class CustomWarehouseInfoController { public class CustomWarehouseInfoController {
@Autowired private final CustomWarehouseInfoService customWarehouseInfoService;
private CustomWarehouseInfoService customWarehouseInfoService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -23,12 +23,12 @@ import java.util.List; ...@@ -23,12 +23,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/dbDiy", description = "Controller") @Tag(name = "DIY模板管理", description = "DIY模板信息接口")
@RequestMapping("/dbDiy") @RequestMapping("/dbDiy")
@RequiredArgsConstructor
public class DbDiyController { public class DbDiyController {
@Autowired private final DbDiyService dbDiyService;
private DbDiyService dbDiyService;
/** /**
* 列表查询接口 * 列表查询接口
......
...@@ -3,6 +3,7 @@ package com.jomalls.custom.webapp.controller; ...@@ -3,6 +3,7 @@ package com.jomalls.custom.webapp.controller;
import com.jomalls.custom.app.constant.Constants; import com.jomalls.custom.app.constant.Constants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -13,6 +14,7 @@ import java.util.Map; ...@@ -13,6 +14,7 @@ import java.util.Map;
* @Description: 心跳检测接口 * @Description: 心跳检测接口
* @Version: 1.0 * @Version: 1.0
*/ */
@RestController
public class HealthController { public class HealthController {
/** /**
* 健康状态字段 * 健康状态字段
......
...@@ -5,6 +5,7 @@ import com.jomalls.custom.app.vo.LogCustomProductSnakeVO; ...@@ -5,6 +5,7 @@ import com.jomalls.custom.app.vo.LogCustomProductSnakeVO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -22,16 +23,13 @@ import java.util.List; ...@@ -22,16 +23,13 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/api/v2/product/log", description = "商品日志接口") @Tag(name = "商品日志管理", description = "商品日志管理接口")
@RequestMapping("/api/v2/product/log") @RequestMapping("/api/v2/product/log")
@RequiredArgsConstructor
public class LogCustomProductController { public class LogCustomProductController {
private final LogCustomProductService logCustomProductService; private final LogCustomProductService logCustomProductService;
public LogCustomProductController(LogCustomProductService logCustomProductService) {
this.logCustomProductService = logCustomProductService;
}
/** /**
* 根据商品 ID 获取日志列表(对齐 TS getListByProductId) * 根据商品 ID 获取日志列表(对齐 TS getListByProductId)
* *
......
...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -8,8 +8,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -22,12 +22,12 @@ import java.util.List; ...@@ -22,12 +22,12 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/productFactoryRel", description = "产品-工厂关联接口") @Tag(name = "产品工厂关联管理", description = "产品工厂关联接口")
@RequestMapping("/productFactoryRel") @RequestMapping("/productFactoryRel")
@RequiredArgsConstructor
public class ProductFactoryRelController { public class ProductFactoryRelController {
@Autowired private final ProductFactoryRelService productFactoryRelService;
private ProductFactoryRelService productFactoryRelService;
@Operation(summary = "列表查询接口", description = "根据条件查询列表接口(不分页)") @Operation(summary = "列表查询接口", description = "根据条件查询列表接口(不分页)")
@RequestMapping(value = "/list", method = RequestMethod.POST) @RequestMapping(value = "/list", method = RequestMethod.POST)
......
...@@ -4,8 +4,8 @@ import com.jomalls.custom.app.service.SysBillRuleService; ...@@ -4,8 +4,8 @@ import com.jomalls.custom.app.service.SysBillRuleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
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;
...@@ -21,12 +21,12 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -21,12 +21,12 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name = "/api/v2/product/homesku", description = "生成产品SKU编号") @Tag(name = "SKU编号生成", description = "生成产品SKU编号")
@RequestMapping("/api/v2/product/homesku") @RequestMapping("/api/v2/product/homesku")
@RequiredArgsConstructor
public class SysBillRuleController { public class SysBillRuleController {
@Autowired private final SysBillRuleService sysBillRuleService;
private SysBillRuleService sysBillRuleService;
/** /**
* 生成产品SKU编号 * 生成产品SKU编号
......
...@@ -9,7 +9,7 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -9,7 +9,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -20,15 +20,11 @@ import java.util.List; ...@@ -20,15 +20,11 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/api/users") @RequestMapping("/api/users")
@Tag(name = "用户管理", description = "用户管理相关API") @Tag(name = "用户管理", description = "用户管理相关API")
@RequiredArgsConstructor
public class SysUserController { public class SysUserController {
private final SysUserService sysUserService; private final SysUserService sysUserService;
@Autowired
public SysUserController(SysUserService sysUserService) {
this.sysUserService = sysUserService;
}
/** /**
* 列表查询接口 * 列表查询接口
* *
...@@ -101,4 +97,4 @@ public class SysUserController { ...@@ -101,4 +97,4 @@ public class SysUserController {
public void deleteById(@Parameter(description = "用户ID", required = true) @PathVariable Long id) { public void deleteById(@Parameter(description = "用户ID", required = true) @PathVariable Long id) {
sysUserService.deleteById(id); sysUserService.deleteById(id);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment