From ca51702035f9a9f87fc7fc627aa4cd47f58b38d0 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sat, 16 Sep 2023 00:36:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=AE=A1=E7=90=86/=E5=AD=97=E5=85=B8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=88=E5=88=97=E8=A1=A8=E3=80=81=E6=96=B0=E5=A2=9E=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=81=E5=88=A0=E9=99=A4=E3=80=81=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E3=80=81=E6=9F=A5=E8=AF=A2=E5=AD=97=E5=85=B8=E9=A1=B9?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E3=80=81=E6=96=B0=E5=A2=9E=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E9=A1=B9=E3=80=81=E4=BF=AE=E6=94=B9=E5=AD=97=E5=85=B8=E9=A1=B9?= =?UTF-8?q?=E3=80=81=E5=88=A0=E9=99=A4=E5=AD=97=E5=85=B8=E9=A1=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cnadmin/system/mapper/DictItemMapper.java | 28 ++ .../cnadmin/system/mapper/DictMapper.java | 28 ++ .../cnadmin/system/model/entity/DictDO.java | 51 ++ .../system/model/entity/DictItemDO.java | 66 +++ .../system/model/query/DictItemQuery.java | 45 ++ .../cnadmin/system/model/query/DictQuery.java | 46 ++ .../system/model/request/DictItemRequest.java | 80 ++++ .../system/model/request/DictRequest.java | 61 +++ .../cnadmin/system/model/vo/DictDetailVO.java | 61 +++ .../system/model/vo/DictItemDetailVO.java | 82 ++++ .../cnadmin/system/model/vo/DictItemVO.java | 66 +++ .../cnadmin/system/model/vo/DictVO.java | 54 +++ .../system/service/DictItemService.java | 42 ++ .../cnadmin/system/service/DictService.java | 31 ++ .../service/impl/DictItemServiceImpl.java | 84 ++++ .../system/service/impl/DictServiceImpl.java | 102 ++++ continew-admin-ui/src/api/system/dict-item.ts | 57 +++ continew-admin-ui/src/api/system/dict.ts | 54 +++ continew-admin-ui/src/locale/en-US.ts | 2 + continew-admin-ui/src/locale/zh-CN.ts | 2 + .../src/router/routes/modules/demo/form.ts | 2 +- .../src/router/routes/modules/system.ts | 35 +- .../src/views/system/dict/index.vue | 453 ++++++++++++++++++ .../src/views/system/dict/item.vue | 363 ++++++++++++++ .../src/views/system/dict/locale/en-US.ts | 3 + .../src/views/system/dict/locale/zh-CN.ts | 3 + .../controller/system/DictController.java | 42 ++ .../controller/system/DictItemController.java | 43 ++ .../db/changelog/db.changelog-master.yaml | 6 + .../changelog/v1.0.0/continew-admin_data.sql | 30 +- .../changelog/v1.1.0/continew-admin_data.sql | 11 +- .../v1.2.0/continew-admin_column.sql | 2 + .../changelog/v1.2.0/continew-admin_data.sql | 25 + .../changelog/v1.2.0/continew-admin_table.sql | 35 ++ 34 files changed, 2061 insertions(+), 34 deletions(-) create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictItemMapper.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictMapper.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictDO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictItemDO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictItemQuery.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictQuery.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictItemRequest.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictRequest.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictDetailVO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemDetailVO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemVO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictVO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictItemService.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictService.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictItemServiceImpl.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictServiceImpl.java create mode 100644 continew-admin-ui/src/api/system/dict-item.ts create mode 100644 continew-admin-ui/src/api/system/dict.ts create mode 100644 continew-admin-ui/src/views/system/dict/index.vue create mode 100644 continew-admin-ui/src/views/system/dict/item.vue create mode 100644 continew-admin-ui/src/views/system/dict/locale/en-US.ts create mode 100644 continew-admin-ui/src/views/system/dict/locale/zh-CN.ts create mode 100644 continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictController.java create mode 100644 continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictItemController.java create mode 100644 continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_column.sql create mode 100644 continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_data.sql create mode 100644 continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_table.sql diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictItemMapper.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictItemMapper.java new file mode 100644 index 00000000..fdfcf180 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictItemMapper.java @@ -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 {} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictMapper.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictMapper.java new file mode 100644 index 00000000..144623c2 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/DictMapper.java @@ -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 {} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictDO.java new file mode 100644 index 00000000..d1b5da9e --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictDO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictItemDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictItemDO.java new file mode 100644 index 00000000..ff7d5850 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/DictItemDO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictItemQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictItemQuery.java new file mode 100644 index 00000000..b5fc6fee --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictItemQuery.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictQuery.java new file mode 100644 index 00000000..20837fbc --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/DictQuery.java @@ -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; + +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictItemRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictItemRequest.java new file mode 100644 index 00000000..6154f914 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictItemRequest.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictRequest.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictRequest.java new file mode 100644 index 00000000..7403235d --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/DictRequest.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictDetailVO.java new file mode 100644 index 00000000..4aa517fe --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictDetailVO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemDetailVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemDetailVO.java new file mode 100644 index 00000000..4de386fa --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemDetailVO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemVO.java new file mode 100644 index 00000000..5b8aeb35 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictItemVO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictVO.java new file mode 100644 index 00000000..121c13f2 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/DictVO.java @@ -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; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictItemService.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictItemService.java new file mode 100644 index 00000000..3a0f01cf --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictItemService.java @@ -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 { + + /** + * 根据字典 ID 列表删除 + * + * @param dictIds + * 字典 ID 列表 + */ + void deleteByDictIds(List dictIds); +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictService.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictService.java new file mode 100644 index 00000000..b241d4a5 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/DictService.java @@ -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 {} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictItemServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictItemServiceImpl.java new file mode 100644 index 00000000..bd9e91f2 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictItemServiceImpl.java @@ -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 + 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 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(); + } +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictServiceImpl.java new file mode 100644 index 00000000..95dc1ac1 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DictServiceImpl.java @@ -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 + 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 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(); + } +} \ No newline at end of file diff --git a/continew-admin-ui/src/api/system/dict-item.ts b/continew-admin-ui/src/api/system/dict-item.ts new file mode 100644 index 00000000..a0d903ba --- /dev/null +++ b/continew-admin-ui/src/api/system/dict-item.ts @@ -0,0 +1,57 @@ +import axios from 'axios'; +import qs from 'query-string'; + +const BASE_URL = '/system/dict/item'; + +export interface DataRecord { + id?: number; + label: string; + value: string; + color?: string; + sort?: number; + description: string; + dictId?: number; + createUser?: string; + createTime?: string; + updateUser?: string; + updateTime?: string; + createUserString?: string; + updateUserString?: string; +} + +export interface ListParam { + dictId?: number; + page?: number; + size?: number; + sort?: Array; +} + +export interface ListRes { + list: DataRecord[]; + total: number; +} + +export function list(params: ListParam) { + return axios.get(`${BASE_URL}`, { + params, + paramsSerializer: (obj) => { + return qs.stringify(obj); + }, + }); +} + +export function get(id: number) { + return axios.get(`${BASE_URL}/${id}`); +} + +export function add(req: DataRecord) { + return axios.post(BASE_URL, req); +} + +export function update(req: DataRecord, id: number) { + return axios.put(`${BASE_URL}/${id}`, req); +} + +export function del(ids: number | Array) { + return axios.delete(`${BASE_URL}/${ids}`); +} diff --git a/continew-admin-ui/src/api/system/dict.ts b/continew-admin-ui/src/api/system/dict.ts new file mode 100644 index 00000000..ee11112f --- /dev/null +++ b/continew-admin-ui/src/api/system/dict.ts @@ -0,0 +1,54 @@ +import axios from 'axios'; +import qs from 'query-string'; + +const BASE_URL = '/system/dict'; + +export interface DataRecord { + id?: number; + name: string; + code: string; + description?: string; + createUser?: string; + createTime?: string; + updateUser?: string; + updateTime?: string; + createUserString?: string; + updateUserString?: string; +} + +export interface ListParam { + name?: string; + page?: number; + size?: number; + sort?: Array; +} + +export interface ListRes { + list: DataRecord[]; + total: number; +} + +export function list(params: ListParam) { + return axios.get(`${BASE_URL}`, { + params, + paramsSerializer: (obj) => { + return qs.stringify(obj); + }, + }); +} + +export function get(id: number) { + return axios.get(`${BASE_URL}/${id}`); +} + +export function add(req: DataRecord) { + return axios.post(BASE_URL, req); +} + +export function update(req: DataRecord, id: number) { + return axios.put(`${BASE_URL}/${id}`, req); +} + +export function del(ids: number | Array) { + return axios.delete(`${BASE_URL}/${ids}`); +} diff --git a/continew-admin-ui/src/locale/en-US.ts b/continew-admin-ui/src/locale/en-US.ts index 73628c68..f5fdff45 100644 --- a/continew-admin-ui/src/locale/en-US.ts +++ b/continew-admin-ui/src/locale/en-US.ts @@ -5,6 +5,7 @@ import localeRole from '@/views/system/role/locale/en-US'; import localeMenu from '@/views/system/menu/locale/en-US'; import localeDept from '@/views/system/dept/locale/en-US'; import localeAnnouncement from '@/views/system/announcement/locale/en-US'; +import localeDict from '@/views/system/dict/locale/en-US'; import localeGenerator from '@/views/tool/generator/locale/en-US'; @@ -60,6 +61,7 @@ export default { ...localeMenu, ...localeDept, ...localeAnnouncement, + ...localeDict, ...localeGenerator, diff --git a/continew-admin-ui/src/locale/zh-CN.ts b/continew-admin-ui/src/locale/zh-CN.ts index f0cb410d..edbbea5d 100644 --- a/continew-admin-ui/src/locale/zh-CN.ts +++ b/continew-admin-ui/src/locale/zh-CN.ts @@ -5,6 +5,7 @@ import localeRole from '@/views/system/role/locale/zh-CN'; import localeMenu from '@/views/system/menu/locale/zh-CN'; import localeDept from '@/views/system/dept/locale/zh-CN'; import localeAnnouncement from '@/views/system/announcement/locale/zh-CN'; +import localeDict from '@/views/system/dict/locale/zh-CN'; import localeGenerator from '@/views/tool/generator/locale/zh-CN'; @@ -60,6 +61,7 @@ export default { ...localeMenu, ...localeDept, ...localeAnnouncement, + ...localeDict, ...localeGenerator, diff --git a/continew-admin-ui/src/router/routes/modules/demo/form.ts b/continew-admin-ui/src/router/routes/modules/demo/form.ts index 7fceef0b..eede2079 100644 --- a/continew-admin-ui/src/router/routes/modules/demo/form.ts +++ b/continew-admin-ui/src/router/routes/modules/demo/form.ts @@ -7,7 +7,7 @@ const FORM: AppRouteRecordRaw = { component: DEFAULT_LAYOUT, meta: { locale: 'menu.form', - icon: 'bookmark', + icon: 'select-all', requiresAuth: true, order: 901, }, diff --git a/continew-admin-ui/src/router/routes/modules/system.ts b/continew-admin-ui/src/router/routes/modules/system.ts index 7b723470..c366a20e 100644 --- a/continew-admin-ui/src/router/routes/modules/system.ts +++ b/continew-admin-ui/src/router/routes/modules/system.ts @@ -21,6 +21,15 @@ const System: AppRouteRecordRaw = { requiresAuth: true, }, }, + { + name: 'Dept', + path: '/system/dept', + component: () => import('@/views/system/dept/index.vue'), + meta: { + locale: 'menu.system.dept.list', + requiresAuth: true, + }, + }, { name: 'Role', path: '/system/role', @@ -30,6 +39,15 @@ const System: AppRouteRecordRaw = { requiresAuth: true, }, }, + { + name: 'Announcement', + path: '/system/announcement', + component: () => import('@/views/system/announcement/index.vue'), + meta: { + locale: 'menu.system.announcement.list', + requiresAuth: true, + }, + }, { name: 'Menu', path: '/system/menu', @@ -40,20 +58,11 @@ const System: AppRouteRecordRaw = { }, }, { - name: 'Dept', - path: '/system/dept', - component: () => import('@/views/system/dept/index.vue'), + name: 'Dict', + path: '/system/dict', + component: () => import('@/views/system/dict/index.vue'), meta: { - locale: 'menu.system.dept.list', - requiresAuth: true, - }, - }, - { - name: 'Announcement', - path: '/system/announcement', - component: () => import('@/views/system/announcement/index.vue'), - meta: { - locale: 'menu.system.announcement.list', + locale: 'menu.system.dict.list', requiresAuth: true, }, }, diff --git a/continew-admin-ui/src/views/system/dict/index.vue b/continew-admin-ui/src/views/system/dict/index.vue new file mode 100644 index 00000000..fc0baf24 --- /dev/null +++ b/continew-admin-ui/src/views/system/dict/index.vue @@ -0,0 +1,453 @@ + + + + + + + diff --git a/continew-admin-ui/src/views/system/dict/item.vue b/continew-admin-ui/src/views/system/dict/item.vue new file mode 100644 index 00000000..cb7af219 --- /dev/null +++ b/continew-admin-ui/src/views/system/dict/item.vue @@ -0,0 +1,363 @@ + + + + + + + diff --git a/continew-admin-ui/src/views/system/dict/locale/en-US.ts b/continew-admin-ui/src/views/system/dict/locale/en-US.ts new file mode 100644 index 00000000..5ef37180 --- /dev/null +++ b/continew-admin-ui/src/views/system/dict/locale/en-US.ts @@ -0,0 +1,3 @@ +export default { + 'menu.system.dict.list': 'Dictionary management', +}; diff --git a/continew-admin-ui/src/views/system/dict/locale/zh-CN.ts b/continew-admin-ui/src/views/system/dict/locale/zh-CN.ts new file mode 100644 index 00000000..dff22b62 --- /dev/null +++ b/continew-admin-ui/src/views/system/dict/locale/zh-CN.ts @@ -0,0 +1,3 @@ +export default { + 'menu.system.dict.list': '字典管理', +}; diff --git a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictController.java b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictController.java new file mode 100644 index 00000000..7bc14a7c --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictController.java @@ -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.webapi.controller.system; + +import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.*; + +import top.charles7c.cnadmin.common.annotation.CrudRequestMapping; +import top.charles7c.cnadmin.common.base.BaseController; +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.DictService; + +/** + * 字典管理 API + * + * @author Charles7c + * @since 2023/9/11 21:29 + */ +@Tag(name = "字典管理 API") +@RestController +@CrudRequestMapping(value = "/system/dict", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT}) +public class DictController extends BaseController {} \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictItemController.java b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictItemController.java new file mode 100644 index 00000000..5a539288 --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/DictItemController.java @@ -0,0 +1,43 @@ +/* + * 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.webapi.controller.system; + +import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.*; + +import top.charles7c.cnadmin.common.annotation.CrudRequestMapping; +import top.charles7c.cnadmin.common.base.BaseController; +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; + +/** + * 字典项管理 API + * + * @author Charles7c + * @since 2023/9/11 21:29 + */ +@Tag(name = "字典项管理 API") +@RestController +@CrudRequestMapping(value = "/system/dict/item", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE}) +public class DictItemController + extends BaseController {} \ No newline at end of file diff --git a/continew-admin-webapi/src/main/resources/db/changelog/db.changelog-master.yaml b/continew-admin-webapi/src/main/resources/db/changelog/db.changelog-master.yaml index dca6b576..3e1345f9 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/continew-admin-webapi/src/main/resources/db/changelog/db.changelog-master.yaml @@ -11,3 +11,9 @@ databaseChangeLog: file: db/changelog/v1.1.0/continew-admin_column.sql - include: file: db/changelog/v1.1.0/continew-admin_data.sql + - include: + file: db/changelog/v1.2.0/continew-admin_table.sql + - include: + file: db/changelog/v1.2.0/continew-admin_column.sql + - include: + file: db/changelog/v1.2.0/continew-admin_data.sql diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql index c5e1d2b7..99673529 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.0.0/continew-admin_data.sql @@ -13,21 +13,21 @@ VALUES (1014, '用户导出', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:export', 4, 1, 1, NOW(), NULL, NULL), (1015, '重置密码', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:password:reset', 5, 1, 1, NOW(), NULL, NULL), (1016, '分配角色', 1010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:user:role:update', 6, 1, 1, NOW(), NULL, NULL), -(1020, '角色管理', 1000, 2, '/system/role', 'Role', 'system/role/index', 'safe', b'0', b'0', b'0', 'system:role:list', 2, 1, 1, NOW(), NULL, NULL), -(1021, '角色新增', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:add', 1, 1, 1, NOW(), NULL, NULL), -(1022, '角色修改', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:update', 2, 1, 1, NOW(), NULL, NULL), -(1023, '角色删除', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:delete', 3, 1, 1, NOW(), NULL, NULL), -(1024, '角色导出', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:export', 4, 1, 1, NOW(), NULL, NULL), -(1030, '部门管理', 1000, 2, '/system/dept', 'Dept', 'system/dept/index', 'user-group', b'0', b'0', b'0', 'system:dept:list', 3, 1, 1, NOW(), NULL, NULL), -(1031, '部门新增', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:add', 1, 1, 1, NOW(), NULL, NULL), -(1032, '部门修改', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:update', 2, 1, 1, NOW(), NULL, NULL), -(1033, '部门删除', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:delete', 3, 1, 1, NOW(), NULL, NULL), -(1034, '部门导出', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:export', 4, 1, 1, NOW(), NULL, NULL), -(1900, '菜单管理', 1000, 2, '/system/menu', 'Menu', 'system/menu/index', 'menu', b'0', b'0', b'0', 'system:menu:list', 999, 1, 1, NOW(), NULL, NULL), -(1901, '菜单新增', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:add', 1, 1, 1, NOW(), NULL, NULL), -(1902, '菜单修改', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:update', 2, 1, 1, NOW(), NULL, NULL), -(1903, '菜单删除', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:delete', 3, 1, 1, NOW(), NULL, NULL), -(1904, '菜单导出', 1900, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:export', 4, 1, 1, NOW(), NULL, NULL), +(1020, '部门管理', 1000, 2, '/system/dept', 'Dept', 'system/dept/index', 'user-group', b'0', b'0', b'0', 'system:dept:list', 2, 1, 1, NOW(), NULL, NULL), +(1021, '部门新增', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:add', 1, 1, 1, NOW(), NULL, NULL), +(1022, '部门修改', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:update', 2, 1, 1, NOW(), NULL, NULL), +(1023, '部门删除', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:delete', 3, 1, 1, NOW(), NULL, NULL), +(1024, '部门导出', 1020, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dept:export', 4, 1, 1, NOW(), NULL, NULL), +(1030, '角色管理', 1000, 2, '/system/role', 'Role', 'system/role/index', 'safe', b'0', b'0', b'0', 'system:role:list', 3, 1, 1, NOW(), NULL, NULL), +(1031, '角色新增', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:add', 1, 1, 1, NOW(), NULL, NULL), +(1032, '角色修改', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:update', 2, 1, 1, NOW(), NULL, NULL), +(1033, '角色删除', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:delete', 3, 1, 1, NOW(), NULL, NULL), +(1034, '角色导出', 1030, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:role:export', 4, 1, 1, NOW(), NULL, NULL), +(1040, '菜单管理', 1000, 2, '/system/menu', 'Menu', 'system/menu/index', 'menu', b'0', b'0', b'0', 'system:menu:list', 4, 1, 1, NOW(), NULL, NULL), +(1041, '菜单新增', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:add', 1, 1, 1, NOW(), NULL, NULL), +(1042, '菜单修改', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:update', 2, 1, 1, NOW(), NULL, NULL), +(1043, '菜单删除', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:delete', 3, 1, 1, NOW(), NULL, NULL), +(1044, '菜单导出', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:menu:export', 4, 1, 1, NOW(), NULL, NULL), (9000, '系统监控', 0, 1, '/monitor', 'Monitor', NULL, 'computer', b'0', b'0', b'0', NULL, 899, 1, 1, NOW(), NULL, NULL), (9010, '在线用户', 9000, 2, '/monitor/online', 'OnlineUser', 'monitor/online/index', 'anonymity', b'0', b'0', b'0', 'monitor:online:user:list', 1, 1, 1, NOW(), NULL, NULL), (9011, '强退用户', 9010, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'monitor:online:user:delete', 1, 1, 1, NOW(), NULL, NULL), diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql index 89dd5750..c4690ccb 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.1.0/continew-admin_data.sql @@ -1,13 +1,14 @@ -- liquibase formatted sql -- changeset Charles7c:1 +-- 初始化默认菜单 INSERT IGNORE INTO `sys_menu` (`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) VALUES -(1040, '公告管理', 1000, 2, '/system/announcement', 'Announcement', 'system/announcement/index', 'advertising', b'0', b'0', b'0', 'system:announcement:list', 4, 1, 1, NOW(), NULL, NULL), -(1041, '公告新增', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:add', 1, 1, 1, NOW(), NULL, NULL), -(1042, '公告修改', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:update', 2, 1, 1, NOW(), NULL, NULL), -(1043, '公告删除', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:delete', 3, 1, 1, NOW(), NULL, NULL), -(1044, '公告导出', 1040, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:export', 4, 1, 1, NOW(), NULL, NULL), +(1050, '公告管理', 1000, 2, '/system/announcement', 'Announcement', 'system/announcement/index', 'advertising', b'0', b'0', b'0', 'system:announcement:list', 5, 1, 1, NOW(), NULL, NULL), +(1051, '公告新增', 1050, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:add', 1, 1, 1, NOW(), NULL, NULL), +(1052, '公告修改', 1050, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:update', 2, 1, 1, NOW(), NULL, NULL), +(1053, '公告删除', 1050, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:delete', 3, 1, 1, NOW(), NULL, NULL), +(1054, '公告导出', 1050, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:announcement:export', 4, 1, 1, NOW(), NULL, NULL), (2000, '系统工具', 0, 1, '/tool', 'Tool', NULL, 'tool', b'0', b'0', b'0', NULL, 2, 1, 1, NOW(), NULL, NULL), (2010, '代码生成', 2000, 2, '/tool/generator', 'Generator', 'tool/generator/index', 'code', b'0', b'0', b'0', 'tool:generator:list', 1, 1, 1, NOW(), NULL, NULL); \ No newline at end of file diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_column.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_column.sql new file mode 100644 index 00000000..874085b8 --- /dev/null +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_column.sql @@ -0,0 +1,2 @@ +-- liquibase formatted sql + diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_data.sql new file mode 100644 index 00000000..ded2cb9c --- /dev/null +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_data.sql @@ -0,0 +1,25 @@ +-- liquibase formatted sql + +-- changeset Charles7c:1 +-- 初始化默认菜单 +INSERT IGNORE INTO `sys_menu` +(`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`) +VALUES +(1060, '字典管理', 1000, 2, '/system/dict', 'Dict', 'system/dict/index', 'bookmark', b'0', b'0', b'0', 'system:dict:list', 6, 1, 1, NOW(), NULL, NULL), +(1061, '字典新增', 1060, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dict:add', 1, 1, 1, NOW(), NULL, NULL), +(1062, '字典修改', 1060, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dict:update', 2, 1, 1, NOW(), NULL, NULL), +(1063, '字典删除', 1060, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dict:delete', 3, 1, 1, NOW(), NULL, NULL), +(1064, '字典导出', 1060, 3, NULL, NULL, NULL, NULL, b'0', b'0', b'0', 'system:dict:export', 4, 1, 1, NOW(), NULL, NULL); + +-- 初始化默认字典 +INSERT IGNORE INTO `sys_dict` +(`id`, `name`, `code`, `description`, `create_user`, `create_time`, `update_user`, `update_time`) +VALUES +(1, '公告类型', 'announcement_type', NULL, 1, NOW(), NULL, NULL); + +-- 初始化默认字典项 +INSERT IGNORE INTO `sys_dict_item` +(`id`, `label`, `value`, `color`, `sort`, `description`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`) +VALUES +(1, '通知', '1', 'blue', 1, NULL, 1, 1, NOW(), NULL, NULL), +(2, '活动', '2', 'orangered', 2, NULL, 1, 1, NOW(), NULL, NULL); \ No newline at end of file diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_table.sql b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_table.sql new file mode 100644 index 00000000..dc7074c6 --- /dev/null +++ b/continew-admin-webapi/src/main/resources/db/changelog/v1.2.0/continew-admin_table.sql @@ -0,0 +1,35 @@ +-- liquibase formatted sql + +-- changeset Charles7c:1 +CREATE TABLE IF NOT EXISTS `sys_dict` ( + `id` bigint(20) UNSIGNED AUTO_INCREMENT COMMENT 'ID', + `name` varchar(50) NOT NULL COMMENT '字典名称', + `code` varchar(50) NOT NULL COMMENT '字典编码', + `description` varchar(512) DEFAULT NULL COMMENT '描述', + `create_user` bigint(20) UNSIGNED NOT NULL COMMENT '创建人', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user` bigint(20) UNSIGNED DEFAULT NULL COMMENT '修改人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_name`(`name`) USING BTREE, + UNIQUE INDEX `uk_code`(`code`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典表'; + +CREATE TABLE IF NOT EXISTS `sys_dict_item` ( + `id` bigint(20) UNSIGNED AUTO_INCREMENT COMMENT 'ID', + `label` varchar(50) NOT NULL COMMENT '字典标签', + `value` varchar(50) NOT NULL COMMENT '字典值', + `color` varchar(20) DEFAULT NULL COMMENT '背景颜色', + `sort` int(11) UNSIGNED DEFAULT 999 COMMENT '字典项排序', + `description` varchar(512) DEFAULT NULL COMMENT '描述', + `dict_id` bigint(20) UNSIGNED NOT NULL COMMENT '字典ID', + `create_user` bigint(20) UNSIGNED NOT NULL COMMENT '创建人', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_user` bigint(20) UNSIGNED DEFAULT NULL COMMENT '修改人', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `uk_value_dict_id`(`value`, `dict_id`) USING BTREE, + INDEX `idx_dict_id`(`dict_id`) USING BTREE, + INDEX `idx_create_user`(`create_user`) USING BTREE, + INDEX `idx_update_user`(`update_user`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典项表';