Newspaper há 1 ano atrás
pai
commit
dd546172a3

+ 19 - 0
snowy-web-app/src/main/java/vip/xiaonuo/core/enums/BaseDataTypeEnum.java

@@ -0,0 +1,19 @@
+package vip.xiaonuo.core.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum BaseDataTypeEnum {
+    /**
+     * 栋舍
+     */
+    PIGPEN("PIGPEN"),
+
+    STAGE("STAGE");
+
+    private final String value;
+
+    BaseDataTypeEnum(String value) {
+        this.value = value;
+    }
+}

+ 140 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/controller/BasePigpenController.java

@@ -0,0 +1,140 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.controller;
+
+import cn.hutool.core.lang.tree.Tree;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import vip.xiaonuo.common.annotation.CommonLog;
+import vip.xiaonuo.common.pojo.CommonResult;
+import vip.xiaonuo.common.pojo.CommonValidList;
+import vip.xiaonuo.modular.pigpen.entity.BasePigpen;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenAddParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenEditParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenIdParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenPageParam;
+import vip.xiaonuo.modular.pigpen.service.BasePigpenService;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
+/**
+ * base_pigpen控制器
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ */
+@Api(tags = "base_pigpen控制器")
+@ApiSupport(author = "SNOWY_TEAM", order = 1)
+@RestController
+@Validated
+public class BasePigpenController {
+
+    @Resource
+    private BasePigpenService basePigpenService;
+
+    /**
+     * 获取base_pigpen分页
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("获取栋舍分页")
+    @GetMapping("/biz/pigpen/page")
+    public CommonResult<Page<BasePigpen>> page(BasePigpenPageParam basePigpenPageParam) {
+        return CommonResult.data(basePigpenService.page(basePigpenPageParam));
+    }
+
+    /**
+     * 获取base_pigpen树
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 2)
+    @ApiOperation("获取栋舍树")
+    @GetMapping("/biz/pigpen/tree")
+    public CommonResult<List<Tree<String>>> tree() {
+        return CommonResult.data(basePigpenService.tree());
+    }
+
+    /**
+     * 添加base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 2)
+    @ApiOperation("添加栋舍")
+    @CommonLog("添加栋舍")
+    @PostMapping("/biz/pigpen/add")
+    public CommonResult<String> add(@RequestBody @Valid BasePigpenAddParam basePigpenAddParam) {
+        basePigpenService.add(basePigpenAddParam);
+        return CommonResult.ok();
+    }
+
+    /**
+     * 编辑base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 3)
+    @ApiOperation("编辑栋舍")
+    @CommonLog("编辑栋舍")
+    @PostMapping("/biz/pigpen/edit")
+    public CommonResult<String> edit(@RequestBody @Valid BasePigpenEditParam basePigpenEditParam) {
+        basePigpenService.edit(basePigpenEditParam);
+        return CommonResult.ok();
+    }
+
+    /**
+     * 删除base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 4)
+    @ApiOperation("删除栋舍")
+    @CommonLog("删除栋舍")
+    @PostMapping("/biz/pigpen/delete")
+    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
+                                                   CommonValidList<BasePigpenIdParam> basePigpenIdParamList) {
+        basePigpenService.delete(basePigpenIdParamList);
+        return CommonResult.ok();
+    }
+
+    /**
+     * 获取base_pigpen详情
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    @ApiOperationSupport(order = 5)
+    @ApiOperation("获取栋舍详情")
+    @GetMapping("/biz/pigpen/detail")
+    public CommonResult<BasePigpen> detail(@Valid BasePigpenIdParam basePigpenIdParam) {
+        return CommonResult.data(basePigpenService.detail(basePigpenIdParam));
+    }
+}

+ 84 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/entity/BasePigpen.java

@@ -0,0 +1,84 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.entity;
+
+
+import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * base_pigpen实体
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+@Setter
+@TableName("base_pigpen")
+public class BasePigpen {
+
+    /** ID */
+    @TableId
+    @ApiModelProperty(value = "ID", position = 1)
+    private String id;
+
+    /** 栋舍名字 */
+    @ApiModelProperty(value = "栋舍名字", position = 2)
+    private String buildName;
+
+    /** 父级ID */
+    @ApiModelProperty(value = "父级ID", position = 3)
+    private String parentId;
+
+    /** 类型 0:栋舍 1:楼层 2:单元 */
+    @ApiModelProperty(value = "类型 0:栋舍 1:楼层 2:单元", position = 4)
+    private Integer type;
+
+    /** 阶段 */
+    @ApiModelProperty(value = "阶段", position = 5)
+    private String remarks;
+
+    /** 组织id */
+    @ApiModelProperty(value = "组织id", position = 6)
+    private String orgId;
+
+    /** 排序 */
+    @ApiModelProperty(value = "排序", position = 7)
+    private Integer sort;
+
+    /** 逻辑删除标识 */
+    @ApiModelProperty(value = "逻辑删除标识", position = 8)
+    private String deleteFlag;
+
+    /** 创建者 */
+    @ApiModelProperty(value = "创建者", position = 9)
+    private String createBy;
+
+    /** 修改者 */
+    @ApiModelProperty(value = "修改者", position = 10)
+    private String updateBy;
+
+    /** 创建时间 */
+    @ApiModelProperty(value = "创建时间", position = 10)
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    /** 修改时间 */
+    @ApiModelProperty(value = "修改时间", position = 11)
+    @TableField(fill = FieldFill.UPDATE)
+    private Date updateTime;
+}

