feat(coding): 在属性和分类实体中添加排序字段并更新服务
在属性和属性分类实体中引入排序字段,以便对它们进行有序管理。更新相关服务方法以支持排序字段的查询,确保数据能够按排序字段进行升序处理。
This commit is contained in:
parent
8daedaba75
commit
724929d92d
|
@ -37,5 +37,8 @@ public class Attribute extends BaseEntity {
|
|||
@Schema(description = "是否锁定")
|
||||
private Boolean locked;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sortNo;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,5 +25,8 @@ public class AttributeClassification extends BaseEntity {
|
|||
@Schema(description = "属性分类名称")
|
||||
private String attributeClassificationName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sortNo;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -91,11 +91,14 @@ public class AttributeClassificationService extends BaseService<AttributeClassif
|
|||
return Result.data(this.page(page, new QueryWrapper<AttributeClassification>()
|
||||
.lambda()
|
||||
.like(StrUtil.isNotBlank(vo.getAttributeClassificationName()), AttributeClassification::getAttributeClassificationName, vo.getAttributeClassificationName())
|
||||
.orderByAsc(AttributeClassification::getSortNo)
|
||||
));
|
||||
}
|
||||
|
||||
public Result<List<AttributeClassification>> getAttributeClassificationList() {
|
||||
return Result.data(this.list());
|
||||
return Result.data(this.list(new QueryWrapper<AttributeClassification>()
|
||||
.lambda()
|
||||
.orderByAsc(AttributeClassification::getSortNo)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ public class AttributeService extends BaseService<AttributeMapper, Attribute> {
|
|||
.like(StrUtil.isNotBlank(vo.getAttributeDescription()), Attribute::getAttributeDescription, vo.getAttributeDescription())
|
||||
.like(StrUtil.isNotBlank(vo.getAttributeRemarks()), Attribute::getAttributeRemarks, vo.getAttributeRemarks())
|
||||
.like(StrUtil.isNotBlank(vo.getAttributeName()), Attribute::getAttributeName, vo.getAttributeName())
|
||||
.orderByAsc(Attribute::getSortNo)
|
||||
)));
|
||||
}
|
||||
|
||||
|
@ -109,6 +110,7 @@ public class AttributeService extends BaseService<AttributeMapper, Attribute> {
|
|||
return Result.data(AttributeWrapper.INSTANCE.toDto(this.list(new QueryWrapper<Attribute>()
|
||||
.lambda()
|
||||
.eq(StrUtil.isNotBlank(attributeClassificationId), Attribute::getAttributeClassificationId, attributeClassificationId)
|
||||
.orderByAsc(Attribute::getSortNo)
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,19 @@ import cn.hutool.core.util.ObjUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.base.BaseService;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.core.util.SpringUtil;
|
||||
import cn.workde.module.drone.coding.dto.AttributeValueDto;
|
||||
import cn.workde.module.drone.coding.dto.BatchesDto;
|
||||
import cn.workde.module.drone.coding.dto.CodeDto;
|
||||
import cn.workde.module.drone.coding.entity.*;
|
||||
import cn.workde.module.drone.coding.mapper.AttributeValueMapper;
|
||||
import cn.workde.module.drone.coding.mapper.BatchesMapper;
|
||||
import cn.workde.module.drone.coding.vo.AttributeValueVo2;
|
||||
import cn.workde.module.drone.coding.vo.BatchesVo;
|
||||
import cn.workde.module.drone.coding.wrapper.BatchesWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -127,12 +130,16 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
|
|||
.like(StrUtil.isNotBlank(vo.getBatchesDescription()), Batches::getBatchesDescription, vo.getBatchesDescription())
|
||||
.eq(StrUtil.isNotBlank(vo.getMfcId()), Batches::getMfcId, vo.getMfcId())
|
||||
.eq(StrUtil.isNotBlank(vo.getRuleId()), Batches::getRuleId, vo.getRuleId())
|
||||
.orderByAsc(Batches::getCreatedAt)
|
||||
);
|
||||
return Result.data(BatchesWrapper.INSTANCE.toDto(paged));
|
||||
}
|
||||
|
||||
public Result<List<BatchesDto>> getBatchesList() {
|
||||
List<Batches> list = this.list(new QueryWrapper<Batches>());
|
||||
List<Batches> list = this.list(new QueryWrapper<Batches>()
|
||||
.lambda()
|
||||
.orderByAsc(Batches::getCreatedAt)
|
||||
);
|
||||
return Result.data(BatchesWrapper.INSTANCE.toDto(list));
|
||||
}
|
||||
|
||||
|
@ -148,6 +155,7 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
|
|||
new QueryWrapper<AttributeClassification>()
|
||||
.lambda()
|
||||
.inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'")
|
||||
.orderByAsc(AttributeClassification::getSortNo)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(attributeClassifications)) {
|
||||
List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>();
|
||||
|
@ -156,11 +164,14 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
|
|||
attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId());
|
||||
attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName());
|
||||
//获取属性值
|
||||
List<AttributeValue> attributeValues = attributeValueService.list(
|
||||
new QueryWrapper<AttributeValue>()
|
||||
.lambda()
|
||||
List<AttributeValue> attributeValues = SpringUtil.getBean(AttributeValueMapper.class).selectJoinList(
|
||||
AttributeValue.class,
|
||||
new MPJLambdaWrapper<AttributeValue>()
|
||||
.selectAll(AttributeValue.class)
|
||||
.leftJoin(Attribute.class, Attribute::getId, AttributeValue::getAttributeId)
|
||||
.eq(AttributeValue::getMfcId, mfcId)
|
||||
.eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId())
|
||||
.orderByAsc(Attribute::getSortNo)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(attributeValues)) {
|
||||
List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>();
|
||||
|
|
|
@ -265,7 +265,7 @@ public class CodeService extends BaseService<CodeMapper, Code>{
|
|||
.like(StrUtil.isNotBlank(mfcCode), Code::getMfcCode, mfcCode)
|
||||
.like(StrUtil.isNotBlank(ruleCode), Code::getRuleCode, ruleCode)
|
||||
.like(StrUtil.isNotBlank(snCode), Code::getSnCode, snCode)
|
||||
.orderByDesc(Code::getCreatedAt)
|
||||
.orderByAsc(Code::getCode)
|
||||
);
|
||||
return Result.data(CodeWrapper.INSTANCE.toDto(paged));
|
||||
}
|
||||
|
|
|
@ -6,15 +6,18 @@ import cn.hutool.core.util.ObjUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.workde.core.base.BaseService;
|
||||
import cn.workde.core.data.dto.Result;
|
||||
import cn.workde.core.util.SpringUtil;
|
||||
import cn.workde.module.drone.coding.dto.AttributeClassificationDto;
|
||||
import cn.workde.module.drone.coding.dto.AttributeValueDto;
|
||||
import cn.workde.module.drone.coding.entity.*;
|
||||
import cn.workde.module.drone.coding.mapper.AttributeValueMapper;
|
||||
import cn.workde.module.drone.coding.mapper.MfcMapper;
|
||||
import cn.workde.module.drone.coding.vo.AttributeValueVo;
|
||||
import cn.workde.module.drone.coding.vo.AttributeValueVo2;
|
||||
import cn.workde.module.drone.coding.vo.MfcVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -123,24 +126,32 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
|
|||
}
|
||||
|
||||
public Result<Page<Mfc>> getMfcPageList(Page page, MfcVo vo) {
|
||||
Page paged = this.page(page, new QueryWrapper<Mfc>()
|
||||
Page<Mfc> paged = this.page(page, new QueryWrapper<Mfc>()
|
||||
.lambda()
|
||||
.like(StrUtil.isNotBlank(vo.getMfcCode()), Mfc::getMfcCode, vo.getMfcCode())
|
||||
.like(StrUtil.isNotBlank(vo.getMfcName()), Mfc::getMfcName, vo.getMfcName())
|
||||
.like(StrUtil.isNotBlank(vo.getMfcDescription()), Mfc::getMfcDescription, vo.getMfcDescription())
|
||||
.orderByAsc(Mfc::getCreatedAt)
|
||||
);
|
||||
return Result.data(paged);
|
||||
}
|
||||
|
||||
public Result<List<Mfc>> getMfcList() {
|
||||
List<Mfc> list = this.list();
|
||||
List<Mfc> list = this.list(new QueryWrapper<Mfc>()
|
||||
.lambda()
|
||||
.orderByAsc(Mfc::getCreatedAt)
|
||||
);
|
||||
return Result.data(list);
|
||||
}
|
||||
|
||||
|
||||
public Result<List<AttributeClassificationDto>> getAttributeOptions() {
|
||||
//获取所有属性分类
|
||||
List<AttributeClassification> attributeClassificationList = attributeClassificationService.list();
|
||||
List<AttributeClassification> attributeClassificationList = attributeClassificationService.list(
|
||||
new QueryWrapper<AttributeClassification>()
|
||||
.lambda()
|
||||
.orderByAsc(AttributeClassification::getSortNo)
|
||||
);
|
||||
if (ObjUtil.isNotNull(attributeClassificationList)) {
|
||||
List<AttributeClassificationDto> attributeClassificationDtoList = new ArrayList<AttributeClassificationDto>();
|
||||
attributeClassificationList.forEach(attributeClassification -> {
|
||||
|
@ -150,6 +161,7 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
|
|||
List<Attribute> attributeList = attributeService.list(new QueryWrapper<Attribute>()
|
||||
.lambda()
|
||||
.eq(Attribute::getAttributeClassificationId, attributeClassification.getId())
|
||||
.orderByAsc(Attribute::getSortNo)
|
||||
);
|
||||
attributeClassificationDto.setAttributeList(attributeList);
|
||||
attributeClassificationDtoList.add(attributeClassificationDto);
|
||||
|
@ -245,6 +257,7 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
|
|||
new QueryWrapper<AttributeClassification>()
|
||||
.lambda()
|
||||
.inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'")
|
||||
.orderByAsc(AttributeClassification::getSortNo)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(attributeClassifications)) {
|
||||
List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>();
|
||||
|
@ -253,11 +266,14 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
|
|||
attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId());
|
||||
attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName());
|
||||
//获取属性值
|
||||
List<AttributeValue> attributeValues = attributeValueService.list(
|
||||
new QueryWrapper<AttributeValue>()
|
||||
.lambda()
|
||||
List<AttributeValue> attributeValues = SpringUtil.getBean(AttributeValueMapper.class).selectJoinList(
|
||||
AttributeValue.class,
|
||||
new MPJLambdaWrapper<AttributeValue>()
|
||||
.selectAll(AttributeValue.class)
|
||||
.leftJoin(Attribute.class, Attribute::getId, AttributeValue::getAttributeId)
|
||||
.eq(AttributeValue::getMfcId, mfcId)
|
||||
.eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId())
|
||||
.orderByAsc(Attribute::getSortNo)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(attributeValues)) {
|
||||
List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>();
|
||||
|
|
|
@ -123,12 +123,15 @@ public class RuleService extends BaseService<RuleMapper, Rule> {
|
|||
.like(StrUtil.isNotBlank(vo.getRuleCode()), Rule::getRuleCode, vo.getRuleCode())
|
||||
.like(StrUtil.isNotBlank(vo.getRuleName()), Rule::getRuleName, vo.getRuleName())
|
||||
.like(StrUtil.isNotBlank(vo.getRuleDescription()), Rule::getRuleDescription, vo.getRuleDescription())
|
||||
.orderByAsc(Rule::getCreatedAt)
|
||||
);
|
||||
return Result.data(paged);
|
||||
}
|
||||
|
||||
public Result<List<Rule>> getRuleList() {
|
||||
List<Rule> list = this.list(new QueryWrapper<Rule>()
|
||||
.lambda()
|
||||
.orderByAsc(Rule::getCreatedAt)
|
||||
);
|
||||
return Result.data(list);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.workde.module.drone.coding.vo;
|
|||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
@ -10,4 +11,8 @@ public class AttributeClassificationVo {
|
|||
@Schema(description = "属性分类名称")
|
||||
@NotBlank(message = "属性分类名称不能为空")
|
||||
private String attributeClassificationName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sortNo;
|
||||
}
|
||||
|
|
|
@ -26,4 +26,8 @@ public class AttributeVo {
|
|||
@Schema(description = "是否锁定")
|
||||
@NotNull(message = "请选择是否锁定")
|
||||
private Boolean locked;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "请输入排序")
|
||||
private Integer sortNo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue