标签管理增删改查
This commit is contained in:
@@ -90,6 +90,7 @@ public enum ErrorCodeEnum {
|
||||
|
||||
LABEL_GROUP_IN_USE(120001, "该标签组下存在标签,不可删除;请确保该标签组下标签数量为0后再进行删除", null),
|
||||
LABEL_GROUP_EXIST(120002, "该标签组已存在,请重新输入", null),
|
||||
LABEL_EXIST(120003, "该标签已存在,请重新输入", null),
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ public interface HyPartnerLabelMapper {
|
||||
|
||||
HyPartnerLabelDO selectByPrimaryKey(Long id);
|
||||
|
||||
List<HyPartnerLabelDO> selectSelective(HyPartnerLabelDO labelDO);
|
||||
|
||||
int updateByPrimaryKeySelective(HyPartnerLabelDO record);
|
||||
|
||||
int updateByPrimaryKey(HyPartnerLabelDO record);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<include refid="Base_Column_List" />
|
||||
from hy_partner_label_group
|
||||
where id = #{id}
|
||||
order by create_time
|
||||
</select>
|
||||
|
||||
<select id="selectSelective" resultType="com.cool.store.entity.HyPartnerLabelGroupDO">
|
||||
@@ -52,6 +53,7 @@
|
||||
<if test="remark != null and remark != ''">
|
||||
and remark like concat('%', #{remark}, '%')
|
||||
</if>
|
||||
order by create_time
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
@@ -218,6 +220,7 @@
|
||||
<if test="labelGroupName != null and labelGroupName != ''">
|
||||
AND t1.label_group_name LIKE CONCAT('%', #{labelGroupName}, '%')
|
||||
</if>
|
||||
ORDER BY t1.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,17 +2,17 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.HyPartnerLabelMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerLabelDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="label_group_id" jdbcType="BIGINT" property="labelGroupId" />
|
||||
<result column="label_name" jdbcType="VARCHAR" property="labelName" />
|
||||
<result column="edit_user_id" jdbcType="VARCHAR" property="editUserId" />
|
||||
<result column="edit_date" jdbcType="TIMESTAMP" property="editDate" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
||||
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<id column="id" property="id" />
|
||||
<result column="label_group_id" property="labelGroupId" />
|
||||
<result column="label_name" property="labelName" />
|
||||
<result column="edit_user_id" property="editUserId" />
|
||||
<result column="edit_date" property="editDate" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="create_user_id" property="createUserId" />
|
||||
<result column="update_user_id" property="updateUserId" />
|
||||
<result column="remark" property="remark" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, label_group_id, label_name, edit_user_id, edit_date, deleted, create_time, update_time,
|
||||
@@ -22,21 +22,58 @@
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from hy_partner_label
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
where deleted = 0
|
||||
and id = #{id}
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSelective" resultType="com.cool.store.entity.HyPartnerLabelDO">
|
||||
select <include refid="Base_Column_List"></include>
|
||||
from hy_partner_label
|
||||
where deleted = 0
|
||||
<if test="labelGroupId != null">
|
||||
and label_group_id = #{labelGroupId}
|
||||
</if>
|
||||
<if test="labelName != null and labelName != ''">
|
||||
and label_name = #{labelName}
|
||||
</if>
|
||||
<if test="editUserId != null">
|
||||
and edit_user_id = #{editUserId}
|
||||
</if>
|
||||
<if test="editDate != null">
|
||||
and edit_date = #{editDate}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
and create_user_id = #{createUserId}
|
||||
</if>
|
||||
<if test="updateUserId != null">
|
||||
and update_user_id = #{updateUserId}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
and remark = #{remark}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from hy_partner_label
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
where id = #{id}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.cool.store.entity.HyPartnerLabelDO">
|
||||
insert into hy_partner_label (id, label_group_id, label_name,
|
||||
edit_user_id, edit_date, deleted,
|
||||
create_time, update_time, create_user_id,
|
||||
update_user_id, remark)
|
||||
values (#{id,jdbcType=BIGINT}, #{labelGroupId,jdbcType=BIGINT}, #{labelName,jdbcType=VARCHAR},
|
||||
#{editUserId,jdbcType=VARCHAR}, #{editDate,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
|
||||
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=VARCHAR},
|
||||
#{updateUserId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR})
|
||||
values (#{id}, #{labelGroupId}, #{labelName},
|
||||
#{editUserId}, #{editDate}, #{deleted},
|
||||
#{createTime}, #{updateTime}, #{createUserId},
|
||||
#{updateUserId}, #{remark})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.cool.store.entity.HyPartnerLabelDO">
|
||||
insert into hy_partner_label
|
||||
@@ -77,37 +114,37 @@
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
#{id},
|
||||
</if>
|
||||
<if test="labelGroupId != null">
|
||||
#{labelGroupId,jdbcType=BIGINT},
|
||||
#{labelGroupId},
|
||||
</if>
|
||||
<if test="labelName != null">
|
||||
#{labelName,jdbcType=VARCHAR},
|
||||
#{labelName},
|
||||
</if>
|
||||
<if test="editUserId != null">
|
||||
#{editUserId,jdbcType=VARCHAR},
|
||||
#{editUserId},
|
||||
</if>
|
||||
<if test="editDate != null">
|
||||
#{editDate,jdbcType=TIMESTAMP},
|
||||
#{editDate},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
#{deleted,jdbcType=BIT},
|
||||
#{deleted},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
#{createUserId,jdbcType=VARCHAR},
|
||||
#{createUserId},
|
||||
</if>
|
||||
<if test="updateUserId != null">
|
||||
#{updateUserId,jdbcType=VARCHAR},
|
||||
#{updateUserId},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark,jdbcType=VARCHAR},
|
||||
#{remark},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
@@ -115,51 +152,52 @@
|
||||
update hy_partner_label
|
||||
<set>
|
||||
<if test="labelGroupId != null">
|
||||
label_group_id = #{labelGroupId,jdbcType=BIGINT},
|
||||
label_group_id = #{labelGroupId},
|
||||
</if>
|
||||
<if test="labelName != null">
|
||||
label_name = #{labelName,jdbcType=VARCHAR},
|
||||
<if test="labelName != null and labelName != ''">
|
||||
label_name = #{labelName},
|
||||
</if>
|
||||
<if test="editUserId != null">
|
||||
edit_user_id = #{editUserId,jdbcType=VARCHAR},
|
||||
edit_user_id = #{editUserId},
|
||||
</if>
|
||||
<if test="editDate != null">
|
||||
edit_date = #{editDate,jdbcType=TIMESTAMP},
|
||||
edit_date = #{editDate},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted,jdbcType=BIT},
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="createUserId != null">
|
||||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
create_user_id = #{createUserId},
|
||||
</if>
|
||||
<if test="updateUserId != null">
|
||||
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
||||
update_user_id = #{updateUserId},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
remark = #{remark},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
where deleted = 0
|
||||
and id = #{id}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.cool.store.entity.HyPartnerLabelDO">
|
||||
update hy_partner_label
|
||||
set label_group_id = #{labelGroupId,jdbcType=BIGINT},
|
||||
label_name = #{labelName,jdbcType=VARCHAR},
|
||||
edit_user_id = #{editUserId,jdbcType=VARCHAR},
|
||||
edit_date = #{editDate,jdbcType=TIMESTAMP},
|
||||
deleted = #{deleted,jdbcType=BIT},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
||||
remark = #{remark,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
set label_group_id = #{labelGroupId},
|
||||
label_name = #{labelName},
|
||||
edit_user_id = #{editUserId},
|
||||
edit_date = #{editDate},
|
||||
deleted = #{deleted},
|
||||
create_time = #{createTime},
|
||||
update_time = #{updateTime},
|
||||
create_user_id = #{createUserId},
|
||||
update_user_id = #{updateUserId},
|
||||
remark = #{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getLabelList" resultType="com.cool.store.vo.LabelListVo">
|
||||
@@ -174,6 +212,7 @@
|
||||
<if test="labelGroupId != null">
|
||||
AND t2.id = #{labelGroupId}
|
||||
</if>
|
||||
ORDER BY t1.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="whetherGroupInUse" resultType="java.lang.Boolean">
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.cool.store.dto.label;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fun Li 2023/8/10 16:43
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class LabelDeleteDTO {
|
||||
|
||||
@ApiModelProperty(value = "标签id", required = true)
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cool.store.dto.label;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -8,4 +9,14 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class LabelUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "标签id", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "标签名称", required = true)
|
||||
private String labelName;
|
||||
|
||||
@ApiModelProperty(value = "标签组id", required = true)
|
||||
private Long labelGroupId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,5 +26,17 @@ public interface LabelService {
|
||||
* 添加标签组
|
||||
* @param dto 新增标签组信息
|
||||
*/
|
||||
void addLabel(LabelAddDTO dto);
|
||||
void addLabel(LabelAddDTO dto) throws ApiException;
|
||||
|
||||
/**
|
||||
* 修改标签信息
|
||||
* @param dto 新标签信息
|
||||
*/
|
||||
void updateLabel(LabelUpdateDTO dto);
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @param dto
|
||||
*/
|
||||
void deleteLabel(LabelDeleteDTO dto);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.entity.HyPartnerLabelDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.mapper.HyPartnerLabelMapper;
|
||||
import com.cool.store.service.LabelService;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
@@ -38,15 +42,52 @@ public class LabelServiceImpl implements LabelService {
|
||||
* @param dto 新增标签组信息
|
||||
*/
|
||||
@Override
|
||||
public void addLabel(LabelAddDTO dto) {
|
||||
public void addLabel(LabelAddDTO dto) throws ApiException {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
List<HyPartnerLabelDO> hyPartnerLabelDOS = labelMapper.selectSelective(labelDO);
|
||||
if (hyPartnerLabelDOS != null && hyPartnerLabelDOS.size() > 0) {
|
||||
throw new ApiException(ErrorCodeEnum.LABEL_EXIST);
|
||||
}
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setLabelGroupId(dto.getLabelGroupId());
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setCreateUserId(userId);
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelMapper.insertSelective(labelDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签信息
|
||||
* @param dto 新标签信息
|
||||
*/
|
||||
@Override
|
||||
public void updateLabel(LabelUpdateDTO dto) {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setId(dto.getId());
|
||||
labelDO.setLabelName(dto.getLabelName());
|
||||
labelDO.setLabelGroupId(dto.getLabelGroupId());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelMapper.updateByPrimaryKeySelective(labelDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void deleteLabel(LabelDeleteDTO dto) {
|
||||
HyPartnerLabelDO labelDO = new HyPartnerLabelDO();
|
||||
String userId = CurrentUserHolder.getUserId();
|
||||
labelDO.setId(dto.getId());
|
||||
labelDO.setEditUserId(userId);
|
||||
labelDO.setEditDate(new Date());
|
||||
labelDO.setUpdateUserId(userId);
|
||||
labelDO.setDeleted(Boolean.TRUE);
|
||||
labelMapper.updateByPrimaryKeySelective(labelDO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.cool.store.controller;
|
||||
|
||||
import com.cool.store.dto.label.LabelAddDTO;
|
||||
import com.cool.store.dto.label.LabelDeleteDTO;
|
||||
import com.cool.store.dto.label.LabelListDTO;
|
||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.LabelService;
|
||||
import com.cool.store.vo.LabelListVo;
|
||||
@@ -39,16 +42,23 @@ public class LabelController {
|
||||
|
||||
@ApiOperation("新增标签")
|
||||
@PostMapping("/add")
|
||||
public ResponseResult addLabel(@RequestBody LabelAddDTO dto) {
|
||||
public ResponseResult addLabel(@RequestBody LabelAddDTO dto) throws ApiException {
|
||||
labelService.addLabel(dto);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
// @ApiOperation("修改标签")
|
||||
// @PostMapping("/edit")
|
||||
// public ResponseResult updateLabel() {
|
||||
// labelService.updateLabel();
|
||||
// return ResponseResult.success();
|
||||
// }
|
||||
@ApiOperation("修改标签")
|
||||
@PostMapping("/edit")
|
||||
public ResponseResult updateLabel(@RequestBody LabelUpdateDTO dto) {
|
||||
labelService.updateLabel(dto);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation("删除标签")
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult deleteLabel(@RequestBody LabelDeleteDTO dto) {
|
||||
labelService.deleteLabel(dto);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user