Merge remote-tracking branch 'refs/remotes/origin/dev' into nanguangmall
This commit is contained in:
+2
@@ -1,5 +1,6 @@
|
||||
package com.linke.transport.application.service.warehouse.material.command;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
@@ -25,6 +26,7 @@ public class CreateMaterialCommand {
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "物料型号")
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
|
||||
@NotBlank(message = "物料单位不能为空")
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.linke.transport.application.service.warehouse.material.command;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
@@ -24,6 +25,7 @@ public class UpdateMaterialCommand {
|
||||
@ApiModelProperty(value = "物料名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "物料型号")
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
@ApiModelProperty(value = "物料单位")
|
||||
private String unit;
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.linke.transport.application.service.warehouse.material.query;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -17,6 +18,7 @@ public class MaterialQueryCommand {
|
||||
@ApiModelProperty(name = "名称")
|
||||
private String name;
|
||||
@ApiModelProperty(name = "型号")
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
@ApiModelProperty("物料编码")
|
||||
private String materialCode;
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.linke.transport.application.service.warehouse.material.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
@@ -24,6 +25,7 @@ public class MaterialVO{
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
@ApiModelProperty("型号")
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
@ApiModelProperty("单位")
|
||||
private String unit;
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package com.linke.transport.domain.warehouse.material.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.linke.transport.domain.warehouse.material.MaterialCodeGenerator;
|
||||
import com.linke.transport.domain.warehouse.material.exception.MaterialDomainException;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
@@ -20,8 +21,10 @@ public class Material {
|
||||
private Long ownerId;
|
||||
private String category;
|
||||
private String name;
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
private String unit;
|
||||
@TableField("\"VALUE\"") // 字段名转义
|
||||
private BigDecimal value;
|
||||
private boolean codeManaged;
|
||||
private String remark;
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.linke.transport.infrastructure.config;
|
||||
|
||||
import com.linke.transport.infrastructure.util.CamelCaseUtils;
|
||||
import org.apache.ibatis.executor.resultset.ResultSetHandler;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* MyBatis插件:拦截Map类型结果,转换Key为驼峰
|
||||
*/
|
||||
@Intercepts({@Signature(
|
||||
type = ResultSetHandler.class,
|
||||
method = "handleResultSets",
|
||||
args = {Statement.class}
|
||||
)})
|
||||
@Component
|
||||
public class CamelCaseMapPlugin implements Interceptor {
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
// 执行原方法获取结果
|
||||
Object result = invocation.proceed();
|
||||
// 处理结果:如果是List且元素是Map,转换Key
|
||||
if (result instanceof List<?>) {
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) result;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object item = list.get(i);
|
||||
if (item instanceof Map<?, ?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String, Object>) item;
|
||||
// 转换Key为驼峰
|
||||
list.set(i, CamelCaseUtils.convertMapKeyToCamel(map));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
// 只拦截ResultSetHandler类型
|
||||
if (target instanceof ResultSetHandler) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
// 可配置参数,此处无需处理
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.linke.transport.infrastructure.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字符串工具类扩展:下划线/大写转驼峰
|
||||
*/
|
||||
public class CamelCaseUtils {
|
||||
|
||||
/**
|
||||
* 大写下划线转驼峰(如:USER_NAME → userName)
|
||||
*/
|
||||
public static String toCamelCase(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return str;
|
||||
}
|
||||
// 先转小写,再处理下划线
|
||||
str = str.toLowerCase();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean nextUpperCase = false;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c == '_') {
|
||||
nextUpperCase = true;
|
||||
} else {
|
||||
if (nextUpperCase) {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
nextUpperCase = false;
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量转换Map的Key为驼峰
|
||||
*/
|
||||
public static <V> Map<String, V> convertMapKeyToCamel(Map<String, V> map) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
Map<String, V> newMap = new HashMap<>(map.size());
|
||||
for (Map.Entry<String, V> entry : map.entrySet()) {
|
||||
String camelKey = toCamelCase(entry.getKey());
|
||||
newMap.put(camelKey, entry.getValue());
|
||||
}
|
||||
return newMap;
|
||||
}
|
||||
}
|
||||
+1
@@ -21,6 +21,7 @@ public class MaterialDO {
|
||||
private Long ownerId;
|
||||
private String category;
|
||||
private String name;
|
||||
@TableField("\"MODEL\"") // 字段名转义
|
||||
private String model;
|
||||
private String unit;
|
||||
private BigDecimal value;
|
||||
|
||||
@@ -18,13 +18,15 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置使用ip+端口号
|
||||
#server-addr: 10.33.0.129:6000
|
||||
# server-addr: 10.33.0.129:6010r
|
||||
server-addr: 10.33.0.129:6010
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置使用ip+端口号
|
||||
#server-addr: 10.33.0.129:6000
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.33.0.129:6010
|
||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||
file-extension: yml #默认properties
|
||||
# 共享配置
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
i.material_id,
|
||||
m.category AS material_category,
|
||||
m.name AS material_name,
|
||||
m.model AS material_model,
|
||||
m."MODEL" AS material_model,
|
||||
i.quantity,
|
||||
m.unit,
|
||||
m.weight,
|
||||
m.code_managed,
|
||||
m.value,
|
||||
m."VALUE",
|
||||
i.machine_serial_no,
|
||||
i.created_at
|
||||
FROM
|
||||
@@ -91,7 +91,7 @@
|
||||
i.material_id,
|
||||
m.category AS material_category,
|
||||
m.name AS material_name,
|
||||
m.model AS material_model,
|
||||
m."MODEL" AS material_model,
|
||||
i.quantity,
|
||||
m.unit,
|
||||
m.weight,
|
||||
|
||||
Reference in New Issue
Block a user