From f3343871f3bdfcfe0174ae5616cd43cd8c88d4b0 Mon Sep 17 00:00:00 2001 From: YY <1272464982@qq.com> Date: Thu, 24 Jul 2025 08:46:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=93=81=E7=B1=BBmapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CoscoCategoryController.java | 46 ---- .../dao/CoscoCategoryMapper.java | 81 ------ .../service/ICoscoCategoryService.java | 50 +--- .../impl/CoscoCategoryServiceImpl.java | 122 +-------- .../dao/mapper/CoscoCategoryMapper.xml | 235 ------------------ 5 files changed, 4 insertions(+), 530 deletions(-) delete mode 100644 src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/dao/CoscoCategoryMapper.java delete mode 100644 src/main/resources/com/chinaunicom/zyhy/ebtp/coscoCategory/dao/mapper/CoscoCategoryMapper.xml diff --git a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/controller/CoscoCategoryController.java b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/controller/CoscoCategoryController.java index 84279ca..127c37f 100644 --- a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/controller/CoscoCategoryController.java +++ b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/controller/CoscoCategoryController.java @@ -28,19 +28,6 @@ public class CoscoCategoryController extends BaseController { @Autowired private ICoscoCategoryService coscoCategoryService; - /** - * 查询分页数据 - * - * @param coscoCategory 分页信息 - * @return 返回结果 - */ - @ApiOperation("查询分页数据") - @PostMapping("/getPage") - public BaseResponse> 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 edit(@RequestBody CoscoCategory coscoCategory) { - return BaseResponse.success(coscoCategoryService.updateCoscoCategory(coscoCategory)); - } - - /** - * 删除品类库_品类 - */ - @DeleteMapping("/{id}") - public BaseResponse remove(@PathVariable String id) { - return BaseResponse.success(coscoCategoryService.deleteCoscoCategoryById(id)); - } - @GetMapping(value = "/getCategoryNameById") public String getCategoryNameById(String id){ return coscoCategoryService.getCategoryNameById(id); diff --git a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/dao/CoscoCategoryMapper.java b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/dao/CoscoCategoryMapper.java deleted file mode 100644 index 0d587ca..0000000 --- a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/dao/CoscoCategoryMapper.java +++ /dev/null @@ -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 { - /** - * 查询品类库_品类 - * - * @param id 品类库_品类主键 - * @return 品类库_品类 - */ - public CoscoCategory selectCoscoCategoryById(String id); - - /** - * 查询品类库_品类列表 - * - * @param coscoCategory 品类库_品类 - * @return 品类库_品类集合 - */ - public List 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 selectMyPage(IPage p,@Param("coscoCategory") CoscoCategoryVO coscoCategory); - - /** - * 根据品类id获取全部名称 - * @param id - * @return - */ - String selectCategoryNameById(String id); - - /** - * 通过多个id查询 - */ - List selectCoscoCategoryNameList(CoscoCategory coscoCategory); - - -} diff --git a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/ICoscoCategoryService.java b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/ICoscoCategoryService.java index 36265bf..cb63291 100644 --- a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/ICoscoCategoryService.java +++ b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/ICoscoCategoryService.java @@ -17,7 +17,7 @@ import java.util.List; * @author ruoyi * @date 2025-06-16 */ -public interface ICoscoCategoryService extends IBaseService { +public interface ICoscoCategoryService { /** * 查询品类库_品类 * @@ -25,54 +25,6 @@ public interface ICoscoCategoryService extends IBaseService { * @return 品类库_品类 */ public CoscoCategoryMaintenance selectCoscoCategoryById(String id); - - /** - * 查询品类库_品类列表 - * - * @param coscoCategory 品类库_品类 - * @return 品类库_品类集合 - */ - public List 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 getPage(CoscoCategoryVO coscoCategory); - /** * 查询品类树 * @param coscoCategory diff --git a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/impl/CoscoCategoryServiceImpl.java b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/impl/CoscoCategoryServiceImpl.java index 05fbb57..f5c287d 100644 --- a/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/impl/CoscoCategoryServiceImpl.java +++ b/src/main/java/com/chinaunicom/zyhy/ebtp/supplier/coscoCategory/service/impl/CoscoCategoryServiceImpl.java @@ -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 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 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 getPage(CoscoCategoryVO coscoCategory) { - IPage p = new Page<>(coscoCategory.getBasePageRequest().getPageNo(), - coscoCategory.getBasePageRequest().getPageSize()); - return coscoCategoryMapper.selectMyPage(p, coscoCategory); - } @Override public BaseResponse> selectCategoryTree(CoscoCategoryMaintenanceVO coscoCategory) { @@ -182,39 +91,14 @@ public class CoscoCategoryServiceImpl extends BaseServiceImpl buildTree(List categories) { - // 获取所有顶级节点 (parentId = "0") - List 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 allCategories) { - List 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; - } } diff --git a/src/main/resources/com/chinaunicom/zyhy/ebtp/coscoCategory/dao/mapper/CoscoCategoryMapper.xml b/src/main/resources/com/chinaunicom/zyhy/ebtp/coscoCategory/dao/mapper/CoscoCategoryMapper.xml deleted file mode 100644 index 7b54065..0000000 --- a/src/main/resources/com/chinaunicom/zyhy/ebtp/coscoCategory/dao/mapper/CoscoCategoryMapper.xml +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - 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, - - - #{id}, - #{categoryName}, - #{parentId}, - #{type}, - #{orderBy}, - #{ancestors}, - #{remark}, - #{delFlag}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{lastUpdateTime}, - - - - 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 - - ( #{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}) - - - - update cosco_category - - category_name = - #{categoryName}, - - parent_id = - #{parentId}, - - type = - #{type}, - - order_by = - #{orderBy}, - - ancestors = - #{ancestors}, - - remark = - #{remark}, - - del_flag = - #{delFlag}, - - create_by = - #{createBy}, - - create_time = - #{createTime}, - - update_by = - #{updateBy}, - - update_time = - #{updateTime}, - - last_update_time = - #{lastUpdateTime}, - - - where id = #{id} - - - - update cosco_category - set del_flag = 'deleted' - where id = #{id} - - - - update cosco_category set del_flag = 'deleted' where id in - - #{id} - - -