mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-28 16:57:11 +08:00
feat: 新增系统管理/字典管理(列表、新增、修改、删除、导出、查询字典项列表、新增字典项、修改字典项、删除字典项)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.mapper;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||
|
||||
/**
|
||||
* 字典项 Mapper
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
public interface DictItemMapper extends BaseMapper<DictItemDO> {}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.mapper;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictDO;
|
||||
|
||||
/**
|
||||
* 字典 Mapper
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
public interface DictMapper extends BaseMapper<DictDO> {}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
|
||||
/**
|
||||
* 字典实体
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_dict")
|
||||
public class DictDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
|
||||
/**
|
||||
* 字典项实体
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_dict_item")
|
||||
public class DictItemDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 字典ID
|
||||
*/
|
||||
private Long dictId;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.query;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.annotation.Query;
|
||||
|
||||
/**
|
||||
* 字典项查询条件
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "字典项查询条件")
|
||||
public class DictItemQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典 ID
|
||||
*/
|
||||
@Schema(description = "字典 ID")
|
||||
@Query
|
||||
private Long dictId;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.query;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.annotation.Query;
|
||||
|
||||
/**
|
||||
* 字典查询条件
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "字典查询条件")
|
||||
public class DictQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称")
|
||||
@Query(blurry = {"code", "name", "description"})
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.request;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseRequest;
|
||||
|
||||
/**
|
||||
* 创建或修改字典项信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建或修改字典项信息")
|
||||
public class DictItemRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Schema(description = "字典标签", example = "通知")
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@Schema(description = "字典值", example = "1")
|
||||
@NotBlank(message = "字典值不能为空")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
@Schema(description = "背景颜色", example = "blue")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "通知描述信息")
|
||||
@Length(max = 200, message = "描述长度不能超过 {max} 个字符")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 所属字典
|
||||
*/
|
||||
@Schema(description = "所属字典", example = "1")
|
||||
@NotNull(message = "所属字典不能为空")
|
||||
private Long dictId;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.request;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseRequest;
|
||||
|
||||
/**
|
||||
* 创建或修改字典信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建或修改字典信息")
|
||||
public class DictRequest extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称", example = "公告类型")
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Schema(description = "字典编码", example = "announcement_type")
|
||||
@NotBlank(message = "字典编码不能为空")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "公告类型描述信息")
|
||||
@Length(max = 200, message = "描述长度不能超过 {max} 个字符")
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDetailVO;
|
||||
|
||||
/**
|
||||
* 字典详情信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@Schema(description = "字典详情信息")
|
||||
public class DictDetailVO extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称", example = "公告类型")
|
||||
@ExcelProperty(value = "字典名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Schema(description = "字典编码", example = "announcement_type")
|
||||
@ExcelProperty(value = "字典编码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "公告类型描述信息")
|
||||
@ExcelProperty(value = "描述")
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDetailVO;
|
||||
|
||||
/**
|
||||
* 字典项详情信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@Schema(description = "字典项详情信息")
|
||||
public class DictItemDetailVO extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Schema(description = "字典标签", example = "通知")
|
||||
@ExcelProperty(value = "字典标签")
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@Schema(description = "字典值", example = "1")
|
||||
@ExcelProperty(value = "字典值")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
@Schema(description = "背景颜色", example = "blue")
|
||||
@ExcelProperty(value = "背景颜色")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
@ExcelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "通知描述信息")
|
||||
@ExcelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 所属字典
|
||||
*/
|
||||
@Schema(description = "所属字典", example = "1")
|
||||
@ExcelProperty(value = "所属字典")
|
||||
private Long dictId;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseVO;
|
||||
|
||||
/**
|
||||
* 字典项信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "字典项信息")
|
||||
public class DictItemVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Schema(description = "字典标签", example = "通知")
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@Schema(description = "字典值", example = "1")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 背景颜色
|
||||
*/
|
||||
@Schema(description = "背景颜色", example = "blue")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "通知描述信息")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseVO;
|
||||
|
||||
/**
|
||||
* 字典信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "字典信息")
|
||||
public class DictVO extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称", example = "公告类型")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Schema(description = "字典编码", example = "announcement_type")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述", example = "公告类型描述信息")
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseService;
|
||||
import top.charles7c.cnadmin.system.model.query.DictItemQuery;
|
||||
import top.charles7c.cnadmin.system.model.request.DictItemRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictItemDetailVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictItemVO;
|
||||
|
||||
/**
|
||||
* 字典项业务接口
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
public interface DictItemService extends BaseService<DictItemVO, DictItemDetailVO, DictItemQuery, DictItemRequest> {
|
||||
|
||||
/**
|
||||
* 根据字典 ID 列表删除
|
||||
*
|
||||
* @param dictIds
|
||||
* 字典 ID 列表
|
||||
*/
|
||||
void deleteByDictIds(List<Long> dictIds);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.service;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseService;
|
||||
import top.charles7c.cnadmin.system.model.query.DictQuery;
|
||||
import top.charles7c.cnadmin.system.model.request.DictRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictDetailVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictVO;
|
||||
|
||||
/**
|
||||
* 字典业务接口
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
public interface DictService extends BaseService<DictVO, DictDetailVO, DictQuery, DictRequest> {}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
|
||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
||||
import top.charles7c.cnadmin.system.mapper.DictItemMapper;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictItemDO;
|
||||
import top.charles7c.cnadmin.system.model.query.DictItemQuery;
|
||||
import top.charles7c.cnadmin.system.model.request.DictItemRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictItemDetailVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictItemVO;
|
||||
import top.charles7c.cnadmin.system.service.DictItemService;
|
||||
|
||||
/**
|
||||
* 字典项业务实现
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictItemServiceImpl
|
||||
extends BaseServiceImpl<DictItemMapper, DictItemDO, DictItemVO, DictItemDetailVO, DictItemQuery, DictItemRequest>
|
||||
implements DictItemService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(DictItemRequest request) {
|
||||
String value = request.getValue();
|
||||
CheckUtils.throwIf(this.checkValueExists(value, null, request.getDictId()), "新增失败,字典值 [{}] 已存在", value);
|
||||
return super.add(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DictItemRequest request, Long id) {
|
||||
String value = request.getValue();
|
||||
CheckUtils.throwIf(this.checkValueExists(value, id, request.getDictId()), "修改失败,字典值 [{}] 已存在", value);
|
||||
super.update(request, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDictIds(List<Long> dictIds) {
|
||||
baseMapper.lambdaUpdate().in(DictItemDO::getDictId, dictIds).remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字典值是否存在
|
||||
*
|
||||
* @param value
|
||||
* 字典值
|
||||
* @param id
|
||||
* ID
|
||||
* @param dictId
|
||||
* 字典 ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkValueExists(String value, Long id, Long dictId) {
|
||||
return baseMapper.lambdaQuery().eq(DictItemDO::getValue, value).eq(DictItemDO::getDictId, dictId)
|
||||
.ne(null != id, DictItemDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
|
||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
||||
import top.charles7c.cnadmin.system.mapper.DictMapper;
|
||||
import top.charles7c.cnadmin.system.model.entity.DictDO;
|
||||
import top.charles7c.cnadmin.system.model.query.DictQuery;
|
||||
import top.charles7c.cnadmin.system.model.request.DictRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictDetailVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.DictVO;
|
||||
import top.charles7c.cnadmin.system.service.DictItemService;
|
||||
import top.charles7c.cnadmin.system.service.DictService;
|
||||
|
||||
/**
|
||||
* 字典业务实现
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/11 21:29
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO, DictDetailVO, DictQuery, DictRequest>
|
||||
implements DictService {
|
||||
|
||||
private final DictItemService dictItemService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(DictRequest request) {
|
||||
String name = request.getName();
|
||||
CheckUtils.throwIf(this.checkNameExists(name, null), "新增失败,[{}] 已存在", name);
|
||||
String code = request.getCode();
|
||||
CheckUtils.throwIf(this.checkCodeExists(code, null), "新增失败,[{}] 已存在", code);
|
||||
return super.add(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DictRequest request, Long id) {
|
||||
String name = request.getName();
|
||||
CheckUtils.throwIf(this.checkNameExists(name, id), "修改失败,[{}] 已存在", name);
|
||||
String code = request.getCode();
|
||||
CheckUtils.throwIf(this.checkCodeExists(code, id), "修改失败,[{}] 已存在", code);
|
||||
super.update(request, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> ids) {
|
||||
dictItemService.deleteByDictIds(ids);
|
||||
super.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查名称是否存在
|
||||
*
|
||||
* @param name
|
||||
* 名称
|
||||
* @param id
|
||||
* ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(DictDO::getName, name).ne(null != id, DictDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查编码是否存在
|
||||
*
|
||||
* @param code
|
||||
* 编码
|
||||
* @param id
|
||||
* ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkCodeExists(String code, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(DictDO::getCode, code).ne(null != id, DictDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user