+ 48 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/enums/BasePigpenTypeEnum.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.enums;
+
+import lombok.Getter;
+import vip.xiaonuo.common.exception.CommonException;
+
+/**
+ * base_pigpen枚举
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+public enum BasePigpenTypeEnum {
+
+    /** 栋舍 */
+    building(0),
+
+    /** 楼层 */
+    floor(1),
+
+    /** 单元 */
+    unit(2);
+
+    private final Integer value;
+
+    BasePigpenTypeEnum(Integer value) {
+        this.value = value;
+    }
+
+    public static void validate(Integer value) {
+        boolean flag = building.getValue().equals(value) || floor.getValue().equals(value) || unit.getValue().equals(value);
+        if(!flag) {
+            throw new CommonException("不支持的栋舍分类:{}", value);
+        }
+    }
+}

+ 26 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/mapper/BasePigpenMapper.java

@@ -0,0 +1,26 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import vip.xiaonuo.modular.pigpen.entity.BasePigpen;
+
+
+/**
+ * base_pigpenMapper接口
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+public interface BasePigpenMapper extends BaseMapper<BasePigpen> {
+}

+ 5 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/mapper/mapping/BasePigpenMapper.xml

@@ -0,0 +1,5 @@
+<?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="vip.xiaonuo.modular.pigpen.mapper.BasePigpenMapper">
+
+</mapper>

+ 62 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/param/BasePigpenAddParam.java

@@ -0,0 +1,62 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * base_pigpen添加参数
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+@Setter
+public class BasePigpenAddParam {
+
+    /** 栋舍名字 */
+    @ApiModelProperty(value = "栋舍名字", required = true, position = 1)
+    @NotBlank(message = "buildName不能为空")
+    private String buildName;
+
+    /** 父级ID */
+    @ApiModelProperty(value = "父级ID", required = true, position = 2)
+    @NotNull(message = "parentId不能为空")
+    private String parentId;
+
+    /** 类型 0:栋舍 1:楼层 2:单元 */
+    @ApiModelProperty(value = "类型 0:栋舍 1:楼层 2:单元", position = 3)
+    private Integer type;
+
+    /** 阶段 */
+    @ApiModelProperty(value = "阶段", position = 4)
+    private String remarks;
+
+    /** 排序 */
+    @ApiModelProperty(value = "排序", required = true, position = 5)
+    @NotNull(message = "sort不能为空")
+    private Integer sort;
+
+    /** 所属组织 */
+    @ApiModelProperty(value = "所属组织")
+    private String orgId;
+
+
+}

+ 71 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/param/BasePigpenEditParam.java

@@ -0,0 +1,71 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * base_pigpen编辑参数
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+@Setter
+public class BasePigpenEditParam {
+
+    /** ID */
+    @ApiModelProperty(value = "ID", required = true, position = 1)
+    @NotNull(message = "id不能为空")
+    private String id;
+
+    /** 栋舍名字 */
+    @ApiModelProperty(value = "栋舍名字", required = true, position = 2)
+    @NotBlank(message = "buildName不能为空")
+    private String buildName;
+
+    /** 父级ID */
+    @ApiModelProperty(value = "父级ID", required = true, position = 3)
+    @NotNull(message = "parentId不能为空")
+    private String parentId;
+
+    /** 类型 0:栋舍 1:楼层 2:单元 */
+    @ApiModelProperty(value = "类型 0:栋舍 1:楼层 2:单元", position = 4)
+    private Integer type;
+
+    /** 阶段 */
+    @ApiModelProperty(value = "阶段", position = 5)
+    private String remarks;
+
+    /** 逻辑删除标识 */
+    @ApiModelProperty(value = "逻辑删除标识 ", position = 6)
+    private Long deleted;
+
+    /** 组织id */
+    @ApiModelProperty(value = "组织id", position = 7)
+    private String orgId;
+
+    /** 排序 */
+    @ApiModelProperty(value = "排序", required = true, position = 8)
+    @NotNull(message = "sort不能为空")
+    private Integer sort;
+
+
+}

