标签组增删改查

This commit is contained in:
feng.li
2023-08-10 13:44:00 +08:00
parent fa86db7da7
commit fd896956c5
11 changed files with 601 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package com.cool.store.mapper;
import com.cool.store.entity.HyPartnerLabelGroupDO;
import com.cool.store.vo.LabelGroupListVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author Fun Li 2023/8/10 13:25
* @version 1.0
*/
@Mapper
public interface HyPartnerLabelGroupMapper {
int deleteByPrimaryKey(Long id);
int insert(HyPartnerLabelGroupDO record);
int insertSelective(HyPartnerLabelGroupDO record);
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
List<HyPartnerLabelGroupDO> selectSelective(HyPartnerLabelGroupDO record);
List<LabelGroupListVo> getLabelGroupList(HyPartnerLabelGroupDO record);
int updateByPrimaryKeySelective(HyPartnerLabelGroupDO record);
int updateByPrimaryKey(HyPartnerLabelGroupDO record);
}

View File

@@ -0,0 +1,200 @@
<?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.cool.store.mapper.HyPartnerLabelGroupMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerLabelGroupDO">
<id column="id" property="id" />
<result column="label_group_name" property="labelGroupName" />
<result column="deleted" property="deleted" />
<result column="edit_user_id" property="editUserId" />
<result column="edit_date" property="editDate" />
<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_name, deleted, edit_user_id, edit_date, create_time, update_time,
create_user_id, update_user_id, remark
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from hy_partner_label_group
where id = #{id}
</select>
<select id="selectSelective" resultType="com.cool.store.entity.HyPartnerLabelGroupDO">
select <include refid="Base_Column_List"></include>
from hy_partner_label_group
where deleted = 0
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from hy_partner_label_group
where id = #{id}
<if test="id != null">
and id = #{id}
</if>
<if test="labelGroupName != null and labelGroupName != ''">
and label_group_name like concat('%', #{labelGroupName}, '%')
</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 != ''">
and remark like concat('%', #{remark}, '%')
</if>
</delete>
<insert id="insert" parameterType="com.cool.store.entity.HyPartnerLabelGroupDO">
insert into hy_partner_label_group (id, label_group_name, deleted,
edit_user_id, edit_date, create_time,
update_time, create_user_id, update_user_id,
remark)
values (#{id}, #{labelGroupName}, #{deleted},
#{editUserId}, #{editDate}, #{createTime},
#{updateTime}, #{createUserId}, #{updateUserId},
#{remark})
</insert>
<insert id="insertSelective" parameterType="com.cool.store.entity.HyPartnerLabelGroupDO">
insert into hy_partner_label_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="labelGroupName != null and labelGroupName != ''">
label_group_name,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="editUserId != null">
edit_user_id,
</if>
<if test="editDate != null">
edit_date,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="updateUserId != null">
update_user_id,
</if>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="labelGroupName != null">
#{labelGroupName},
</if>
<if test="deleted != null">
#{deleted},
</if>
<if test="editUserId != null">
#{editUserId},
</if>
<if test="editDate != null">
#{editDate},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="createUserId != null">
#{createUserId},
</if>
<if test="updateUserId != null">
#{updateUserId},
</if>
<if test="remark != null">
#{remark},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.cool.store.entity.HyPartnerLabelGroupDO">
update hy_partner_label_group
<set>
<if test="labelGroupName != null">
label_group_name = #{labelGroupName},
</if>
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="editUserId != null">
edit_user_id = #{editUserId},
</if>
<if test="editDate != null">
edit_date = #{editDate},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="createUserId != null">
create_user_id = #{createUserId},
</if>
<if test="updateUserId != null">
update_user_id = #{updateUserId},
</if>
<if test="remark != null">
remark = #{remark},
</if>
</set>
where id = #{id}
</update>
<update id="updateByPrimaryKey" parameterType="com.cool.store.entity.HyPartnerLabelGroupDO">
update hy_partner_label_group
set label_group_name = #{labelGroupName},
deleted = #{deleted},
edit_user_id = #{editUserId},
edit_date = #{editDate},
create_time = #{createTime},
update_time = #{updateTime},
create_user_id = #{createUserId},
update_user_id = #{updateUserId},
remark = #{remark}
where id = #{id}
</update>
<!-- 获取标签分组信息列表 -->
<select id="getLabelGroupList" resultType="com.cool.store.vo.LabelGroupListVo">
SELECT t1.id, t1.label_group_name, t2.`name` AS editName, t2.mobile AS editMobile, t1.edit_date
FROM hy_partner_label_group t1
LEFT JOIN enterprise_user t2 ON t1.edit_user_id = t2.user_id
WHERE t1.deleted = 0 AND t2.deleted = 0
<if test="labelGroupName != null and labelGroupName != ''">
AND t1.label_group_name LIKE CONCAT('%', #{labelGroupName}, '%')
</if>
</select>
</mapper>

View File

@@ -0,0 +1,19 @@
package com.cool.store.dto.label;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author Fun Li 2023/8/10 13:28
* @version 1.0
*/
@Data
public class LabelGroupAddDTO {
@ApiModelProperty(value = "标签组名称", required = true)
private @NotBlank(message = "镖标签组名称不能为空")
String labelGroupName;
}

View File

@@ -0,0 +1,16 @@
package com.cool.store.dto.label;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Fun Li 2023/8/10 13:29
* @version 1.0
*/
@Data
public class LabelGroupDeleteDTO {
@ApiModelProperty("id")
private Long id;
}

View File

@@ -0,0 +1,19 @@
package com.cool.store.dto.label;
import com.cool.store.common.PageBasicInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author Fun Li 2023/8/10 13:29
* @version 1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LabelGroupListDTO extends PageBasicInfo {
@ApiModelProperty(value = "标签组名称", required = false)
private String labelGroupName;
}

View File

@@ -0,0 +1,22 @@
package com.cool.store.dto.label;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author Fun Li 2023/8/10 13:30
* @version 1.0
*/
@Data
public class LabelGroupUpdateDTO {
@ApiModelProperty(value = "id", required = true)
private Long id;
@ApiModelProperty(value = "标签组名称", required = true)
private @NotBlank(message = "标签组名称不能为空")
String labelGroupName;
}

View File

@@ -0,0 +1,52 @@
package com.cool.store.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author Fun Li 2023/8/10 13:31
* @version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HyPartnerLabelGroupDO {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("标签组名称")
private String labelGroupName;
@ApiModelProperty("删除标识")
private Boolean deleted;
@ApiModelProperty("编辑人user_identerprise_user.user_id")
private String editUserId;
@ApiModelProperty("编辑时间")
private Date editDate;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("创建人enterprise_user.user_id")
private String createUserId;
@ApiModelProperty("更新人enterprise_user.user_id")
private String updateUserId;
@ApiModelProperty("备注")
private String remark;
}

View File

@@ -0,0 +1,30 @@
package com.cool.store.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Fun Li 2023/8/10 13:33
* @version 1.0
*/
@Data
public class LabelGroupListVo {
@ApiModelProperty("标签组id")
private long id;
@ApiModelProperty("标签组名称")
private String labelGroupName;
@ApiModelProperty("编辑人姓名")
private String editName;
@ApiModelProperty("编辑人电话")
private String editMobile;
@ApiModelProperty("编辑时间")
private Date editDate;
}

View File

@@ -0,0 +1,46 @@
package com.cool.store.service;
import com.cool.store.dto.label.LabelGroupAddDTO;
import com.cool.store.dto.label.LabelGroupDeleteDTO;
import com.cool.store.dto.label.LabelGroupListDTO;
import com.cool.store.dto.label.LabelGroupUpdateDTO;
import com.cool.store.vo.LabelGroupListVo;
import java.util.List;
/**
* @author Fun Li 2023/8/10 13:34
* @version 1.0
*/
public interface LabelGroupService {
/**
* 查询标签组信息列表
* @param dto 查询条件
*/
List<LabelGroupListVo> getLabelGroupList(LabelGroupListDTO dto);
/**
* 添加标签组
* @param dto 新增标签组信息
*/
void addLabelGroup(LabelGroupAddDTO dto);
/**
* 修改标签组信息
* @param dto 修改内容
*/
void updateLabelGroup(LabelGroupUpdateDTO dto);
/**
* 删除标签组
* @param dto 待删除标签组信息
*/
void deleteLabelGroup(LabelGroupDeleteDTO dto);
/**
* 获取所有标签组
*/
List<LabelGroupListVo> getAllLabelGroupList();
}

View File

@@ -0,0 +1,94 @@
package com.cool.store.service.impl;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dto.label.LabelGroupAddDTO;
import com.cool.store.dto.label.LabelGroupDeleteDTO;
import com.cool.store.dto.label.LabelGroupListDTO;
import com.cool.store.dto.label.LabelGroupUpdateDTO;
import com.cool.store.entity.HyPartnerLabelGroupDO;
import com.cool.store.mapper.HyPartnerLabelGroupMapper;
import com.cool.store.service.LabelGroupService;
import com.cool.store.vo.LabelGroupListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author Fun Li 2023/8/10 13:35
* @version 1.0
*/
@Service
public class LabelGroupServiceImpl implements LabelGroupService {
@Autowired
private HyPartnerLabelGroupMapper labelGroupMapper;
/**
* 查询标签组信息列表
* @param dto 查询条件
*/
@Override
public List<LabelGroupListVo> getLabelGroupList(LabelGroupListDTO dto) {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
return this.labelGroupMapper.getLabelGroupList(labelGroupDO);
}
/**
* 添加标签组
* @param dto 新增标签组信息
*/
@Override
public void addLabelGroup(LabelGroupAddDTO dto) {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
String userId = CurrentUserHolder.getUserId();
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
labelGroupDO.setEditUserId(userId);
labelGroupDO.setEditDate(new Date());
labelGroupDO.setCreateUserId(userId);
labelGroupDO.setUpdateUserId(userId);
this.labelGroupMapper.insertSelective(labelGroupDO);
}
/**
* 修改标签组信息
* @param dto 修改内容
*/
@Override
public void updateLabelGroup(LabelGroupUpdateDTO dto) {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
String userId = CurrentUserHolder.getUserId();
labelGroupDO.setId(dto.getId());
labelGroupDO.setLabelGroupName(dto.getLabelGroupName());
labelGroupDO.setEditUserId(userId);
labelGroupDO.setEditDate(new Date());
labelGroupDO.setUpdateUserId(userId);
this.labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
}
/**
* 删除标签组
* @param dto 待删除标签组信息
*/
@Override
public void deleteLabelGroup(LabelGroupDeleteDTO dto) {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
String userId = CurrentUserHolder.getUserId();
labelGroupDO.setId(dto.getId());
labelGroupDO.setDeleted(Boolean.TRUE);
labelGroupDO.setUpdateUserId(userId);
this.labelGroupMapper.updateByPrimaryKeySelective(labelGroupDO);
}
/**
* 获取所有标签组
*/
@Override
public List<LabelGroupListVo> getAllLabelGroupList() {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
return this.labelGroupMapper.getLabelGroupList(labelGroupDO);
}
}

View File

@@ -0,0 +1,71 @@
package com.cool.store.controller;
import com.cool.store.dto.label.LabelGroupAddDTO;
import com.cool.store.dto.label.LabelGroupDeleteDTO;
import com.cool.store.dto.label.LabelGroupListDTO;
import com.cool.store.dto.label.LabelGroupUpdateDTO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.LabelGroupService;
import com.cool.store.vo.LabelGroupListVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author Fun Li 2023/8/10 10:54
* @version 1.0
*/
@Api(tags = {"标签组管理"})
@RestController
@RequestMapping({"/labelGroup"})
public class LabelGroupController {
@Autowired
private LabelGroupService labelGroupService;
public LabelGroupController() {
}
@ApiOperation("标签组分页查询")
@PostMapping({"/list"})
public ResponseResult<PageInfo<LabelGroupListVo>> getLabelGroupList(@RequestBody LabelGroupListDTO dto) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
List<LabelGroupListVo> result = this.labelGroupService.getLabelGroupList(dto);
return ResponseResult.success(new PageInfo(result));
}
@ApiOperation("新增标签组")
@PostMapping({"/add"})
public ResponseResult addLabelGroup(@RequestBody LabelGroupAddDTO dto) {
this.labelGroupService.addLabelGroup(dto);
return ResponseResult.success();
}
@ApiOperation("修改标签组")
@PostMapping({"/edit"})
public ResponseResult updateLabelGroup(@RequestBody LabelGroupUpdateDTO dto) {
this.labelGroupService.updateLabelGroup(dto);
return ResponseResult.success();
}
@ApiOperation("删除标签组")
@PostMapping({"/delete"})
public ResponseResult deleteLabelGroup(@RequestBody LabelGroupDeleteDTO dto) {
this.labelGroupService.deleteLabelGroup(dto);
return ResponseResult.success();
}
@ApiOperation("获取所有标签组")
@PostMapping({"/allList"})
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
return ResponseResult.success(this.labelGroupService.getAllLabelGroupList());
}
}