From 2af85ee22e625dd08b0f902ede1721e85ccdfade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Tue, 31 Mar 2026 09:31:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=82=A8=E5=8A=A8=E6=80=81=E8=A1=A8?= =?UTF-8?q?=E5=8D=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sysTableConfig/entity/SysTableConfig.java | 63 ++++++ .../facade/ISysTableConfigService.java | 57 +++++ .../mapper/SysTableConfigMapper.java | 47 ++++ .../SysTableConfigServiceImpl.java | 140 ++++++++++++ .../repository/po/SysTableConfigPO.java | 61 ++++++ .../repository/todo/SysTableConfigDTO.java | 62 ++++++ .../repository/vo/SysTableConfigVO.java | 62 ++++++ .../sysTableConfig/SysTableConfigApi.java | 204 ++++++++++++++++++ .../sysTableConfig/SysTableConfigMapper.xml | 33 +++ 9 files changed, 729 insertions(+) create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/entity/SysTableConfig.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/facade/ISysTableConfigService.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/mapper/SysTableConfigMapper.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/persistence/SysTableConfigServiceImpl.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/po/SysTableConfigPO.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/todo/SysTableConfigDTO.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/vo/SysTableConfigVO.java create mode 100644 mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/sysTableConfig/SysTableConfigApi.java create mode 100644 mhd_wms/src/main/resources/mapper/sysTableConfig/SysTableConfigMapper.xml diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/entity/SysTableConfig.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/entity/SysTableConfig.java new file mode 100644 index 000000000..be61deaa1 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/entity/SysTableConfig.java @@ -0,0 +1,63 @@ +package com.mhd.wms.domain.sysTableConfig.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mhd.common.core.annotation.Excel; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author: brb + * @description: + * @create: 2026-03-04 14:30 + */ +@Data +@TableName("sys_table_config") +public class SysTableConfig extends BaseVOEntity { + + @TableId(type = IdType.AUTO) + private Long id; + /* + * 仓库id + * */ + @ApiModelProperty("仓库ID") + @Excel(name = "仓库ID") + private Long warehouseId; + /**组织ID*/ + @ApiModelProperty(value = "组织ID") + @Excel(name = "组织ID", width = 15) + private Long organizationId; + /**一级组织ID*/ + @ApiModelProperty(value = "一级组织ID") + @Excel(name = "一级组织ID", width = 15) + private Long topOrganizationId; + /**组织名称*/ + @ApiModelProperty(value = "组织名称") + @Excel(name = "组织名称", width = 15) + private String organizationName; + /**键*/ + @ApiModelProperty(value = "键") + @Excel(name = "键", width = 15) + private String key; + /**值*/ + @ApiModelProperty(value = "值") + @Excel(name = "值", width = 15) + private String value; + /**备注说明*/ + @ApiModelProperty(value = "备注说明") + @Excel(name = "备注说明", width = 15) + private String remark; + /**明细值*/ + @ApiModelProperty(value = "明细值") + @Excel(name = "明细值", width = 15) + private String detailValue; + /**物料添加方式*/ + @ApiModelProperty(value = "物料添加方式") + @Excel(name = "物料添加方式", width = 15) + private String materialAddType; +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/facade/ISysTableConfigService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/facade/ISysTableConfigService.java new file mode 100644 index 000000000..3da3dee51 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/facade/ISysTableConfigService.java @@ -0,0 +1,57 @@ +package com.mhd.wms.domain.sysTableConfig.repository.facade; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.mhd.wms.domain.sysTableConfig.entity.SysTableConfig; +import com.mhd.wms.domain.sysTableConfig.repository.todo.SysTableConfigDTO; +import com.mhd.wms.domain.sysTableConfig.repository.vo.SysTableConfigVO; + +import java.util.List; + +public interface ISysTableConfigService extends IService { + + + /** + * 分页查询配置列表 + * @param page 分页对象 + * @param sysTableConfigDTO 查询条件 + * @return 配置列表 + */ + Page queryList(Page page, SysTableConfigDTO sysTableConfigDTO); + + /** + * 根据组织 ID 和键查询配置 + * @param organizationId 组织 ID + * @param key 配置键 + * @return 配置信息 + */ + SysTableConfig getByOrgIdAndKey(Long organizationId, String key); + + /** + * 根据组织 ID 查询所有配置 + * @param organizationId 组织 ID + * @return 配置列表 + */ + List listByOrgId(Long organizationId); + + /** + * 保存或更新配置(根据组织 ID 和键判断是新增还是更新) + * @param sysTableConfigDTO 配置信息 + * @return 是否成功 + */ + boolean saveOrUpdateConfig(SysTableConfigDTO sysTableConfigDTO); + + /** + * 删除配置 + * @param ids 主键 ID 列表 + * @return 是否成功 + */ + int delete(List ids); + + /** + * 根据组织 ID 删除所有配置 + * @param organizationId 组织 ID + * @return 是否成功 + */ + int deleteByOrgId(Long organizationId); +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/mapper/SysTableConfigMapper.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/mapper/SysTableConfigMapper.java new file mode 100644 index 000000000..a2aaa6902 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/mapper/SysTableConfigMapper.java @@ -0,0 +1,47 @@ +package com.mhd.wms.domain.sysTableConfig.repository.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mhd.wms.domain.sysTableConfig.entity.SysTableConfig; +import com.mhd.wms.domain.sysTableConfig.repository.vo.SysTableConfigVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: 系统表配置(全局表内容展示顺序) + * @Author: Assistant + * @Date: 2026-03-04 + * @Version: V1.0 + */ +public interface SysTableConfigMapper extends BaseMapper { + + /** + * 根据组织 ID 和键查询配置 + * @param organizationId 组织 ID + * @param key 配置键 + * @return 配置信息 + */ + @Select("SELECT * FROM sys_table_config WHERE organization_id = #{organizationId} AND key = #{key}") + SysTableConfig getByOrgIdAndKey(@Param("organizationId") Long organizationId, @Param("key") String key); + + /** + * 根据组织 ID 查询所有配置 + * @param organizationId 组织 ID + * @return 配置列表 + */ + @Select("SELECT * FROM sys_table_config WHERE organization_id = #{organizationId} ORDER BY create_time DESC") + List listByOrgId(@Param("organizationId") Long organizationId); + + /** + * 分页查询配置列表 + * @param page 分页对象 + * @param organizationId 组织 ID + * @param key 配置键(可选) + * @return 配置列表 + */ + List queryList(Page page, + @Param("organizationId") Long organizationId, + @Param("key") String key); +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/persistence/SysTableConfigServiceImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/persistence/SysTableConfigServiceImpl.java new file mode 100644 index 000000000..3e043c6f2 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/persistence/SysTableConfigServiceImpl.java @@ -0,0 +1,140 @@ +package com.mhd.wms.domain.sysTableConfig.repository.persistence; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mhd.common.core.exception.ServiceException; +import com.mhd.common.core.utils.StringUtils; +import com.mhd.common.security.utils.SecurityUtils; +import com.mhd.system.api.domain.WlhyLoginUser; +import com.mhd.wms.domain.sysTableConfig.entity.SysTableConfig; +import com.mhd.wms.domain.sysTableConfig.repository.facade.ISysTableConfigService; +import com.mhd.wms.domain.sysTableConfig.repository.mapper.SysTableConfigMapper; +import com.mhd.wms.domain.sysTableConfig.repository.todo.SysTableConfigDTO; +import com.mhd.wms.domain.sysTableConfig.repository.vo.SysTableConfigVO; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +@Service +public class SysTableConfigServiceImpl extends ServiceImpl implements ISysTableConfigService { + + + @Resource + private SysTableConfigMapper sysTableConfigMapper; + + @Override + public Page queryList(Page page, SysTableConfigDTO sysTableConfigDTO) { + // 获取登录人信息(可选,用于自动填充组织 ID) + try { + WlhyLoginUser loginUser = SecurityUtils.getLoginUser().getWlhyLoginUser(); + if (loginUser != null && sysTableConfigDTO.getOrganizationId() == null) { + // 如果没有传入组织 ID,可以选择不设置或者设置默认值 + // 这里保持传入参数不变,由 Mapper 层处理 null 值 + } + } catch (Exception e) { + e.printStackTrace(); + } + + List list = sysTableConfigMapper.queryList(page, + sysTableConfigDTO.getOrganizationId() != null ? sysTableConfigDTO.getOrganizationId().longValue() : null, + sysTableConfigDTO.getKey()); + return page.setRecords(list); + } + + @Override + public SysTableConfig getByOrgIdAndKey(Long organizationId, String key) { + if (organizationId == null || StringUtils.isBlank(key)) { + throw new ServiceException("组织 ID 和键不能为空"); + } + return sysTableConfigMapper.getByOrgIdAndKey(organizationId, key); + } + + @Override + public List listByOrgId(Long organizationId) { + if (organizationId == null) { + throw new ServiceException("组织 ID 不能为空"); + } + return sysTableConfigMapper.listByOrgId(organizationId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveOrUpdateConfig(SysTableConfigDTO sysTableConfigDTO) { + if (sysTableConfigDTO.getOrganizationId() == null) { + throw new ServiceException("组织 ID 不能为空"); + } + if (StringUtils.isBlank(sysTableConfigDTO.getKey())) { + throw new ServiceException("配置键不能为空"); + } + if (StringUtils.isBlank(sysTableConfigDTO.getValue())) { + throw new ServiceException("配置值不能为空"); + } + + // 获取登录人信息 + WlhyLoginUser loginUser = SecurityUtils.getLoginUser().getWlhyLoginUser(); + String username = loginUser != null ? loginUser.getUsername() : "system"; + + // 判断是新增还是更新 + SysTableConfig existingConfig = sysTableConfigMapper.getByOrgIdAndKey( + sysTableConfigDTO.getOrganizationId().longValue(), + sysTableConfigDTO.getKey()); + + if (existingConfig != null) { + // 更新 + existingConfig.setValue(sysTableConfigDTO.getValue()); + //existingConfig.setUpdateBy(username); + existingConfig.setUpdateTime(new Date()); + existingConfig.setDetailValue(sysTableConfigDTO.getDetailValue()); + existingConfig.setMaterialAddType(sysTableConfigDTO.getMaterialAddType()); + if (StringUtils.isNotBlank(sysTableConfigDTO.getRemark())) { + existingConfig.setRemark(sysTableConfigDTO.getRemark()); + } + return this.updateById(existingConfig); + } else { + // 新增 + SysTableConfig newConfig = new SysTableConfig(); + BeanUtils.copyProperties(sysTableConfigDTO, newConfig); + //newConfig.setCreateBy(username); + newConfig.setCreateTime(new Date()); + //newConfig.setUpdateBy(username); + newConfig.setUpdateTime(new Date()); + return this.save(newConfig); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int delete(List ids) { + if (ids == null || ids.isEmpty()) { + throw new ServiceException("删除的 ID 不能为空"); + } + + // 简单的日志记录,不做复杂的权限验证 + try { + WlhyLoginUser loginUser = SecurityUtils.getLoginUser().getWlhyLoginUser(); + if (loginUser != null) { + } + } catch (Exception e) { + e.printStackTrace(); + } + + return this.removeByIds(ids) ? ids.size() : 0; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteByOrgId(Long organizationId) { + if (organizationId == null) { + throw new ServiceException("组织 ID 不能为空"); + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysTableConfig::getOrganizationId, organizationId); + + return this.remove(queryWrapper) ? 1 : 0; + } +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/po/SysTableConfigPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/po/SysTableConfigPO.java new file mode 100644 index 000000000..8e5c2f797 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/po/SysTableConfigPO.java @@ -0,0 +1,61 @@ +package com.mhd.wms.domain.sysTableConfig.repository.po; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mhd.common.core.annotation.Excel; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author: brb + * @description: + * @create: 2026-03-04 14:30 + */ +@Data +public class SysTableConfigPO extends BaseVOEntity { + + @TableId(type = IdType.AUTO) + private Long id; + /* + * 仓库id + * */ + @ApiModelProperty("仓库ID") + @Excel(name = "仓库ID") + private Long warehouseId; + /**组织ID*/ + @ApiModelProperty(value = "组织ID") + @Excel(name = "组织ID", width = 15) + private Long organizationId; + /**键*/ + @ApiModelProperty(value = "键") + @Excel(name = "键", width = 15) + private String key; + /**值*/ + @ApiModelProperty(value = "值") + @Excel(name = "值", width = 15) + private String value; + /**备注说明*/ + @ApiModelProperty(value = "备注说明") + @Excel(name = "备注说明", width = 15) + private String remark; + /**明细值*/ + @ApiModelProperty(value = "明细值") + @Excel(name = "明细值", width = 15) + private String detailValue; + /**物料添加方式*/ + @ApiModelProperty(value = "物料添加方式") + @Excel(name = "物料添加方式", width = 15) + private String materialAddType; + /**一级组织ID*/ + @ApiModelProperty(value = "一级组织ID") + @Excel(name = "一级组织ID", width = 15) + private Long topOrganizationId; + /**组织名称*/ + @ApiModelProperty(value = "组织名称") + @Excel(name = "组织名称", width = 15) + private String organizationName; +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/todo/SysTableConfigDTO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/todo/SysTableConfigDTO.java new file mode 100644 index 000000000..9f3367ba7 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/todo/SysTableConfigDTO.java @@ -0,0 +1,62 @@ +package com.mhd.wms.domain.sysTableConfig.repository.todo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mhd.common.core.annotation.Excel; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author: brb + * @description: + * @create: 2026-03-04 14:30 + */ +@Data +@TableName("sys_table_config") +public class SysTableConfigDTO extends BaseVOEntity { + + @TableId(type = IdType.AUTO) + private Long id; + /* + * 仓库id + * */ + @ApiModelProperty("仓库ID") + @Excel(name = "仓库ID") + private Long warehouseId; + /**组织ID*/ + @ApiModelProperty(value = "组织ID") + @Excel(name = "组织ID", width = 15) + private Long organizationId; + /**键*/ + @ApiModelProperty(value = "键") + @Excel(name = "键", width = 15) + private String key; + /**值*/ + @ApiModelProperty(value = "值") + @Excel(name = "值", width = 15) + private String value; + /**备注说明*/ + @ApiModelProperty(value = "备注说明") + @Excel(name = "备注说明", width = 15) + private String remark; + /**明细值*/ + @ApiModelProperty(value = "明细值") + @Excel(name = "明细值", width = 15) + private String detailValue; + /**物料添加方式*/ + @ApiModelProperty(value = "物料添加方式") + @Excel(name = "物料添加方式", width = 15) + private String materialAddType; + /**一级组织ID*/ + @ApiModelProperty(value = "一级组织ID") + @Excel(name = "一级组织ID", width = 15) + private Long topOrganizationId; + /**组织名称*/ + @ApiModelProperty(value = "组织名称") + @Excel(name = "组织名称", width = 15) + private String organizationName; +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/vo/SysTableConfigVO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/vo/SysTableConfigVO.java new file mode 100644 index 000000000..42802dafb --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/sysTableConfig/repository/vo/SysTableConfigVO.java @@ -0,0 +1,62 @@ +package com.mhd.wms.domain.sysTableConfig.repository.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mhd.common.core.annotation.Excel; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author: brb + * @description: + * @create: 2026-03-04 14:30 + */ +@Data +@TableName("sys_table_config") +public class SysTableConfigVO extends BaseVOEntity { + + @TableId(type = IdType.AUTO) + private Long id; + /* + * 仓库id + * */ + @ApiModelProperty("仓库ID") + @Excel(name = "仓库ID") + private Long warehouseId; + /**组织ID*/ + @ApiModelProperty(value = "组织ID") + @Excel(name = "组织ID", width = 15) + private Long organizationId; + /**键*/ + @ApiModelProperty(value = "键") + @Excel(name = "键", width = 15) + private String key; + /**值*/ + @ApiModelProperty(value = "值") + @Excel(name = "值", width = 15) + private String value; + /**备注说明*/ + @ApiModelProperty(value = "备注说明") + @Excel(name = "备注说明", width = 15) + private String remark; + /**明细值*/ + @ApiModelProperty(value = "明细值") + @Excel(name = "明细值", width = 15) + private String detailValue; + /**物料添加方式*/ + @ApiModelProperty(value = "物料添加方式") + @Excel(name = "物料添加方式", width = 15) + private String materialAddType; + /**一级组织ID*/ + @ApiModelProperty(value = "一级组织ID") + @Excel(name = "一级组织ID", width = 15) + private Long topOrganizationId; + /**组织名称*/ + @ApiModelProperty(value = "组织名称") + @Excel(name = "组织名称", width = 15) + private String organizationName; +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/sysTableConfig/SysTableConfigApi.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/sysTableConfig/SysTableConfigApi.java new file mode 100644 index 000000000..d569d6339 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/sysTableConfig/SysTableConfigApi.java @@ -0,0 +1,204 @@ +package com.mhd.wms.interfaces.facadeApi.sysTableConfig; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mhd.common.core.utils.sms.Result; +import com.mhd.common.core.web.controller.BaseController; +import com.mhd.common.core.web.domain.AjaxResult; +import com.mhd.common.core.web.page.TableDataInfo; +import com.mhd.wms.application.service.stockShelfOrder.StockShelfOrderApplicationService; +import com.mhd.wms.domain.stockShelfOrder.repository.po.StockShelfOrderPO; +import com.mhd.wms.domain.stockShelfOrder.repository.todo.StockShelfOrderDO; +import com.mhd.wms.domain.sysTableConfig.entity.SysTableConfig; +import com.mhd.wms.domain.sysTableConfig.repository.facade.ISysTableConfigService; +import com.mhd.wms.domain.sysTableConfig.repository.todo.SysTableConfigDTO; +import com.mhd.wms.domain.sysTableConfig.repository.vo.SysTableConfigVO; +import com.mhd.wms.interfaces.assember.stockShelfOrder.StockShelfOrderAssembler; +import com.mhd.wms.interfaces.dto.stockShelfOrder.StockShelfOrderDTO; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author gen + * @date 2024-05-21 + */ +@RestController +@RequestMapping("/sysTableConfigApi") +@Slf4j +public class SysTableConfigApi extends BaseController { + @Autowired + private ISysTableConfigService sysTableConfigService; + + /** + * 分页列表查询 + * + * @param sysTableConfigDTO + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @ApiOperation(value = "系统表配置 - 分页列表查询", notes = "系统表配置 - 分页列表查询") + @GetMapping(value = "/queryList") + public Result queryList(SysTableConfigDTO sysTableConfigDTO, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + Result> result = new Result<>(); + Page pageList = new Page<>(pageNo, pageSize); + pageList = sysTableConfigService.queryList(pageList, sysTableConfigDTO); + result.setResult(pageList); + result.setSuccess(true); + return result; + } + + /** + * 根据组织 ID 和键查询配置 + * + * @param organizationId 组织 ID + * @param key 配置键 + * @return + */ + @ApiOperation(value = "系统表配置 - 根据组织 ID 和键查询", notes = "系统表配置 - 根据组织 ID 和键查询") + @GetMapping(value = "/getByOrgIdAndKey") + public Result getByOrgIdAndKey(@RequestParam(name="organizationId") Long organizationId, + @RequestParam(name="key") String key) { + try { + SysTableConfig config = sysTableConfigService.getByOrgIdAndKey(organizationId, key); + if (config == null) { + return Result.error("未找到对应配置"); + } + return Result.ok(config); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.error("查询失败:" + e.getMessage()); + } + } + + /** + * 根据组织 ID 查询所有配置 + * + * @param organizationId 组织 ID + * @return + */ + @ApiOperation(value = "系统表配置 - 根据组织 ID 查询所有配置", notes = "系统表配置 - 根据组织 ID 查询所有配置") + @GetMapping(value = "/listByOrgId") + public Result listByOrgId(@RequestParam(name="organizationId") Long organizationId) { + try { + List list = sysTableConfigService.listByOrgId(organizationId); + return Result.ok(list); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.error("查询失败:" + e.getMessage()); + } + } + + /** + * 添加或更新配置 + * + * @param sysTableConfigDTO + * @return + */ + @ApiOperation(value = "系统表配置 - 添加或更新", notes = "系统表配置 - 添加或更新") + @PostMapping(value = "/saveOrUpdate") + public Result saveOrUpdate(@RequestBody SysTableConfigDTO sysTableConfigDTO) { + Result result = new Result<>(); + try { + boolean success = sysTableConfigService.saveOrUpdateConfig(sysTableConfigDTO); + if (success) { + result.success("保存成功!"); + } else { + result.error500("保存失败"); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败:" + e.getMessage()); + } + return result; + } + + /** + * 通过 id 删除 + * + * @param id + * @return + */ + @ApiOperation(value = "系统表配置 - 删除", notes = "系统表配置 - 删除") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + Result result = new Result<>(); + try { + sysTableConfigService.delete(Arrays.asList(id)); + result.success("删除成功!"); + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败:" + e.getMessage()); + } + return result; + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @ApiOperation(value = "系统表配置 - 批量删除", notes = "系统表配置 - 批量删除") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + Result result = new Result<>(); + try { + int count = sysTableConfigService.delete(Arrays.asList(ids.split(","))); + result.success("删除成功,共删除" + count + "条记录"); + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败:" + e.getMessage()); + } + return result; + } + + /** + * 根据组织 ID 删除所有配置 + * + * @param organizationId 组织 ID + * @return + */ + @ApiOperation(value = "系统表配置 - 根据组织 ID 删除所有配置", notes = "系统表配置 - 根据组织 ID 删除所有配置") + @DeleteMapping(value = "/deleteByOrgId") + public Result deleteByOrgId(@RequestParam(name="organizationId",required=true) Long organizationId) { + Result result = new Result<>(); + try { + int count = sysTableConfigService.deleteByOrgId(organizationId); + result.success("删除成功,共删除" + count + "条记录"); + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("操作失败:" + e.getMessage()); + } + return result; + } + + /** + * 通过 id 查询 + * + * @param id + * @return + */ + @ApiOperation(value = "系统表配置 - 通过 id 查询", notes = "系统表配置 - 通过 id 查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + SysTableConfig config = sysTableConfigService.getById(id); + if (config == null) { + return Result.error("未找到对应数据"); + } + return Result.ok(config); + } + +} \ No newline at end of file diff --git a/mhd_wms/src/main/resources/mapper/sysTableConfig/SysTableConfigMapper.xml b/mhd_wms/src/main/resources/mapper/sysTableConfig/SysTableConfigMapper.xml new file mode 100644 index 000000000..3d9730950 --- /dev/null +++ b/mhd_wms/src/main/resources/mapper/sysTableConfig/SysTableConfigMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + AND a.organization_id = #{organizationId} + + + AND a.key LIKE CONCAT('%', #{key}, '%') + + + + \ No newline at end of file