仓储动态表单;
This commit is contained in:
@@ -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;
|
||||
}
|
||||
+57
@@ -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<SysTableConfig> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询配置列表
|
||||
* @param page 分页对象
|
||||
* @param sysTableConfigDTO 查询条件
|
||||
* @return 配置列表
|
||||
*/
|
||||
Page<SysTableConfigVO> queryList(Page<SysTableConfigVO> page, SysTableConfigDTO sysTableConfigDTO);
|
||||
|
||||
/**
|
||||
* 根据组织 ID 和键查询配置
|
||||
* @param organizationId 组织 ID
|
||||
* @param key 配置键
|
||||
* @return 配置信息
|
||||
*/
|
||||
SysTableConfig getByOrgIdAndKey(Long organizationId, String key);
|
||||
|
||||
/**
|
||||
* 根据组织 ID 查询所有配置
|
||||
* @param organizationId 组织 ID
|
||||
* @return 配置列表
|
||||
*/
|
||||
List<SysTableConfig> listByOrgId(Long organizationId);
|
||||
|
||||
/**
|
||||
* 保存或更新配置(根据组织 ID 和键判断是新增还是更新)
|
||||
* @param sysTableConfigDTO 配置信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveOrUpdateConfig(SysTableConfigDTO sysTableConfigDTO);
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
* @param ids 主键 ID 列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
int delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据组织 ID 删除所有配置
|
||||
* @param organizationId 组织 ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
int deleteByOrgId(Long organizationId);
|
||||
}
|
||||
+47
@@ -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<SysTableConfig> {
|
||||
|
||||
/**
|
||||
* 根据组织 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<SysTableConfig> listByOrgId(@Param("organizationId") Long organizationId);
|
||||
|
||||
/**
|
||||
* 分页查询配置列表
|
||||
* @param page 分页对象
|
||||
* @param organizationId 组织 ID
|
||||
* @param key 配置键(可选)
|
||||
* @return 配置列表
|
||||
*/
|
||||
List<SysTableConfigVO> queryList(Page<SysTableConfigVO> page,
|
||||
@Param("organizationId") Long organizationId,
|
||||
@Param("key") String key);
|
||||
}
|
||||
+140
@@ -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<SysTableConfigMapper, SysTableConfig> implements ISysTableConfigService {
|
||||
|
||||
|
||||
@Resource
|
||||
private SysTableConfigMapper sysTableConfigMapper;
|
||||
|
||||
@Override
|
||||
public Page<SysTableConfigVO> queryList(Page<SysTableConfigVO> 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<SysTableConfigVO> 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<SysTableConfig> 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<String> 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<SysTableConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysTableConfig::getOrganizationId, organizationId);
|
||||
|
||||
return this.remove(queryWrapper) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
+61
@@ -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;
|
||||
}
|
||||
+62
@@ -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;
|
||||
}
|
||||
+62
@@ -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;
|
||||
}
|
||||
+204
@@ -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<IPage<SysTableConfigVO>> result = new Result<>();
|
||||
Page<SysTableConfigVO> 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<SysTableConfig> 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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.mhd.wms.domain.sysTableConfig.repository.mapper.SysTableConfigMapper">
|
||||
|
||||
<!-- 分页查询配置列表 -->
|
||||
<select id="queryList" parameterType="java.lang.String" resultType="com.mhd.wms.domain.sysTableConfig.repository.vo.SysTableConfigVO">
|
||||
SELECT
|
||||
a.id,
|
||||
a.create_by AS createBy,
|
||||
a.create_time AS createTime,
|
||||
a.update_by AS updateBy,
|
||||
a.update_time AS updateTime,
|
||||
a.organization_id AS organizationId,
|
||||
a.key AS key,
|
||||
a.value AS value,
|
||||
a.remark AS remark
|
||||
FROM sys_table_config a
|
||||
WHERE 1=1
|
||||
<include refid="common_where"></include>
|
||||
ORDER BY a.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 公共查询条件 -->
|
||||
<sql id="common_where">
|
||||
<if test="organizationId != null">
|
||||
AND a.organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="key != null and key != ''">
|
||||
AND a.key LIKE CONCAT('%', #{key}, '%')
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user