+ 35 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/param/BasePigpenIdParam.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * base_pigpenId参数
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+@Setter
+public class BasePigpenIdParam {
+
+    /** ID */
+    @ApiModelProperty(value = "ID", required = true)
+    @NotBlank(message = "id不能为空")
+    private String id;
+}

+ 59 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/param/BasePigpenPageParam.java

@@ -0,0 +1,59 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * base_pigpen查询参数
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Getter
+@Setter
+public class BasePigpenPageParam {
+
+    /** 当前页 */
+    @ApiModelProperty(value = "当前页码")
+    private Integer current;
+
+    /** 每页条数 */
+    @ApiModelProperty(value = "每页条数")
+    private Integer size;
+
+    /** 排序字段 */
+    @ApiModelProperty(value = "排序字段,字段驼峰名称,如:userName")
+    private String sortField;
+
+    /** 排序方式 */
+    @ApiModelProperty(value = "排序方式,升序:ASCEND;降序:DESCEND")
+    private String sortOrder;
+
+    /** 父id */
+    @ApiModelProperty(value = "父id")
+    private String parentId;
+
+    /** 关键词 */
+    @ApiModelProperty(value = "关键词")
+    private String searchKey;
+
+    /** 所属组织 */
+    @ApiModelProperty(value = "所属组织")
+    private String orgId;
+
+}

+ 108 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/service/BasePigpenService.java

@@ -0,0 +1,108 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.service;
+import cn.hutool.core.lang.tree.Tree;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import vip.xiaonuo.modular.pigpen.entity.BasePigpen;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenAddParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenEditParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenIdParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenPageParam;
+
+import java.util.List;
+
+/**
+ * base_pigpenService接口
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+public interface BasePigpenService extends IService<BasePigpen> {
+
+    /**
+     * 获取base_pigpen分页
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    Page<BasePigpen> page(BasePigpenPageParam basePigpenPageParam);
+
+    /**
+     * 添加base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    void add(BasePigpenAddParam basePigpenAddParam);
+
+    /**
+     * 编辑base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    void edit(BasePigpenEditParam basePigpenEditParam);
+
+    /**
+     * 删除base_pigpen
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    void delete(List<BasePigpenIdParam> basePigpenIdParamList);
+
+    /**
+     * 获取base_pigpen详情
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     */
+    BasePigpen detail(BasePigpenIdParam basePigpenIdParam);
+
+    /**
+     * 获取base_pigpen详情
+     *
+     * @author newspaper
+     * @date  2023/12/05 08:55
+     **/
+    BasePigpen queryEntity(String id);
+
+
+    /**
+     * 获取所有栋舍
+     *
+     * @author newspaper
+     * @date 2023/12/05 11:23
+     **/
+    List<BasePigpen> getAllPigpenList(String orgId);
+
+
+    /**
+     * 根据id获取所有的子数据列表
+     *
+     * @author newspaper
+     * @date 2023/12/05 11:23
+     **/
+    List<BasePigpen> getChildListById(List<BasePigpen> originDataList, String id, boolean includeSelf);
+
+    /**
+     * 根据id获取数据
+     *
+     * @author newspaper
+     * @date 2022/8/15 14:55
+     **/
+    BasePigpen getById(List<BasePigpen> originDataList, String id);
+
+    List<Tree<String>> tree();
+}

+ 206 - 0
snowy-web-app/src/main/java/vip/xiaonuo/modular/pigpen/service/impl/BasePigpenServiceImpl.java

