提交 0a1c16a2 authored 作者: 吴德鹏's avatar 吴德鹏

属性管理

上级 2f13ad95
package com.platform.controller;
import com.platform.annotation.IgnoreAuth;
import com.platform.entity.AttributesDescEntity;
import com.platform.entity.AttributesEntity;
import com.platform.entity.TbCfItemParamEntity;
import com.platform.entity.TbCfStationItemEntity;
import com.platform.service.AttributesDescService;
import com.platform.service.AttributesService;
import com.platform.service.TbCfItemParamService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.utils.util.StringUtil;
import com.platform.vo.AttributesExtends;
import com.platform.vo.AttributesVo;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -36,6 +39,8 @@ public class AttributesController {
private AttributesService attributesService;
@Autowired
private TbCfItemParamService itemParamService;
@Autowired
private AttributesDescService attributesDescService;
/**
......@@ -48,10 +53,16 @@ public class AttributesController {
//查询列表数据
Query query = new Query(params);
List<AttributesEntity> list = new ArrayList<>();
List<AttributesEntity> attributesList = attributesService.queryList(query);
attributesList.forEach(attr -> {
List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(attr.getId());
attr.setDescs(descs);
list.add(attr);
});
int total = attributesService.queryTotal(query);
PageUtils pageUtil = new PageUtils(attributesList, total, query.getLimit(), query.getPage());
PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
......@@ -64,7 +75,8 @@ public class AttributesController {
@ResponseBody
public R info(@PathVariable("id") String id) {
AttributesEntity attributes = attributesService.queryObject(id);
List<AttributesDescEntity> desc = attributesDescService.queryByAttrId(attributes.getId());
attributes.setDescs(desc);
return R.ok().put("attributes", attributes);
}
......@@ -74,7 +86,7 @@ public class AttributesController {
@RequestMapping("/save")
@RequiresPermissions("attributes:save")
@ResponseBody
public R save(@RequestBody AttributesEntity attributes) {
public R save(@RequestBody AttributesExtends attributes) {
attributesService.save(attributes);
return R.ok();
......@@ -86,7 +98,7 @@ public class AttributesController {
@RequestMapping("/update")
@RequiresPermissions("attributes:update")
@ResponseBody
public R update(@RequestBody AttributesEntity attributes) {
public R update(@RequestBody AttributesExtends attributes) {
attributesService.update(attributes);
return R.ok();
......@@ -143,31 +155,31 @@ public class AttributesController {
* @param attrDesc 搜索关键字 如(l)
* @return url(../attributes/queryAttrDescs?id=2&attrDesc=l)
*/
@RequestMapping("/queryAttrDescs")
@ResponseBody
@IgnoreAuth
public R queryAttrDescs(@RequestParam("id") String id,
@RequestParam(value = "attrDesc", required = false) String attrDesc) {
if (StringUtils.isBlank(id)) {
return R.error("id不能为空!");
}
AttributesEntity attributes = attributesService.queryObject(id);
List<String> list = new ArrayList<>();
if (attributes != null) {
String[] descs = attributes.getAttrDesc().split(",");
list = Arrays.asList(descs);
list = list.stream().sorted(String::compareTo).collect(Collectors.toList());
}
if (attrDesc != null && list.size() > 0 && list != null) {
/*for (String attr : list) {
if (attr.indexOf(attrDesc) <= -1)
list.remove(attr);
}*/
list = list.stream().filter(attr -> attr.indexOf(attrDesc) > -1).collect(Collectors.toList());
}
return R.ok().put("list", list);
}
// @RequestMapping("/queryAttrDescs")
// @ResponseBody
// @IgnoreAuth
// public R queryAttrDescs(@RequestParam("id") String id,
// @RequestParam(value = "attrDesc", required = false) String attrDesc) {
// if (StringUtils.isBlank(id)) {
// return R.error("id不能为空!");
// }
// AttributesEntity attributes = attributesService.queryObject(id);
// List<String> list = new ArrayList<>();
// if (attributes != null) {
// String[] descs = attributes.getAttrDesc().split(",");
// list = Arrays.asList(descs);
// list = list.stream().sorted(String::compareTo).collect(Collectors.toList());
// }
//
// if (attrDesc != null && list.size() > 0 && list != null) {
// /*for (String attr : list) {
// if (attr.indexOf(attrDesc) <= -1)
// list.remove(attr);
// }*/
// list = list.stream().filter(attr -> attr.indexOf(attrDesc) > -1).collect(Collectors.toList());
// }
// return R.ok().put("list", list);
// }
/**
* 新版商品属性(整合旧版数据)
......
package com.platform.controller;
import com.platform.entity.AttributesDescEntity;
import com.platform.service.AttributesDescService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author lipengjun
* @date 2020-12-23 11:00:57
*/
@Controller
@RequestMapping("attributesdesc")
public class AttributesDescController {
@Autowired
private AttributesDescService attributesDescService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("attributesdesc:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<AttributesDescEntity> attributesDescList = attributesDescService.queryList(query);
int total = attributesDescService.queryTotal(query);
PageUtils pageUtil = new PageUtils(attributesDescList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{attrDescId}")
@RequiresPermissions("attributesdesc:info")
@ResponseBody
public R info(@PathVariable("attrDescId") String attrDescId) {
AttributesDescEntity attributesDesc = attributesDescService.queryObject(attrDescId);
return R.ok().put("attributesDesc", attributesDesc);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("attributesdesc:save")
@ResponseBody
public R save(@RequestBody AttributesDescEntity attributesDesc) {
attributesDescService.save(attributesDesc);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("attributesdesc:update")
@ResponseBody
public R update(@RequestBody AttributesDescEntity attributesDesc) {
attributesDescService.update(attributesDesc);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("attributesdesc:delete")
@ResponseBody
public R delete(@RequestBody String[] attrDescIds) {
attributesDescService.deleteBatch(attrDescIds);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<AttributesDescEntity> list = attributesDescService.queryList(params);
return R.ok().put("list", list);
}
}
package com.platform.dao;
import com.platform.entity.AttributesEntity;
import com.platform.vo.AttributesExtends;
import java.util.List;
import java.util.Map;
/**
* Dao
......@@ -10,4 +14,6 @@ import com.platform.entity.AttributesEntity;
*/
public interface AttributesDao extends BaseDao<AttributesEntity> {
List<AttributesExtends> queryAttributesList(Map<String, Object> map);
}
package com.platform.dao;
import com.platform.entity.AttributesDescEntity;
import java.util.List;
/**
* Dao
*
* @author lipengjun
* @date 2020-12-23 11:00:57
*/
public interface AttributesDescDao extends BaseDao<AttributesDescEntity> {
List<AttributesDescEntity> queryByAttrId(String id);
}
package com.platform.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 attributes_desc
*
* @author lipengjun
* @date 2020-12-23 11:00:57
*/
public class AttributesDescEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 属性描述ID
*/
private String attrDescId;
/**
* 属性ID
*/
private String attrId;
/**
* 属性值
*/
private String attrValue;
/**
* 属性描述(中文)
*/
private String attrDesc;
/**
* 状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 设置:属性描述ID
*/
public void setAttrDescId(String attrDescId) {
this.attrDescId = attrDescId;
}
/**
* 获取:属性描述ID
*/
public String getAttrDescId() {
return attrDescId;
}
/**
* 设置:属性ID
*/
public void setAttrId(String attrId) {
this.attrId = attrId;
}
/**
* 获取:属性ID
*/
public String getAttrId() {
return attrId;
}
/**
* 设置:属性值
*/
public void setAttrValue(String attrValue) {
this.attrValue = attrValue;
}
/**
* 获取:属性值
*/
public String getAttrValue() {
return attrValue;
}
/**
* 设置:属性描述(中文)
*/
public void setAttrDesc(String attrDesc) {
this.attrDesc = attrDesc;
}
/**
* 获取:属性描述(中文)
*/
public String getAttrDesc() {
return attrDesc;
}
/**
* 设置:状态
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* 获取:状态
*/
public Integer getStatus() {
return status;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:更新时间
*/
public Date getUpdateTime() {
return updateTime;
}
}
package com.platform.entity;
import org.hibernate.validator.constraints.EAN;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 实体
......@@ -21,10 +24,7 @@ public class AttributesEntity implements Serializable {
* 属性名
*/
private String attrName;
/**
* 属性描述
*/
private String attrDesc;
/**
* 状态 0:隐藏 1:正常
*/
......@@ -46,6 +46,19 @@ public class AttributesEntity implements Serializable {
*/
private Date updateTime;
public List<AttributesDescEntity> getDescs() {
return descs;
}
public void setDescs(List<AttributesDescEntity> descs) {
this.descs = descs;
}
private List<AttributesDescEntity> descs;
/**
* 设置:商品属性ID
*/
......@@ -72,19 +85,7 @@ public class AttributesEntity implements Serializable {
public String getAttrName() {
return attrName;
}
/**
* 设置:属性描述
*/
public void setAttrDesc(String attrDesc) {
this.attrDesc = attrDesc;
}
/**
* 获取:属性描述
*/
public String getAttrDesc() {
return attrDesc;
}
/**
* 设置:状态 0:隐藏 1:正常
*/
......
package com.platform.service;
import com.platform.entity.AttributesDescEntity;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2020-12-23 11:00:57
*/
public interface AttributesDescService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
AttributesDescEntity queryObject(String attrDescId);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<AttributesDescEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param attributesDesc 实体
* @return 保存条数
*/
int save(AttributesDescEntity attributesDesc);
/**
* 根据主键更新实体
*
* @param attributesDesc 实体
* @return 更新条数
*/
int update(AttributesDescEntity attributesDesc);
/**
* 根据主键删除
*
* @param attrDescId
* @return 删除条数
*/
int delete(String attrDescId);
/**
* 根据主键批量删除
*
* @param attrDescIds
* @return 删除条数
*/
int deleteBatch(String[] attrDescIds);
List<AttributesDescEntity> queryByAttrId(String id);
}
package com.platform.service;
import com.platform.entity.AttributesEntity;
import com.platform.vo.AttributesExtends;
import java.util.List;
import java.util.Map;
......@@ -43,7 +44,7 @@ public interface AttributesService {
* @param attributes 实体
* @return 保存条数
*/
int save(AttributesEntity attributes);
int save(AttributesExtends attributes);
/**
* 根据主键更新实体
......@@ -51,7 +52,7 @@ public interface AttributesService {
* @param attributes 实体
* @return 更新条数
*/
int update(AttributesEntity attributes);
int update(AttributesExtends attributes);
/**
* 根据主键删除
......@@ -68,4 +69,6 @@ public interface AttributesService {
* @return 删除条数
*/
int deleteBatch(String[] ids);
List<AttributesExtends> queryAttributesList(Map<String, Object> map);
}
package com.platform.service.impl;
import com.platform.dao.AttributesDescDao;
import com.platform.entity.AttributesDescEntity;
import com.platform.service.AttributesDescService;
import com.platform.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2020-12-23 11:00:57
*/
@Service("attributesDescService")
public class AttributesDescServiceImpl implements AttributesDescService {
@Autowired
private AttributesDescDao attributesDescDao;
@Override
public AttributesDescEntity queryObject(String attrDescId) {
return attributesDescDao.queryObject(attrDescId);
}
@Override
public List<AttributesDescEntity> queryList(Map<String, Object> map) {
return attributesDescDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return attributesDescDao.queryTotal(map);
}
@Override
public int save(AttributesDescEntity attributesDesc) {
attributesDesc.setAttrDescId(IdUtil.createIdbyUUID());
return attributesDescDao.save(attributesDesc);
}
@Override
public int update(AttributesDescEntity attributesDesc) {
return attributesDescDao.update(attributesDesc);
}
@Override
public int delete(String attrDescId) {
return attributesDescDao.delete(attrDescId);
}
@Override
public int deleteBatch(String[] attrDescIds) {
return attributesDescDao.deleteBatch(attrDescIds);
}
@Override
public List<AttributesDescEntity> queryByAttrId(String id) {
return attributesDescDao.queryByAttrId(id);
}
}
package com.platform.service.impl;
import com.platform.dao.AttributesDao;
import com.platform.dao.AttributesDescDao;
import com.platform.entity.AttributesDescEntity;
import com.platform.entity.AttributesEntity;
import com.platform.service.AttributesService;
import com.platform.utils.IdUtil;
import com.platform.vo.AttributesExtends;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -20,6 +24,8 @@ import java.util.Map;
public class AttributesServiceImpl implements AttributesService {
@Autowired
private AttributesDao attributesDao;
@Autowired
private AttributesDescDao attributesDescDao;
@Override
public AttributesEntity queryObject(String id) {
......@@ -37,14 +43,40 @@ public class AttributesServiceImpl implements AttributesService {
}
@Override
public int save(AttributesEntity attributes) {
attributes.setId(IdUtil.createIdbyUUID());
return attributesDao.save(attributes);
public int save(AttributesExtends attributes) {
//属性
String id = IdUtil.createIdbyUUID();
attributes.setId(id);
Date date = new Date();
attributes.setCreateTime(date);
attributes.setUpdateTime(date);
int res1 = attributesDao.save(attributes);
//属性描述
AttributesDescEntity descEntity = new AttributesDescEntity();
descEntity.setAttrDescId(IdUtil.createIdbyUUID());
descEntity.setAttrId(id);
descEntity.setAttrValue(attributes.getAttrValue());
descEntity.setAttrDesc(attributes.getAttrDesc());
descEntity.setStatus(1);
descEntity.setCreateTime(date);
descEntity.setUpdateTime(date);
int res2 = attributesDescDao.save(descEntity);
return (res1 > 0 && res2 > 0) ? 1 : 0;
}
@Override
public int update(AttributesEntity attributes) {
return attributesDao.update(attributes);
public int update(AttributesExtends attributes) {
Date date = new Date();
attributes.setUpdateTime(date);
int res1 = attributesDao.update(attributes);
AttributesDescEntity descEntity = attributesDescDao.queryObject(attributes.getAttrDescId());
descEntity.setAttrValue(attributes.getAttrValue());
descEntity.setAttrDesc(attributes.getAttrDesc());
descEntity.setUpdateTime(date);
int res2 = attributesDescDao.update(descEntity);
return (res1 > 0 && res2 > 0) ? 1 : 0;
}
@Override
......@@ -56,4 +88,9 @@ public class AttributesServiceImpl implements AttributesService {
public int deleteBatch(String[] ids) {
return attributesDao.deleteBatch(ids);
}
@Override
public List<AttributesExtends> queryAttributesList(Map<String, Object> map) {
return attributesDao.queryAttributesList(map);
}
}
package com.platform.vo;
import com.platform.entity.AttributesEntity;
/**
* @Auther: wudepeng
* @Date: 2020/12/23
* @Description:
*/
public class AttributesExtends extends AttributesEntity {
private String attrDescId;
private String attrValue;
private String attrDesc;
public String getAttrDescId() {
return attrDescId;
}
public void setAttrDescId(String attrDescId) {
this.attrDescId = attrDescId;
}
public String getAttrValue() {
return attrValue;
}
public void setAttrValue(String attrValue) {
this.attrValue = attrValue;
}
public String getAttrDesc() {
return attrDesc;
}
public void setAttrDesc(String attrDesc) {
this.attrDesc = attrDesc;
}
}
......@@ -3,22 +3,23 @@
<mapper namespace="com.platform.dao.AttributesDao">
<resultMap type="com.platform.entity.AttributesEntity" id="attributesMap">
<resultMap type="com.platform.vo.AttributesExtends" id="attributesMap">
<result property="id" column="id"/>
<result property="attrName" column="attr_name"/>
<result property="attrDesc" column="attr_desc"/>
<result property="status" column="status"/>
<result property="sort" column="sort"/>
<result property="isNeed" column="is_need"/>
<result property="createTime" column="create_time"/>
<result property="need" column="is_need"/>
<result property="attrDescId" column="attr_desc_id"/>
<result property="attrValue" column="attr_value"/>
<result property="attrDesc" column="attr_desc"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.AttributesEntity">
<select id="queryObject" resultType="com.platform.entity.AttributesEntity">
select
`id`,
`attr_name`,
`attr_desc`,
`status`,
`sort`,
`is_need`,
......@@ -28,47 +29,74 @@
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.AttributesEntity">
select
`id`,
`attr_name`,
`attr_desc`,
`status`,
`sort`,
`is_need`,
`create_time`,
`update_time`
from attributes
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (attr_name LIKE concat('%',#{name},'%') OR attr_desc LIKE concat('%',#{name},'%'))
</if>
<select id="queryList" resultType="com.platform.entity.AttributesEntity">
select
`id`,
`attr_name`,
`status`,
`sort`,
`create_time`,
`update_time`
from attributes
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (attr_name LIKE concat('%',#{name},'%') )
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
<otherwise>
order by sort
</otherwise>
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from attributes
WHERE 1=1
<select id="queryAttributesList" resultType="com.platform.vo.AttributesExtends">
SELECT
a.`id`,
a.`attr_name`,
a.`status`,
a.`sort`,
a.`is_need`,
d.attr_desc_id,
d.attr_value,
d.attr_desc,
a.`create_time`,
a.`update_time`
FROM attributes a LEFT join attributes_desc d on a.id=d.attr_id
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (attr_name LIKE concat('%',#{name},'%') OR attr_desc LIKE concat('%',#{name},'%'))
AND (attr_name LIKE concat('%',#{name},'%') )
</if>
</select>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by sort
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<insert id="save" parameterType="com.platform.entity.AttributesEntity">
<select id="queryTotal" resultType="int">
select count(*) from attributes
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND (attr_name LIKE concat('%',#{name},'%'))
</if>
</select>
<insert id="save" parameterType="com.platform.entity.AttributesEntity">
insert into attributes(
`id`,
`attr_name`,
`attr_desc`,
`status`,
`sort`,
`is_need`,
......@@ -77,7 +105,6 @@
values(
#{id},
#{attrName},
#{attrDesc},
#{status},
#{sort},
#{isNeed},
......@@ -85,31 +112,29 @@
#{updateTime})
</insert>
<update id="update" parameterType="com.platform.entity.AttributesEntity">
update attributes
<set>
<if test="attrName != null">`attr_name` = #{attrName}, </if>
<if test="attrDesc != null">`attr_desc` = #{attrDesc}, </if>
<if test="status != null">`status` = #{status}, </if>
<if test="sort != null">`sort` = #{sort}, </if>
<if test="isNeed != null">`is_need` = #{isNeed}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<update id="update" parameterType="com.platform.entity.AttributesEntity">
update attributes
<set>
<if test="attrName != null">`attr_name` = #{attrName},</if>
<if test="status != null">`status` = #{status},</if>
<if test="sort != null">`sort` = #{sort},</if>
<if test="isNeed != null">`is_need` = #{isNeed},</if>
<if test="createTime != null">`create_time` = #{createTime},</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
<delete id="delete">
delete from attributes where id = #{value}
</delete>
<delete id="deleteBatch">
delete from attributes where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteBatch">
delete from attributes where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.AttributesDescDao">
<resultMap type="com.platform.entity.AttributesDescEntity" id="attributesDescMap">
<result property="attrDescId" column="attr_desc_id"/>
<result property="attrId" column="attr_id"/>
<result property="attrValue" column="attr_value"/>
<result property="attrDesc" column="attr_desc"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.AttributesDescEntity">
select
`attr_desc_id`,
`attr_id`,
`attr_value`,
`attr_desc`,
`status`,
`create_time`,
`update_time`
from attributes_desc
where attr_desc_id = #{id}
</select>
<select id="queryByAttrId" resultType="com.platform.entity.AttributesDescEntity">
select
`attr_desc_id`,
`attr_id`,
`attr_value`,
`attr_desc`,
`status`,
`create_time`,
`update_time`
from attributes_desc
where attr_id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.AttributesDescEntity">
select
`attr_desc_id`,
`attr_id`,
`attr_value`,
`attr_desc`,
`status`,
`create_time`,
`update_time`
from attributes_desc
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by attr_desc_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from attributes_desc
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.AttributesDescEntity">
insert into attributes_desc(
`attr_desc_id`,
`attr_id`,
`attr_value`,
`attr_desc`,
`status`,
`create_time`,
`update_time`)
values(
#{attrDescId},
#{attrId},
#{attrValue},
#{attrDesc},
#{status},
#{createTime},
#{updateTime})
</insert>
<update id="update" parameterType="com.platform.entity.AttributesDescEntity">
update attributes_desc
<set>
<if test="attrId != null">`attr_id` = #{attrId}, </if>
<if test="attrValue != null">`attr_value` = #{attrValue}, </if>
<if test="attrDesc != null">`attr_desc` = #{attrDesc}, </if>
<if test="status != null">`status` = #{status}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where attr_desc_id = #{attrDescId}
</update>
<delete id="delete">
delete from attributes_desc where attr_desc_id = #{value}
</delete>
<delete id="deleteBatch">
delete from attributes_desc where attr_desc_id in
<foreach item="attrDescId" collection="array" open="(" separator="," close=")">
#{attrDescId}
</foreach>
</delete>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论