mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-12 13:43:49 +08:00
优化:字典选择组件支持多选
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package net.lab1024.sa.admin.module.business.goods.domain.form;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@@ -32,6 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
||||
private Integer goodsStatus;
|
||||
|
||||
@Schema(description = "产地")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "上架状态")
|
||||
|
||||
@@ -199,7 +199,7 @@ public class GoodsService {
|
||||
GoodsExcelVO.builder()
|
||||
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
||||
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
|
||||
.place(dictCacheService.selectValueNameByValueCode(e.getPlace()))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(code)).collect(Collectors.joining(",")))
|
||||
.price(e.getPrice())
|
||||
.goodsName(e.getGoodsName())
|
||||
.remark(e.getRemark())
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
INSTR(goods_name,#{query.searchWord})
|
||||
</if>
|
||||
<if test="query.place != null">
|
||||
AND place = #{query.place}
|
||||
AND INSTR(place,#{query.place})
|
||||
</if>
|
||||
<if test="query.goodsStatus != null">
|
||||
AND goods_status = #{query.goodsStatus}
|
||||
|
||||
@@ -28,19 +28,19 @@ public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
||||
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||
List<DictValueVO> list = new ArrayList<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
||||
String deserialize = "";
|
||||
try {
|
||||
if (listOrObjectNode.isArray()) {
|
||||
for (JsonNode node : listOrObjectNode) {
|
||||
list.add(objectCodec.treeToValue(node, DictValueVO.class));
|
||||
list.add(node.asText());
|
||||
}
|
||||
} else {
|
||||
list.add(objectCodec.treeToValue(listOrObjectNode, DictValueVO.class));
|
||||
list.add(listOrObjectNode.asText());
|
||||
}
|
||||
deserialize = list.stream().map(DictValueVO::getValueCode).collect(Collectors.joining(","));
|
||||
deserialize = String.join(",", list);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
deserialize = listOrObjectNode.asText();
|
||||
|
||||
Reference in New Issue
Block a user