@@ -0,0 +1,206 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.modular.pigpen.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollStreamUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNode;
+import cn.hutool.core.lang.tree.TreeUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
+import vip.xiaonuo.common.enums.CommonSortOrderEnum;
+import vip.xiaonuo.common.exception.CommonException;
+import vip.xiaonuo.common.listener.CommonDataChangeEventCenter;
+import vip.xiaonuo.common.page.CommonPageRequest;
+import vip.xiaonuo.core.enums.BaseDataTypeEnum;
+import vip.xiaonuo.modular.pigpen.entity.BasePigpen;
+import vip.xiaonuo.modular.pigpen.mapper.BasePigpenMapper;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenAddParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenEditParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenIdParam;
+import vip.xiaonuo.modular.pigpen.param.BasePigpenPageParam;
+import vip.xiaonuo.modular.pigpen.service.BasePigpenService;
+import vip.xiaonuo.sys.core.enums.SysDataTypeEnum;
+
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * base_pigpenService接口实现类
+ *
+ * @author newspaper
+ * @date  2023/12/05 08:55
+ **/
+@Service
+public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePigpen> implements BasePigpenService {
+
+    @Override
+    public Page<BasePigpen> page(BasePigpenPageParam basePigpenPageParam) {
+        String orgId = StpLoginUserUtil.getLoginUser().getOrgId();
+        QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().select(BasePigpen::getId, BasePigpen::getParentId, BasePigpen::getBuildName,
+                BasePigpen::getBuildName, BasePigpen::getSort);
+        queryWrapper.lambda().eq(BasePigpen::getOrgId,orgId);
+        if(ObjectUtil.isNotEmpty(basePigpenPageParam.getParentId())) {
+            queryWrapper.lambda().eq(BasePigpen::getParentId, basePigpenPageParam.getParentId());
+        }
+        if(ObjectUtil.isNotEmpty(basePigpenPageParam.getSearchKey())) {
+            queryWrapper.lambda().like(BasePigpen::getBuildName, basePigpenPageParam.getSearchKey());
+        }
+
+
+        if(ObjectUtil.isAllNotEmpty(basePigpenPageParam.getSortField(), basePigpenPageParam.getSortOrder())) {
+            CommonSortOrderEnum.validate(basePigpenPageParam.getSortOrder());
+            queryWrapper.orderBy(true, basePigpenPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
+                    StrUtil.toUnderlineCase(basePigpenPageParam.getSortField()));
+        } else {
+            queryWrapper.lambda().orderByAsc(BasePigpen::getId);
+        }
+        return this.page(CommonPageRequest.defaultPage(), queryWrapper);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void add(BasePigpenAddParam basePigpenAddParam) {
+        SaBaseLoginUser user = StpLoginUserUtil.getLoginUser();
+        String orgId = user.getOrgId();
+        BasePigpen basePigpen = BeanUtil.toBean(basePigpenAddParam, BasePigpen.class);
+        if (basePigpen.getParentId().equals("0")){
+            basePigpen.setType(0);
+        }else {
+            basePigpen.setType(this.queryEntity(basePigpen.getParentId()).getType()+1);
+        }
+        basePigpen.setOrgId(orgId);
+        boolean repeatName = this.count(new LambdaQueryWrapper<BasePigpen>().eq(BasePigpen::getParentId, basePigpen.getParentId())
+                .eq(BasePigpen::getBuildName, basePigpen.getBuildName())) > 0;
+        if(repeatName) {
+            throw new CommonException("存在重复的同级栋舍,名称为:{}", basePigpen.getBuildName());
+        }
+        basePigpen.setCreateBy(user.getId());
+        this.save(basePigpen);
+
+        // 发布增加事件
+        CommonDataChangeEventCenter.doAddWithData(BaseDataTypeEnum.PIGPEN.getValue(), JSONUtil.createArray().put(basePigpen));
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void edit(BasePigpenEditParam basePigpenEditParam) {
+        SaBaseLoginUser user = StpLoginUserUtil.getLoginUser();
+        BasePigpen basePigpen = this.queryEntity(basePigpenEditParam.getId());
+        BeanUtil.copyProperties(basePigpenEditParam, basePigpen);
+        if (basePigpen.getParentId().equals("0")){
+            basePigpen.setType(0);
+        }else {
+            basePigpen.setType(this.queryEntity(basePigpen.getParentId()).getType()+1);
+        }
+        boolean repeatName = this.count(new LambdaQueryWrapper<BasePigpen>().eq(BasePigpen::getParentId, basePigpen.getParentId())
+                .eq(BasePigpen::getBuildName, basePigpen.getBuildName()).ne(BasePigpen::getId, basePigpen.getId())) > 0;
+        if(repeatName) {
+            throw new CommonException("存在重复的同级栋舍,名称为:{}", basePigpen.getBuildName());
+        }
+        List<BasePigpen> originDataList = this.getAllPigpenList(basePigpen.getOrgId());
+        boolean errorLevel = this.getChildListById(originDataList, basePigpen.getId(), true).stream()
+                .map(BasePigpen::getId).collect(Collectors.toList()).contains(basePigpen.getParentId());
+        if(errorLevel) {
+            throw new CommonException("不可选择上级栋舍:{}", this.getById(originDataList, basePigpen.getParentId()).getBuildName());
+        }
+        basePigpen.setUpdateBy(user.getId());
+        this.updateById(basePigpen);
+
+        // 发布更新事件
+        CommonDataChangeEventCenter.doUpdateWithData(BaseDataTypeEnum.PIGPEN.getValue(), JSONUtil.createArray().put(basePigpen));
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void delete(List<BasePigpenIdParam> basePigpenIdParamList) {
+        List<String> toDeletePigpenIdList = CollStreamUtil.toList(basePigpenIdParamList, BasePigpenIdParam::getId);
+        // 执行删除
+        this.removeByIds(toDeletePigpenIdList);
+
+        // 发布删除事件
+        CommonDataChangeEventCenter.doDeleteWithDataId(SysDataTypeEnum.ORG.getValue(), toDeletePigpenIdList);
+    }
+
+    @Override
+    public BasePigpen detail(BasePigpenIdParam basePigpenIdParam) {
+        return this.queryEntity(basePigpenIdParam.getId());
+    }
+
+    @Override
+    public BasePigpen queryEntity(String id) {
+        BasePigpen basePigpen = this.getById(id);
+        if(ObjectUtil.isEmpty(basePigpen)) {
+            throw new CommonException("栋舍不存在,id值为:{}", id);
+        }
+        return basePigpen;
+    }
+
+    @Override
+    public List<BasePigpen> getAllPigpenList(String orgId) {
+        List<BasePigpen> orgList = this.list(new LambdaQueryWrapper<BasePigpen>().eq(BasePigpen::getOrgId,orgId).orderByAsc(BasePigpen::getId));
+        return orgList;
+    }
+
+    @Override
+    public List<BasePigpen> getChildListById(List<BasePigpen> originDataList, String id, boolean includeSelf) {
+        List<BasePigpen> resultList = CollectionUtil.newArrayList();
+        execRecursionFindChild(originDataList, id, resultList);
+        if (includeSelf) {
+            BasePigpen self = this.getById(originDataList, id);
+            if (ObjectUtil.isNotEmpty(self)) {
+                resultList.add(self);
+            }
+        }
+        return resultList;
+    }
+
+    public void execRecursionFindChild(List<BasePigpen> originDataList, String id, List<BasePigpen> resultList) {
+        originDataList.forEach(item -> {
+            if(item.getParentId().equals(id)) {
+                resultList.add(item);
+                execRecursionFindChild(originDataList, item.getId(), resultList);
+            }
+        });
+    }
+
+    @Override
+    public BasePigpen getById(List<BasePigpen> originDataList, String id) {
+        int index = CollStreamUtil.toList(originDataList, BasePigpen::getId).indexOf(id);
+        return index == -1?null:originDataList.get(index);
+    }
+
+    @Override
+    public List<Tree<String>> tree() {
+        String orgId = StpLoginUserUtil.getLoginUser().getOrgId();
+        List<BasePigpen> allPigpenList = this.getAllPigpenList(orgId);
+        List<TreeNode<String>> treeNodeList = allPigpenList.stream().map(basePigpen ->
+                new TreeNode<>(basePigpen.getId(), basePigpen.getParentId(),
+                        basePigpen.getBuildName(), basePigpen.getSort()).setExtra(JSONUtil.parseObj(basePigpen)))
+                .collect(Collectors.toList());
+        return TreeUtil.build(treeNodeList, "0");
+    }
+}

+ 2 - 2
snowy-web-app/src/main/resources/application.properties

@@ -96,9 +96,9 @@ spring.jackson.locale=zh_CN
 # redis configuration
 #########################################
 spring.redis.database=1
-spring.redis.host=127.0.0.1
+spring.redis.host=121.36.134.218
 spring.redis.port=6379
-spring.redis.password=
+spring.redis.password=hm123456
 spring.redis.timeout=10s
 
 spring.redis.lettuce.pool.max-active=200