完善商品属性接口,支持新增、删除和查询

This commit is contained in:
季圣华 2022-08-30 00:40:48 +08:00
parent 52bd683c7b
commit 654a246d84
10 changed files with 31 additions and 139 deletions

View File

@ -437,7 +437,6 @@ INSERT INTO `jsh_material` VALUES ('619', null, '衣服', null, null, null, null
DROP TABLE IF EXISTS `jsh_material_attribute`;
CREATE TABLE `jsh_material_attribute` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`attribute_field` varchar(50) DEFAULT NULL COMMENT '属性字段',
`attribute_name` varchar(50) DEFAULT NULL COMMENT '属性名',
`attribute_value` varchar(500) DEFAULT NULL COMMENT '属性值',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户id',
@ -448,11 +447,11 @@ CREATE TABLE `jsh_material_attribute` (
-- ----------------------------
-- Records of jsh_material_attribute
-- ----------------------------
INSERT INTO `jsh_material_attribute` VALUES ('1', 'manyColor', '多颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('2', 'manySize', '多尺寸', 'S|M|L|XL|XXL|XXXL', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('3', 'other1', '自定义1', '小米|华为', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('4', 'other2', '自定义2', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('5', 'other3', '自定义3', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('1', '多颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('2', '多尺寸', 'S|M|L|XL|XXL|XXXL', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('3', '自定义1', '小米|华为', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('4', '自定义2', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('5', '自定义3', null, '63', '0');
-- ----------------------------
-- Table structure for jsh_material_category

View File

@ -1392,4 +1392,11 @@ alter table jsh_person add sort varchar(10) DEFAULT NULL COMMENT '排序' after
update jsh_person set enabled=1;
alter table jsh_role add enabled bit(1) DEFAULT NULL COMMENT '启用' after description;
alter table jsh_role add sort varchar(10) DEFAULT NULL COMMENT '排序' after enabled;
update jsh_role set enabled=1;
update jsh_role set enabled=1;
-- --------------------------------------------------------
-- 时间 2022年08月30日
-- by jishenghua
-- 给产品属性表移除属性字段
-- --------------------------------------------------------
alter table jsh_material_attribute drop column attribute_field;

View File

@ -3,8 +3,6 @@ package com.jsh.erp.datasource.entities;
public class MaterialAttribute {
private Long id;
private String attributeField;
private String attributeName;
private String attributeValue;
@ -21,14 +19,6 @@ public class MaterialAttribute {
this.id = id;
}
public String getAttributeField() {
return attributeField;
}
public void setAttributeField(String attributeField) {
this.attributeField = attributeField == null ? null : attributeField.trim();
}
public String getAttributeName() {
return attributeName;
}

View File

@ -164,76 +164,6 @@ public class MaterialAttributeExample {
return (Criteria) this;
}
public Criteria andAttributeFieldIsNull() {
addCriterion("attribute_field is null");
return (Criteria) this;
}
public Criteria andAttributeFieldIsNotNull() {
addCriterion("attribute_field is not null");
return (Criteria) this;
}
public Criteria andAttributeFieldEqualTo(String value) {
addCriterion("attribute_field =", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldNotEqualTo(String value) {
addCriterion("attribute_field <>", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldGreaterThan(String value) {
addCriterion("attribute_field >", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldGreaterThanOrEqualTo(String value) {
addCriterion("attribute_field >=", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldLessThan(String value) {
addCriterion("attribute_field <", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldLessThanOrEqualTo(String value) {
addCriterion("attribute_field <=", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldLike(String value) {
addCriterion("attribute_field like", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldNotLike(String value) {
addCriterion("attribute_field not like", value, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldIn(List<String> values) {
addCriterion("attribute_field in", values, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldNotIn(List<String> values) {
addCriterion("attribute_field not in", values, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldBetween(String value1, String value2) {
addCriterion("attribute_field between", value1, value2, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeFieldNotBetween(String value1, String value2) {
addCriterion("attribute_field not between", value1, value2, "attributeField");
return (Criteria) this;
}
public Criteria andAttributeNameIsNull() {
addCriterion("attribute_name is null");
return (Criteria) this;

View File

@ -8,7 +8,7 @@ import java.util.List;
public interface MaterialAttributeMapperEx {
List<MaterialAttribute> selectByConditionMaterialAttribute(
@Param("attributeField") String attributeField,
@Param("attributeName") String attributeName,
@Param("offset") Integer offset,
@Param("rows") Integer rows);

View File

@ -31,8 +31,8 @@ public class MaterialAttributeComponent implements ICommonQuery {
private List<?> getMaterialList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String attributeField = StringUtil.getInfo(search, "attributeField");
return materialAttributeService.select(attributeField, QueryUtils.offset(map), QueryUtils.rows(map));
String attributeName = StringUtil.getInfo(search, "attributeName");
return materialAttributeService.select(attributeName, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override

View File

@ -49,6 +49,7 @@ public class MaterialAttributeService {
public List<MaterialAttribute> getMaterialAttribute() throws Exception{
MaterialAttributeExample example = new MaterialAttributeExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc");
List<MaterialAttribute> list=null;
try{
list=materialAttributeMapper.selectByExample(example);
@ -58,31 +59,11 @@ public class MaterialAttributeService {
return list;
}
public List<MaterialAttribute> select(String attributeField, int offset, int rows)
public List<MaterialAttribute> select(String attributeName, int offset, int rows)
throws Exception{
String[] arr = {"manyColor","manySize","other1","other2","other3"};
Map<String, String> map = new HashMap<>();
map.put("manyColor", "多颜色");
map.put("manySize", "多尺寸");
map.put("other1", "自定义1");
map.put("other2", "自定义2");
map.put("other3", "自定义3");
List<MaterialAttribute> list = new ArrayList<>();
try{
List<MaterialAttribute> maList = materialAttributeMapperEx.selectByConditionMaterialAttribute(attributeField, offset, rows);
for(String field: arr) {
MaterialAttribute materialAttribute = new MaterialAttribute();
materialAttribute.setAttributeField(field);
materialAttribute.setAttributeName(map.get(field));
for(MaterialAttribute ma: maList) {
if(field.equals(ma.getAttributeField())){
materialAttribute.setId(ma.getId());
materialAttribute.setAttributeName(ma.getAttributeName());
materialAttribute.setAttributeValue(ma.getAttributeValue());
}
}
list.add(materialAttribute);
}
list = materialAttributeMapperEx.selectByConditionMaterialAttribute(attributeName, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@ -3,7 +3,6 @@
<mapper namespace="com.jsh.erp.datasource.mappers.MaterialAttributeMapper">
<resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.MaterialAttribute">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="attribute_field" jdbcType="VARCHAR" property="attributeField" />
<result column="attribute_name" jdbcType="VARCHAR" property="attributeName" />
<result column="attribute_value" jdbcType="VARCHAR" property="attributeValue" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
@ -68,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, attribute_field, attribute_name, attribute_value, tenant_id, delete_flag
id, attribute_name, attribute_value, tenant_id, delete_flag
</sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialAttributeExample" resultMap="BaseResultMap">
select
@ -101,12 +100,10 @@
</if>
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.MaterialAttribute">
insert into jsh_material_attribute (id, attribute_field, attribute_name,
attribute_value, tenant_id, delete_flag
)
values (#{id,jdbcType=BIGINT}, #{attributeField,jdbcType=VARCHAR}, #{attributeName,jdbcType=VARCHAR},
#{attributeValue,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
)
insert into jsh_material_attribute (id, attribute_name, attribute_value,
tenant_id, delete_flag)
values (#{id,jdbcType=BIGINT}, #{attributeName,jdbcType=VARCHAR}, #{attributeValue,jdbcType=VARCHAR},
#{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialAttribute">
insert into jsh_material_attribute
@ -114,9 +111,6 @@
<if test="id != null">
id,
</if>
<if test="attributeField != null">
attribute_field,
</if>
<if test="attributeName != null">
attribute_name,
</if>
@ -134,9 +128,6 @@
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="attributeField != null">
#{attributeField,jdbcType=VARCHAR},
</if>
<if test="attributeName != null">
#{attributeName,jdbcType=VARCHAR},
</if>
@ -163,9 +154,6 @@
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.attributeField != null">
attribute_field = #{record.attributeField,jdbcType=VARCHAR},
</if>
<if test="record.attributeName != null">
attribute_name = #{record.attributeName,jdbcType=VARCHAR},
</if>
@ -186,7 +174,6 @@
<update id="updateByExample" parameterType="map">
update jsh_material_attribute
set id = #{record.id,jdbcType=BIGINT},
attribute_field = #{record.attributeField,jdbcType=VARCHAR},
attribute_name = #{record.attributeName,jdbcType=VARCHAR},
attribute_value = #{record.attributeValue,jdbcType=VARCHAR},
tenant_id = #{record.tenantId,jdbcType=BIGINT},
@ -198,9 +185,6 @@
<update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.MaterialAttribute">
update jsh_material_attribute
<set>
<if test="attributeField != null">
attribute_field = #{attributeField,jdbcType=VARCHAR},
</if>
<if test="attributeName != null">
attribute_name = #{attributeName,jdbcType=VARCHAR},
</if>
@ -218,8 +202,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.MaterialAttribute">
update jsh_material_attribute
set attribute_field = #{attributeField,jdbcType=VARCHAR},
attribute_name = #{attributeName,jdbcType=VARCHAR},
set attribute_name = #{attributeName,jdbcType=VARCHAR},
attribute_value = #{attributeValue,jdbcType=VARCHAR},
tenant_id = #{tenantId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=VARCHAR}

View File

@ -5,8 +5,9 @@
<select id="selectByConditionMaterialAttribute" resultType="com.jsh.erp.datasource.entities.MaterialAttribute">
select * from jsh_material_attribute ma
where 1=1
<if test="attributeField != null">
and ma.attribute_field = #{attributeField}
<if test="attributeName != null">
<bind name="bindAttributeName" value="'%'+attributeName+'%'"/>
and ma.attribute_name like #{bindAttributeName}
</if>
and ifnull(ma.delete_flag,'0') !='1'
order by ma.id desc
@ -18,8 +19,9 @@
<select id="countsByMaterialAttribute" resultType="java.lang.Long">
SELECT count(ma.id) from jsh_material_attribute ma
where 1=1
<if test="attributeField != null">
and ma.attribute_field = #{attributeField}
<if test="attributeName != null">
<bind name="bindAttributeName" value="'%'+attributeName+'%'"/>
and ma.attribute_name like #{bindAttributeName}
</if>
and ifnull(ma.delete_flag,'0') !='1'
</select>