修改供应商管理接口
This commit is contained in:
parent
66f89161b8
commit
121fda4454
|
|
@ -59,24 +59,26 @@ public class QmsSupplierSqeController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用供应商-用户关联关系
|
||||
* 启用/禁用供应商所有关联关系
|
||||
*
|
||||
* @param request id=供应商ID,enable=启用/禁用
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("enable")
|
||||
public ApiResult<Void> enable(@Valid @RequestBody EnableQO request) {
|
||||
supplierSqeMapService.enable(request.getId(), request.getEnable());
|
||||
supplierSqeMapService.enableBySupplierId(request.getId(), request.getEnable());
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除供应商-用户关联关系(启用状态下不允许删除)
|
||||
* 删除供应商所有关联关系(启用状态下不允许删除)
|
||||
*
|
||||
* @param id 关联记录ID
|
||||
* @param supplierId 供应商ID
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@NotNull Long id) {
|
||||
supplierSqeMapService.deleteById(id);
|
||||
public ApiResult<Void> delete(@NotNull Long supplierId) {
|
||||
supplierSqeMapService.deleteBySupplierId(supplierId);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,12 @@ package com.nflg.wms.common.pojo.vo;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 供应商-用户 关联记录 VO(以关联表为主体,每行一条关联记录)
|
||||
* 供应商-用户 关联 VO(按供应商聚合,每行一个供应商)
|
||||
*/
|
||||
@Data
|
||||
public class QmsSupplierSqeMapVO {
|
||||
|
||||
/**
|
||||
* 关联记录ID(qms_supplier_sqe_map.id)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
|
|
@ -31,47 +24,12 @@ public class QmsSupplierSqeMapVO {
|
|||
private String supplierName;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
* SQE用户名称(多个用逗号分隔)
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户工号
|
||||
*/
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 职位名称
|
||||
*/
|
||||
private String positionName;
|
||||
|
||||
/**
|
||||
* 启用状态:true=启用,false=禁用
|
||||
* 统一启用状态:所有关联记录均启用时为true,否则为false
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ public interface IQmsSupplierSqeMapService extends IService<QmsSupplierSqeMap> {
|
|||
void setUser(Long supplierId, List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 启用/禁用单条供应商-用户关联
|
||||
* 按供应商ID启用/禁用该供应商所有关联记录
|
||||
*/
|
||||
void enable(Long id, Boolean enable);
|
||||
void enableBySupplierId(Long supplierId, Boolean enable);
|
||||
|
||||
/**
|
||||
* 删除单条供应商-用户关联(启用状态下不允许删除)
|
||||
* 按供应商ID删除该供应商所有关联记录(启用状态下不允许删除)
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
void deleteBySupplierId(Long supplierId);
|
||||
|
||||
/**
|
||||
* 按 userId 查询该用户关联的供应商列表(支持供应商过滤,分页)
|
||||
|
|
|
|||
|
|
@ -99,13 +99,15 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public void enable(Long id, Boolean enable) {
|
||||
QmsSupplierSqeMap record = getById(id);
|
||||
if (Objects.isNull(record)) {
|
||||
throw new NflgException(STATE.BusinessError, "关联记录不存在");
|
||||
public void enableBySupplierId(Long supplierId, Boolean enable) {
|
||||
boolean exists = lambdaQuery()
|
||||
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||
.exists();
|
||||
if (!exists) {
|
||||
throw new NflgException(STATE.BusinessError, "该供应商无关联记录");
|
||||
}
|
||||
lambdaUpdate()
|
||||
.eq(QmsSupplierSqeMap::getId, id)
|
||||
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||
.set(QmsSupplierSqeMap::getEnable, enable)
|
||||
.set(QmsSupplierSqeMap::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsSupplierSqeMap::getUpdateTime, LocalDateTime.now())
|
||||
|
|
@ -114,15 +116,17 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
QmsSupplierSqeMap record = getById(id);
|
||||
if (Objects.isNull(record)) {
|
||||
throw new NflgException(STATE.BusinessError, "关联记录不存在");
|
||||
public void deleteBySupplierId(Long supplierId) {
|
||||
boolean hasEnabled = lambdaQuery()
|
||||
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||
.eq(QmsSupplierSqeMap::getEnable, true)
|
||||
.exists();
|
||||
if (hasEnabled) {
|
||||
throw new NflgException(STATE.BusinessError, "该供应商关联关系处于启用状态,不允许删除,请先禁用后再删除");
|
||||
}
|
||||
if (Boolean.TRUE.equals(record.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "关联关系处于启用状态,不允许删除,请先禁用后再删除");
|
||||
}
|
||||
removeById(id);
|
||||
lambdaUpdate()
|
||||
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||
.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
qssm.supplier_id,
|
||||
us.supplier_code,
|
||||
us.supplier_name,
|
||||
STRING_AGG(DISTINCT u.user_name, ',' ORDER BY u.user_name) AS user_name
|
||||
STRING_AGG(DISTINCT u.user_name, ',' ORDER BY u.user_name) AS user_name,
|
||||
BOOL_AND(qssm.enable) AS enable
|
||||
FROM qms_supplier_sqe_map qssm
|
||||
LEFT JOIN user_supplier us ON us.id = qssm.supplier_id
|
||||
LEFT JOIN "user" u ON u.id = qssm.user_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue