diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupController.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupController.java index 7326485..0413aad 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupController.java +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupController.java @@ -94,4 +94,11 @@ public class BasSheepGroupController extends BaseController return toAjax(basSheepGroupService.deleteBasSheepGroupByGroupIds(groupIds)); } + @PreAuthorize("@ss.hasPermi('group_management:group_management:list')") + @GetMapping("/leaf") + public AjaxResult selectLeafNodes() { + List leafNodes = basSheepGroupService.selectLeafNodes(); + return success(leafNodes); + } + } diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupMappingController.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupMappingController.java new file mode 100644 index 0000000..b1d3417 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/controller/BasSheepGroupMappingController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.fileManagement.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +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.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.fileManagement.domain.BasSheepGroupMapping; +import com.zhyc.module.fileManagement.service.IBasSheepGroupMappingService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 羊只分组关联Controller + * + * @author wyt + * @date 2025-07-16 + */ +@RestController +@RequestMapping("/sheep_grouping/sheep_grouping") +public class BasSheepGroupMappingController extends BaseController +{ + @Autowired + private IBasSheepGroupMappingService basSheepGroupMappingService; + + /** + * 查询羊只分组关联列表 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:list')") + @GetMapping("/list") + public TableDataInfo list(BasSheepGroupMapping basSheepGroupMapping) + { + startPage(); + List list = basSheepGroupMappingService.selectBasSheepGroupMappingList(basSheepGroupMapping); + return getDataTable(list); + } + + /** + * 导出羊只分组关联列表 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:export')") + @Log(title = "羊只分组关联", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, BasSheepGroupMapping basSheepGroupMapping) + { + List list = basSheepGroupMappingService.selectBasSheepGroupMappingList(basSheepGroupMapping); + ExcelUtil util = new ExcelUtil(BasSheepGroupMapping.class); + util.exportExcel(response, list, "羊只分组关联数据"); + } + + /** + * 获取羊只分组关联详细信息 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(basSheepGroupMappingService.selectBasSheepGroupMappingById(id)); + } + + /** + * 新增羊只分组关联 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:add')") + @Log(title = "羊只分组关联", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BasSheepGroupMapping basSheepGroupMapping) + { + return toAjax(basSheepGroupMappingService.insertBasSheepGroupMapping(basSheepGroupMapping)); + } + + /** + * 修改羊只分组关联 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:edit')") + @Log(title = "羊只分组关联", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BasSheepGroupMapping basSheepGroupMapping) + { + return toAjax(basSheepGroupMappingService.updateBasSheepGroupMapping(basSheepGroupMapping)); + } + + /** + * 删除羊只分组关联 + */ + @PreAuthorize("@ss.hasPermi('sheep_grouping:sheep_grouping:remove')") + @Log(title = "羊只分组关联", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(basSheepGroupMappingService.deleteBasSheepGroupMappingByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/domain/BasSheepGroupMapping.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/domain/BasSheepGroupMapping.java new file mode 100644 index 0000000..37798f3 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/domain/BasSheepGroupMapping.java @@ -0,0 +1,68 @@ +package com.zhyc.module.fileManagement.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 羊只分组关联对象 bas_sheep_group_mapping + * + * @author wyt + * @date 2025-07-16 + */ +public class BasSheepGroupMapping extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + @Excel(name = "主键ID") + private Long id; + + /** 羊只ID */ + @Excel(name = "羊只ID") + private Long sheepId; + + /** 分组ID */ + @Excel(name = "分组ID") + private Long groupId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSheepId(Long sheepId) + { + this.sheepId = sheepId; + } + + public Long getSheepId() + { + return sheepId; + } + + public void setGroupId(Long groupId) + { + this.groupId = groupId; + } + + public Long getGroupId() + { + return groupId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("sheepId", getSheepId()) + .append("groupId", getGroupId()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMapper.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMapper.java index dcdcaeb..a7a434d 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMapper.java +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMapper.java @@ -60,4 +60,6 @@ public interface BasSheepGroupMapper */ public int deleteBasSheepGroupByGroupIds(Long[] groupIds); + List selectLeafNodes(); + } diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMappingMapper.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMappingMapper.java new file mode 100644 index 0000000..f38bf34 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/mapper/BasSheepGroupMappingMapper.java @@ -0,0 +1,63 @@ +package com.zhyc.module.fileManagement.mapper; + +import java.util.List; +import com.zhyc.module.fileManagement.domain.BasSheepGroupMapping; + +/** + * 羊只分组关联Mapper接口 + * + * @author wyt + * @date 2025-07-16 + */ +public interface BasSheepGroupMappingMapper +{ + /** + * 查询羊只分组关联 + * + * @param id 羊只分组关联主键 + * @return 羊只分组关联 + */ + public BasSheepGroupMapping selectBasSheepGroupMappingById(Long id); + + /** + * 查询羊只分组关联列表 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 羊只分组关联集合 + */ + public List selectBasSheepGroupMappingList(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 新增羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + public int insertBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 修改羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + public int updateBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 删除羊只分组关联 + * + * @param id 羊只分组关联主键 + * @return 结果 + */ + public int deleteBasSheepGroupMappingById(Long id); + + /** + * 批量删除羊只分组关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBasSheepGroupMappingByIds(Long[] ids); + + +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupMappingService.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupMappingService.java new file mode 100644 index 0000000..febb461 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupMappingService.java @@ -0,0 +1,63 @@ +package com.zhyc.module.fileManagement.service; + +import java.util.List; +import com.zhyc.module.fileManagement.domain.BasSheepGroupMapping; + +/** + * 羊只分组关联Service接口 + * + * @author wyt + * @date 2025-07-16 + */ +public interface IBasSheepGroupMappingService +{ + /** + * 查询羊只分组关联 + * + * @param id 羊只分组关联主键 + * @return 羊只分组关联 + */ + public BasSheepGroupMapping selectBasSheepGroupMappingById(Long id); + + /** + * 查询羊只分组关联列表 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 羊只分组关联集合 + */ + public List selectBasSheepGroupMappingList(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 新增羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + public int insertBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 修改羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + public int updateBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping); + + /** + * 批量删除羊只分组关联 + * + * @param ids 需要删除的羊只分组关联主键集合 + * @return 结果 + */ + public int deleteBasSheepGroupMappingByIds(Long[] ids); + + /** + * 删除羊只分组关联信息 + * + * @param id 羊只分组关联主键 + * @return 结果 + */ + public int deleteBasSheepGroupMappingById(Long id); + + +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupService.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupService.java index 2bd5c60..7f55e6f 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupService.java +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/IBasSheepGroupService.java @@ -60,5 +60,5 @@ public interface IBasSheepGroupService */ public int deleteBasSheepGroupByGroupId(Long groupId); - + List selectLeafNodes(); } diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupMappingServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupMappingServiceImpl.java new file mode 100644 index 0000000..d428848 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupMappingServiceImpl.java @@ -0,0 +1,96 @@ +package com.zhyc.module.fileManagement.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zhyc.module.fileManagement.mapper.BasSheepGroupMappingMapper; +import com.zhyc.module.fileManagement.domain.BasSheepGroupMapping; +import com.zhyc.module.fileManagement.service.IBasSheepGroupMappingService; + +/** + * 羊只分组关联Service业务层处理 + * + * @author wyt + * @date 2025-07-16 + */ +@Service +public class BasSheepGroupMappingServiceImpl implements IBasSheepGroupMappingService +{ + @Autowired + private BasSheepGroupMappingMapper basSheepGroupMappingMapper; + + /** + * 查询羊只分组关联 + * + * @param id 羊只分组关联主键 + * @return 羊只分组关联 + */ + @Override + public BasSheepGroupMapping selectBasSheepGroupMappingById(Long id) + { + return basSheepGroupMappingMapper.selectBasSheepGroupMappingById(id); + } + + /** + * 查询羊只分组关联列表 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 羊只分组关联 + */ + @Override + public List selectBasSheepGroupMappingList(BasSheepGroupMapping basSheepGroupMapping) + { + return basSheepGroupMappingMapper.selectBasSheepGroupMappingList(basSheepGroupMapping); + } + + /** + * 新增羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + @Override + public int insertBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping) + { + return basSheepGroupMappingMapper.insertBasSheepGroupMapping(basSheepGroupMapping); + } + + /** + * 修改羊只分组关联 + * + * @param basSheepGroupMapping 羊只分组关联 + * @return 结果 + */ + @Override + public int updateBasSheepGroupMapping(BasSheepGroupMapping basSheepGroupMapping) + { + return basSheepGroupMappingMapper.updateBasSheepGroupMapping(basSheepGroupMapping); + } + + /** + * 批量删除羊只分组关联 + * + * @param ids 需要删除的羊只分组关联主键 + * @return 结果 + */ + @Override + public int deleteBasSheepGroupMappingByIds(Long[] ids) + { + return basSheepGroupMappingMapper.deleteBasSheepGroupMappingByIds(ids); + } + + /** + * 删除羊只分组关联信息 + * + * @param id 羊只分组关联主键 + * @return 结果 + */ + @Override + public int deleteBasSheepGroupMappingById(Long id) + { + return basSheepGroupMappingMapper.deleteBasSheepGroupMappingById(id); + } + + + +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupServiceImpl.java index 970e21d..9df99d3 100644 --- a/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupServiceImpl.java +++ b/zhyc-module/src/main/java/com/zhyc/module/fileManagement/service/impl/BasSheepGroupServiceImpl.java @@ -108,4 +108,16 @@ public class BasSheepGroupServiceImpl implements IBasSheepGroupService { return basSheepGroupMapper.deleteBasSheepGroupByGroupId(groupId); } + + @Override + public List selectLeafNodes() { + List leafNodes = basSheepGroupMapper.selectLeafNodes(); + // 如果 ancestorNames 需要格式化,可以复用已有的逻辑 + leafNodes.forEach(group -> { + if (group.getAncestorNames() != null) { + group.setAncestorNames(group.getAncestorNames().replace(",", " / ")); + } + }); + return leafNodes; + } } diff --git a/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.txt b/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.txt new file mode 100644 index 0000000..be9a507 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.txt @@ -0,0 +1,80 @@ +This XML file does not appear to have any style information associated with it. The document tree is shown below. + + + + + + + + + + + + + + + + + + + +SELECT g.group_id, g.parent_id, g.group_name, g.ancestors, g.status, g.create_by, g.create_time, g.update_by, g.update_time, + +(SELECT GROUP_CONCAT(parent.group_name ORDER BY FIND_IN_SET(parent.group_id, g.ancestors)) FROM bas_sheep_group parent WHERE FIND_IN_SET(parent.group_id, g.ancestors) > 0 ) AS ancestor_names, (CASE WHEN (SELECT COUNT(1) FROM bas_sheep_group child WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf FROM bas_sheep_group g + + + + +insert into bas_sheep_group + +parent_id, +group_name, +ancestors, +status, +create_by, +create_time, +update_by, +update_time, + + +#{parentId}, +#{groupName}, +#{ancestors}, +#{status}, +#{createBy}, +#{createTime}, +#{updateBy}, +#{updateTime}, + + + +update bas_sheep_group + +parent_id = #{parentId}, +group_name = #{groupName}, +ancestors = #{ancestors}, +status = #{status}, +create_by = #{createBy}, +create_time = #{createTime}, +update_by = #{updateBy}, +update_time = #{updateTime}, + +where group_id = #{groupId} + + delete from bas_sheep_group where group_id = #{groupId} + +delete from bas_sheep_group where group_id in + #{groupId} + + \ No newline at end of file diff --git a/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.xml b/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.xml index dd632fd..379f397 100644 --- a/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.xml +++ b/zhyc-module/src/main/resources/mapper/fileManagement/BasSheepGroupMapper.xml @@ -49,6 +49,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and status = #{status} ORDER BY g.group_id + + + + + and sheep_id = #{sheepId} + and group_id = #{groupId} + + + + + + + insert into bas_sheep_group_mapping + + sheep_id, + group_id, + + + #{sheepId}, + #{groupId}, + + + + + update bas_sheep_group_mapping + + sheep_id = #{sheepId}, + group_id = #{groupId}, + + where id = #{id} + + + + delete from bas_sheep_group_mapping where id = #{id} + + + + delete from bas_sheep_group_mapping where id in + + #{id} + + + \ No newline at end of file