删除品类mapper

This commit is contained in:
YY
2025-07-24 08:46:08 +08:00
parent 6cc41f3bfb
commit f3343871f3
5 changed files with 4 additions and 530 deletions

View File

@ -28,19 +28,6 @@ public class CoscoCategoryController extends BaseController {
@Autowired
private ICoscoCategoryService coscoCategoryService;
/**
* 查询分页数据
*
* @param coscoCategory 分页信息
* @return 返回结果
*/
@ApiOperation("查询分页数据")
@PostMapping("/getPage")
public BaseResponse<IPage<CoscoCategoryVO>> getPage(@ApiParam(value = "对象数据", required = true)
@RequestBody CoscoCategoryVO coscoCategory) {
return BaseResponse.success(coscoCategoryService.getPage(coscoCategory));
}
/**
* 品类列表查询
@ -58,8 +45,6 @@ public class CoscoCategoryController extends BaseController {
return coscoCategoryService.selectCategoryTreeNoSuperior(coscoCategory);
}
/**
* 获取品类库_品类详细信息
*/
@ -68,37 +53,6 @@ public class CoscoCategoryController extends BaseController {
return BaseResponse.success(coscoCategoryService.selectCoscoCategoryById(id));
}
/**
* 新增品类库_品类
*/
@PostMapping
public BaseResponse add(@RequestBody CoscoCategory coscoCategory) {
if(coscoCategory.getParentId()==null){
return BaseResponse.fail(ErrorMessageConstant.PLEASE_SELECT_SUPERIOR_CATEGORY);
}
int i = coscoCategoryService.insertCoscoCategory(coscoCategory);
if (i<=0) {
return BaseResponse.fail(ErrorMessageConstant.ENABLE_DISABLE_TEMPLATE_NOT_MODIFY);
}
return BaseResponse.success();
}
/**
* 修改品类库_品类
*/
@PutMapping
public BaseResponse<Integer> edit(@RequestBody CoscoCategory coscoCategory) {
return BaseResponse.success(coscoCategoryService.updateCoscoCategory(coscoCategory));
}
/**
* 删除品类库_品类
*/
@DeleteMapping("/{id}")
public BaseResponse<Integer> remove(@PathVariable String id) {
return BaseResponse.success(coscoCategoryService.deleteCoscoCategoryById(id));
}
@GetMapping(value = "/getCategoryNameById")
public String getCategoryNameById(String id){
return coscoCategoryService.getCategoryNameById(id);

View File

@ -1,81 +0,0 @@
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo.CoscoCategoryVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 品类库_品类Mapper接口
*
* @author ruoyi
* @date 2025-06-16
*/
public interface CoscoCategoryMapper extends IBaseMapper<CoscoCategory> {
/**
* 查询品类库_品类
*
* @param id 品类库_品类主键
* @return 品类库_品类
*/
public CoscoCategory selectCoscoCategoryById(String id);
/**
* 查询品类库_品类列表
*
* @param coscoCategory 品类库_品类
* @return 品类库_品类集合
*/
public List<CoscoCategory> selectCoscoCategoryList(CoscoCategory coscoCategory);
/**
* 新增品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
public int insertCoscoCategory(CoscoCategory coscoCategory);
/**
* 修改品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
public int updateCoscoCategory(CoscoCategory coscoCategory);
/**
* 删除品类库_品类
*
* @param id 品类库_品类主键
* @return 结果
*/
public int deleteCoscoCategoryById(String id);
/**
* 批量删除品类库_品类
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCoscoCategoryByIds(String[] ids);
IPage<CoscoCategoryVO> selectMyPage(IPage<CoscoCategoryVO> p,@Param("coscoCategory") CoscoCategoryVO coscoCategory);
/**
* 根据品类id获取全部名称
* @param id
* @return
*/
String selectCategoryNameById(String id);
/**
* 通过多个id查询
*/
List<CoscoCategory> selectCoscoCategoryNameList(CoscoCategory coscoCategory);
}

View File

@ -17,7 +17,7 @@ import java.util.List;
* @author ruoyi
* @date 2025-06-16
*/
public interface ICoscoCategoryService extends IBaseService<CoscoCategory> {
public interface ICoscoCategoryService {
/**
* 查询品类库_品类
*
@ -25,54 +25,6 @@ public interface ICoscoCategoryService extends IBaseService<CoscoCategory> {
* @return 品类库_品类
*/
public CoscoCategoryMaintenance selectCoscoCategoryById(String id);
/**
* 查询品类库_品类列表
*
* @param coscoCategory 品类库_品类
* @return 品类库_品类集合
*/
public List<CoscoCategory> selectCoscoCategoryList(CoscoCategory coscoCategory);
/**
* 新增品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
public int insertCoscoCategory(CoscoCategory coscoCategory);
/**
* 修改品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
public int updateCoscoCategory(CoscoCategory coscoCategory);
/**
* 批量删除品类库_品类
*
* @param ids 需要删除的品类库_品类主键集合
* @return 结果
*/
public int deleteCoscoCategoryByIds(String[] ids);
/**
* 删除品类库_品类信息
*
* @param id 品类库_品类主键
* @return 结果
*/
public int deleteCoscoCategoryById(String id);
/**
* 分页查询
* @param coscoCategory
* @return
*/
IPage<CoscoCategoryVO> getPage(CoscoCategoryVO coscoCategory);
/**
* 查询品类树
* @param coscoCategory

View File

@ -1,27 +1,15 @@
package com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaunicom.mall.ebtp.common.base.client.CategoryClient;
import com.chinaunicom.mall.ebtp.common.base.client.SystemClient;
import com.chinaunicom.mall.ebtp.common.base.entity.*;
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
import com.chinaunicom.mall.ebtp.common.base.util.TokenUtil;
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
import com.chinaunicom.zyhy.ebtp.supplier.base.constant.CoscoCategoryConstant;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.dao.CoscoCategoryMapper;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.service.ICoscoCategoryService;
import com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.vo.CoscoCategoryVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 品类库_品类Service业务层处理
@ -30,9 +18,8 @@ import java.util.stream.Collectors;
* @date 2025-06-16
*/
@Service
public class CoscoCategoryServiceImpl extends BaseServiceImpl<CoscoCategoryMapper, CoscoCategory> implements ICoscoCategoryService {
@Autowired
private CoscoCategoryMapper coscoCategoryMapper;
public class CoscoCategoryServiceImpl implements ICoscoCategoryService {
@Autowired
private SystemClient systemClient;
@Autowired
@ -53,84 +40,6 @@ public class CoscoCategoryServiceImpl extends BaseServiceImpl<CoscoCategoryMappe
return info.getData();
}
/**
* 查询品类库_品类列表
*
* @param coscoCategory 品类库_品类
* @return 品类库_品类
*/
@Override
public List<CoscoCategory> selectCoscoCategoryList(CoscoCategory coscoCategory) {
return coscoCategoryMapper.selectCoscoCategoryList(coscoCategory);
}
/**
* 新增品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
@Override
public int insertCoscoCategory(CoscoCategory coscoCategory) {
coscoCategory.setId(PropertyUtils.getSnowflakeId());
if (!coscoCategory.getParentId().equals(CoscoCategoryConstant.LEVEL_TOP)) {
CoscoCategory coscoCategory1 = coscoCategoryMapper.selectCoscoCategoryById(coscoCategory.getParentId());
if (coscoCategory1.getType().equals(CoscoCategoryConstant.CATEGORY_TYPE_CATEGORY_TYPE)) {
return 0;
}
coscoCategory.setAncestors(coscoCategory1.getAncestors() + "," + coscoCategory.getId());
} else {
coscoCategory.setAncestors(CoscoCategoryConstant.LEVEL_TOP + "," + coscoCategory.getId());
}
coscoCategory.setCreateTime(new Date());
BaseCacheUser currentUser = TokenUtil.getCurrentUser();
coscoCategory.setCreateBy(currentUser.getUserId());
coscoCategory.setDelFlag(CoscoCategoryConstant.DELETE_FLAG_YES);
return coscoCategoryMapper.insertCoscoCategory(coscoCategory);
}
/**
* 修改品类库_品类
*
* @param coscoCategory 品类库_品类
* @return 结果
*/
@Override
public int updateCoscoCategory(CoscoCategory coscoCategory) {
coscoCategory.setUpdateTime(new Date());
BaseCacheUser currentUser = TokenUtil.getCurrentUser();
coscoCategory.setUpdateBy(currentUser.getUserId());
return coscoCategoryMapper.updateCoscoCategory(coscoCategory);
}
/**
* 批量删除品类库_品类
*
* @param ids 需要删除的品类库_品类主键
* @return 结果
*/
@Override
public int deleteCoscoCategoryByIds(String[] ids) {
return coscoCategoryMapper.deleteCoscoCategoryByIds(ids);
}
/**
* 删除品类库_品类信息
*
* @param id 品类库_品类主键
* @return 结果
*/
@Override
public int deleteCoscoCategoryById(String id) {
return coscoCategoryMapper.deleteCoscoCategoryById(id);
}
@Override
public IPage<CoscoCategoryVO> getPage(CoscoCategoryVO coscoCategory) {
IPage<CoscoCategoryVO> p = new Page<>(coscoCategory.getBasePageRequest().getPageNo(),
coscoCategory.getBasePageRequest().getPageSize());
return coscoCategoryMapper.selectMyPage(p, coscoCategory);
}
@Override
public BaseResponse<List<CoscoCategoryMaintenanceVO>> selectCategoryTree(CoscoCategoryMaintenanceVO coscoCategory) {
@ -182,39 +91,14 @@ public class CoscoCategoryServiceImpl extends BaseServiceImpl<CoscoCategoryMappe
CoscoCategoryMaintenance data = info.getData();
return data.getCategoryName();
}
return coscoCategoryMapper.selectCategoryNameById(id);
return null;
}
private List<CoscoCategoryVO> buildTree(List<CoscoCategoryVO> categories) {
// 获取所有顶级节点 (parentId = "0")
List<CoscoCategoryVO> rootNodes = categories.stream()
.filter(c -> CoscoCategoryConstant.LEVEL_TOP.equals(c.getParentId()))
.map(this::convertToTreeDto)
.collect(Collectors.toList());
// 递归构建树
rootNodes.forEach(root -> buildChildren(root, categories));
return rootNodes;
}
private void buildChildren(CoscoCategoryVO parentNode, List<CoscoCategoryVO> allCategories) {
List<CoscoCategoryVO> children = allCategories.stream()
.filter(c -> parentNode.getId().equals(c.getParentId()))
.map(this::convertToTreeDto)
.collect(Collectors.toList());
if (!children.isEmpty()) {
parentNode.setChildren(children);
children.forEach(child -> buildChildren(child, allCategories));
}
}
private CoscoCategoryVO convertToTreeDto(CoscoCategory category) {
CoscoCategoryVO dto = new CoscoCategoryVO();
BeanUtils.copyProperties(category, dto);
return dto;
}
}

View File

@ -1,235 +0,0 @@
<?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.chinaunicom.zyhy.ebtp.supplier.coscoCategory.dao.CoscoCategoryMapper">
<resultMap type="com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory" id="CoscoCategoryResult">
<result property="id" column="id"/>
<result property="categoryName" column="category_name"/>
<result property="parentId" column="parent_id"/>
<result property="type" column="type"/>
<result property="orderBy" column="order_by"/>
<result property="ancestors" column="ancestors"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="lastUpdateTime" column="last_update_time"/>
</resultMap>
<sql id="selectCoscoCategoryVo">
select id,
category_name,
parent_id,
type,
order_by,
ancestors,
remark,
del_flag,
create_by,
create_time,
update_by,
update_time,
last_update_time
from cosco_category
</sql>
<select id="selectCoscoCategoryList"
parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory"
resultMap="CoscoCategoryResult">
select cc.id,
cc.category_name,
cc.parent_id,
cc.type,
cc.order_by,
cc.ancestors,
cc.remark,
cc.del_flag,
cc.create_by,
cc.create_time,
cc.update_by,
cc.update_time,
cc.last_update_time
from cosco_category cc
<where>
and cc.del_flag = 'normal'
<if test="categoryName != null and categoryName != ''">
and cc.category_name like concat('%', #{categoryName}, '%')
</if>
<if test="parentId != null and parentId != ''">
and cc.parent_id = #{parentId}
</if>
<if test="type != null ">
and cc.type = #{type}
</if>
<if test="orderBy != null ">
and cc.order_by = #{orderBy}
</if>
<if test="lastUpdateTime != null ">
and cc.last_update_time = #{lastUpdateTime}
</if>
<if test="deptIds!=null and deptIds.size>0">
and cc.id not in (
SELECT
cclc.category_id
FROM
cosco_category_library ccl
JOIN cosco_category_library_contain cclc on ccl.id=cclc.category_library_id
where ccl.dept_id in (
<foreach item="deptId" index="index" collection="deptIds" separator=",">
#{deptId}
</foreach>
) and ccl.approve_status=1 and cclc.lock_type=1
)
</if>
</where>
order by cc.order_by asc
</select>
<select id="selectMyPage" parameterType="object"
resultMap="CoscoCategoryResult">
<include refid="selectCoscoCategoryVo"/>
order by order_by asc
</select>
<select id="selectCoscoCategoryById" parameterType="String"
resultMap="CoscoCategoryResult">
<include refid="selectCoscoCategoryVo"/>
where id = #{id}
</select>
<select id="selectCategoryNameById" parameterType="string" resultType="string">
SELECT COALESCE((SELECT GROUP_CONCAT(category_name ORDER BY FIND_IN_SET(id, c.ancestors) SEPARATOR '-')
FROM cosco_category
WHERE FIND_IN_SET(id, c.ancestors)), '') AS ancestor_names
FROM cosco_category c
WHERE id = #{id}
</select>
<select id="selectCoscoCategoryNameList"
parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory"
resultMap="CoscoCategoryResult">
SELECT
c.id,
(
SELECT GROUP_CONCAT(p.category_name ORDER BY FIND_IN_SET(p.id, c.ancestors) SEPARATOR '-')
FROM cosco_category p
WHERE FIND_IN_SET(p.id, c.ancestors)
) AS categoryName
FROM cosco_category c
WHERE c.id IN
<foreach collection="idList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<insert id="insertCoscoCategory"
parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory">
insert into cosco_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="parentId != null">parent_id,</if>
<if test="type != null">type,</if>
<if test="orderBy != null">order_by,</if>
<if test="ancestors != null">ancestors,</if>
<if test="remark != null">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="lastUpdateTime != null">last_update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="parentId != null">#{parentId},</if>
<if test="type != null">#{type},</if>
<if test="orderBy != null">#{orderBy},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="remark != null">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="lastUpdateTime != null">#{lastUpdateTime},</if>
</trim>
</insert>
<insert id="batchCoscoCategory" parameterType="java.util.List">
insert into cosco_category
( id, category_name, parent_id, type, order_by, ancestors, remark, del_flag, create_by, create_time, update_by,
update_time, last_update_time)
values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.categoryName}, #{item.parentId}, #{item.type}, #{item.orderBy}, #{item.ancestors},
#{item.remark}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime},
#{item.lastUpdateTime})
</foreach>
</insert>
<update id="updateCoscoCategory"
parameterType="com.chinaunicom.zyhy.ebtp.supplier.coscoCategory.entity.CoscoCategory">
update cosco_category
<trim prefix="SET" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name =
#{categoryName},
</if>
<if test="parentId != null">parent_id =
#{parentId},
</if>
<if test="type != null">type =
#{type},
</if>
<if test="orderBy != null">order_by =
#{orderBy},
</if>
<if test="ancestors != null">ancestors =
#{ancestors},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="delFlag != null and delFlag != ''">del_flag =
#{delFlag},
</if>
<if test="createBy != null and createBy != ''">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="lastUpdateTime != null">last_update_time =
#{lastUpdateTime},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteCoscoCategoryById" parameterType="String">
update cosco_category
set del_flag = 'deleted'
where id = #{id}
</update>
<update id="deleteCoscoCategoryByIds" parameterType="String">
update cosco_category set del_flag = 'deleted' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>