mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	删除:删除系统管理/岗位管理(过于偏向行政业务向)
This commit is contained in:
		| @@ -1,28 +0,0 @@ | ||||
| /* | ||||
|  * 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.PostDO; | ||||
|  | ||||
| /** | ||||
|  * 岗位 Mapper | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:26 | ||||
|  */ | ||||
| public interface PostMapper extends BaseMapper<PostDO> {} | ||||
| @@ -1,28 +0,0 @@ | ||||
| /* | ||||
|  * 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.UserPostDO; | ||||
|  | ||||
| /** | ||||
|  * 用户和岗位 Mapper | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:28 | ||||
|  */ | ||||
| public interface UserPostMapper extends BaseMapper<UserPostDO> {} | ||||
| @@ -1,64 +0,0 @@ | ||||
| /* | ||||
|  * 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.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseDO; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
|  | ||||
| /** | ||||
|  * 岗位实体 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:25 | ||||
|  */ | ||||
| @Data | ||||
| @TableName("sys_post") | ||||
| public class PostDO extends BaseDO { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID | ||||
|      */ | ||||
|     @TableId | ||||
|     private Long postId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位名称 | ||||
|      */ | ||||
|     private String postName; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 岗位排序 | ||||
|      */ | ||||
|     private Integer postSort; | ||||
|  | ||||
|     /** | ||||
|      * 状态(1启用 2禁用) | ||||
|      */ | ||||
|     private DisEnableStatusEnum status; | ||||
| } | ||||
| @@ -1,53 +0,0 @@ | ||||
| /* | ||||
|  * 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 java.io.Serializable; | ||||
|  | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
|  | ||||
| /** | ||||
|  * 用户和岗位实体 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:28 | ||||
|  */ | ||||
| @Data | ||||
| @NoArgsConstructor | ||||
| @TableName("sys_user_post") | ||||
| public class UserPostDO implements Serializable { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 用户 ID | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID | ||||
|      */ | ||||
|     private Long postId; | ||||
|  | ||||
|     public UserPostDO(Long userId, Long postId) { | ||||
|         this.userId = userId; | ||||
|         this.postId = postId; | ||||
|     } | ||||
| } | ||||
| @@ -1,55 +0,0 @@ | ||||
| /* | ||||
|  * 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 org.springdoc.api.annotations.ParameterObject; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.annotation.Query; | ||||
|  | ||||
| /** | ||||
|  * 岗位查询条件 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:30 | ||||
|  */ | ||||
| @Data | ||||
| @ParameterObject | ||||
| @Schema(description = "岗位查询条件") | ||||
| public class PostQuery implements Serializable { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 岗位名称 | ||||
|      */ | ||||
|     @Schema(description = "岗位名称") | ||||
|     @Query(type = Query.Type.INNER_LIKE) | ||||
|     private String postName; | ||||
|  | ||||
|     /** | ||||
|      * 状态(1启用 2禁用) | ||||
|      */ | ||||
|     @Schema(description = "状态(1启用 2禁用)") | ||||
|     @Query | ||||
|     private Integer status; | ||||
| } | ||||
| @@ -1,78 +0,0 @@ | ||||
| /* | ||||
|  * 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.NotBlank; | ||||
| import javax.validation.constraints.NotNull; | ||||
| import javax.validation.constraints.Null; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import org.hibernate.validator.constraints.Length; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseRequest; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
|  | ||||
| /** | ||||
|  * 创建或修改岗位信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:31 | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "创建或修改岗位信息") | ||||
| public class PostRequest extends BaseRequest { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID | ||||
|      */ | ||||
|     @Schema(description = "岗位 ID") | ||||
|     @Null(message = "新增时,ID 必须为空", groups = Add.class) | ||||
|     @NotNull(message = "修改时,ID 不能为空", groups = Update.class) | ||||
|     private Long postId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位名称 | ||||
|      */ | ||||
|     @Schema(description = "岗位名称") | ||||
|     @NotBlank(message = "岗位名称不能为空") | ||||
|     private String postName; | ||||
|  | ||||
|     /** | ||||
|      * 岗位排序 | ||||
|      */ | ||||
|     @Schema(description = "岗位排序") | ||||
|     @NotNull(message = "岗位排序不能为空") | ||||
|     private Integer postSort; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述") | ||||
|     @Length(max = 200, message = "描述长度不能超过 {max} 个字符") | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 状态(1启用 2禁用) | ||||
|      */ | ||||
|     @Schema(description = "状态(1启用 2禁用)", type = "Integer", allowableValues = {"1", "2"}) | ||||
|     private DisEnableStatusEnum status; | ||||
| } | ||||
| @@ -107,12 +107,6 @@ public class UserRequest extends BaseRequest { | ||||
|     @NotNull(message = "所属部门不能为空") | ||||
|     private Long deptId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID 列表 | ||||
|      */ | ||||
|     @Schema(description = "所属岗位") | ||||
|     private List<Long> postIds; | ||||
|  | ||||
|     /** | ||||
|      * 角色 ID 列表 | ||||
|      */ | ||||
|   | ||||
| @@ -1,77 +0,0 @@ | ||||
| /* | ||||
|  * 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; | ||||
| import top.charles7c.cnadmin.common.config.easyexcel.ExcelBaseEnumConverter; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
|  | ||||
| /** | ||||
|  * 岗位详情信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:35 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @Schema(description = "岗位详情信息") | ||||
| public class PostDetailVO extends BaseDetailVO { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID | ||||
|      */ | ||||
|     @Schema(description = "岗位 ID") | ||||
|     @ExcelProperty(value = "岗位ID") | ||||
|     private Long postId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位名称 | ||||
|      */ | ||||
|     @Schema(description = "岗位名称") | ||||
|     @ExcelProperty(value = "岗位名称") | ||||
|     private String postName; | ||||
|  | ||||
|     /** | ||||
|      * 岗位排序 | ||||
|      */ | ||||
|     @Schema(description = "岗位排序") | ||||
|     @ExcelProperty(value = "岗位排序") | ||||
|     private Integer postSort; | ||||
|  | ||||
|     /** | ||||
|      * 状态(1启用 2禁用) | ||||
|      */ | ||||
|     @Schema(description = "状态(1启用 2禁用)") | ||||
|     @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述") | ||||
|     @ExcelProperty(value = "描述") | ||||
|     private String description; | ||||
| } | ||||
| @@ -1,69 +0,0 @@ | ||||
| /* | ||||
|  * 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 lombok.experimental.Accessors; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseVO; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
|  | ||||
| /** | ||||
|  * 岗位信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:34 | ||||
|  */ | ||||
| @Data | ||||
| @Accessors(chain = true) | ||||
| @Schema(description = "岗位信息") | ||||
| public class PostVO extends BaseVO { | ||||
|  | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID | ||||
|      */ | ||||
|     @Schema(description = "岗位 ID") | ||||
|     private Long postId; | ||||
|  | ||||
|     /** | ||||
|      * 岗位名称 | ||||
|      */ | ||||
|     @Schema(description = "岗位名称") | ||||
|     private String postName; | ||||
|  | ||||
|     /** | ||||
|      * 岗位排序 | ||||
|      */ | ||||
|     @Schema(description = "岗位排序") | ||||
|     private Integer postSort; | ||||
|  | ||||
|     /** | ||||
|      * 状态(1启用 2禁用) | ||||
|      */ | ||||
|     @Schema(description = "状态(1启用 2禁用)") | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述") | ||||
|     private String description; | ||||
| } | ||||
| @@ -126,19 +126,6 @@ public class UserDetailVO extends BaseDetailVO { | ||||
|     @ExcelProperty(value = "所属部门") | ||||
|     private String deptName; | ||||
|  | ||||
|     /** | ||||
|      * 岗位 ID 列表 | ||||
|      */ | ||||
|     @Schema(description = "岗位 ID 列表") | ||||
|     private List<Long> postIds; | ||||
|  | ||||
|     /** | ||||
|      * 所属岗位 | ||||
|      */ | ||||
|     @Schema(description = "所属岗位") | ||||
|     @ExcelProperty(value = "所属岗位") | ||||
|     private String postNames; | ||||
|  | ||||
|     /** | ||||
|      * 角色 ID 列表 | ||||
|      */ | ||||
|   | ||||
| @@ -1,53 +0,0 @@ | ||||
| /* | ||||
|  * 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.common.model.vo.LabelValueVO; | ||||
| import top.charles7c.cnadmin.system.model.query.PostQuery; | ||||
| import top.charles7c.cnadmin.system.model.request.PostRequest; | ||||
| import top.charles7c.cnadmin.system.model.vo.PostDetailVO; | ||||
| import top.charles7c.cnadmin.system.model.vo.PostVO; | ||||
|  | ||||
| /** | ||||
|  * 岗位业务接口 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:38 | ||||
|  */ | ||||
| public interface PostService extends BaseService<PostVO, PostDetailVO, PostQuery, PostRequest> { | ||||
|  | ||||
|     /** | ||||
|      * 构建字典 | ||||
|      * | ||||
|      * @param list | ||||
|      *            原始列表数据 | ||||
|      * @return 字典列表 | ||||
|      */ | ||||
|     List<LabelValueVO<Long>> buildDict(List<PostVO> list); | ||||
|  | ||||
|     /** | ||||
|      * 根据岗位 ID 列表查询 | ||||
|      * | ||||
|      * @param postIds | ||||
|      *            岗位 ID 列表 | ||||
|      * @return 岗位名称列表 | ||||
|      */ | ||||
|     List<String> listPostNamesByPostIds(List<Long> postIds); | ||||
| } | ||||
| @@ -1,56 +0,0 @@ | ||||
| /* | ||||
|  * 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; | ||||
|  | ||||
| /** | ||||
|  * 用户和岗位业务接口 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:40 | ||||
|  */ | ||||
| public interface UserPostService { | ||||
|  | ||||
|     /** | ||||
|      * 保存 | ||||
|      * | ||||
|      * @param postIds | ||||
|      *            岗位 ID 列表 | ||||
|      * @param userId | ||||
|      *            用户 ID | ||||
|      */ | ||||
|     void save(List<Long> postIds, Long userId); | ||||
|  | ||||
|     /** | ||||
|      * 根据岗位 ID 列表查询 | ||||
|      * | ||||
|      * @param postIds | ||||
|      *            岗位 ID 列表 | ||||
|      * @return 总记录数 | ||||
|      */ | ||||
|     Long countByPostIds(List<Long> postIds); | ||||
|  | ||||
|     /** | ||||
|      * 根据用户 ID 查询 | ||||
|      * | ||||
|      * @param userId | ||||
|      *            用户 ID | ||||
|      * @return 岗位 ID 列表 | ||||
|      */ | ||||
|     List<Long> listPostIdsByUserId(Long userId); | ||||
| } | ||||
| @@ -1,113 +0,0 @@ | ||||
| /* | ||||
|  * 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.Collections; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.base.BaseServiceImpl; | ||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.cnadmin.common.model.vo.LabelValueVO; | ||||
| import top.charles7c.cnadmin.common.util.validate.CheckUtils; | ||||
| import top.charles7c.cnadmin.system.mapper.PostMapper; | ||||
| import top.charles7c.cnadmin.system.model.entity.PostDO; | ||||
| import top.charles7c.cnadmin.system.model.query.PostQuery; | ||||
| import top.charles7c.cnadmin.system.model.request.PostRequest; | ||||
| import top.charles7c.cnadmin.system.model.vo.*; | ||||
| import top.charles7c.cnadmin.system.service.*; | ||||
|  | ||||
| /** | ||||
|  * 岗位业务实现类 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:38 | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| public class PostServiceImpl extends BaseServiceImpl<PostMapper, PostDO, PostVO, PostDetailVO, PostQuery, PostRequest> | ||||
|     implements PostService { | ||||
|  | ||||
|     private final UserPostService userPostService; | ||||
|  | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public Long add(PostRequest request) { | ||||
|         String postName = request.getPostName(); | ||||
|         boolean isExists = this.checkNameExists(postName, request.getPostId()); | ||||
|         CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", postName)); | ||||
|  | ||||
|         // 新增岗位 | ||||
|         request.setStatus(DisEnableStatusEnum.ENABLE); | ||||
|         return super.add(request); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public void update(PostRequest request) { | ||||
|         String postName = request.getPostName(); | ||||
|         boolean isExists = this.checkNameExists(postName, request.getPostId()); | ||||
|         CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", postName)); | ||||
|  | ||||
|         // 更新岗位 | ||||
|         super.update(request); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public void delete(List<Long> ids) { | ||||
|         CheckUtils.throwIf(() -> userPostService.countByPostIds(ids) > 0, "所选岗位存在用户关联,请解除关联后重试"); | ||||
|         super.delete(ids); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 检查名称是否存在 | ||||
|      * | ||||
|      * @param name | ||||
|      *            名称 | ||||
|      * @param id | ||||
|      *            ID | ||||
|      * @return 是否存在 | ||||
|      */ | ||||
|     private boolean checkNameExists(String name, Long id) { | ||||
|         return super.lambdaQuery().eq(PostDO::getPostName, name).ne(id != null, PostDO::getPostId, id).exists(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<LabelValueVO<Long>> buildDict(List<PostVO> list) { | ||||
|         if (CollUtil.isEmpty(list)) { | ||||
|             return Collections.emptyList(); | ||||
|         } | ||||
|         return list.stream().map(p -> new LabelValueVO<>(p.getPostName(), p.getPostId())).collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<String> listPostNamesByPostIds(List<Long> postIds) { | ||||
|         List<PostDO> postList = super.lambdaQuery().select(PostDO::getPostName).in(PostDO::getPostId, postIds).list(); | ||||
|         if (CollUtil.isEmpty(postList)) { | ||||
|             return Collections.emptyList(); | ||||
|         } | ||||
|         return postList.stream().map(PostDO::getPostName).collect(Collectors.toList()); | ||||
|     } | ||||
| } | ||||
| @@ -1,74 +0,0 @@ | ||||
| /* | ||||
|  * 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.Collections; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
|  | ||||
| import top.charles7c.cnadmin.system.mapper.UserPostMapper; | ||||
| import top.charles7c.cnadmin.system.model.entity.UserPostDO; | ||||
| import top.charles7c.cnadmin.system.service.UserPostService; | ||||
|  | ||||
| /** | ||||
|  * 用户和岗位业务实现类 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/2/25 22:40 | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| public class UserPostServiceImpl implements UserPostService { | ||||
|  | ||||
|     private final UserPostMapper userPostMapper; | ||||
|  | ||||
|     @Override | ||||
|     public void save(List<Long> postIds, Long userId) { | ||||
|         if (CollUtil.isEmpty(postIds)) { | ||||
|             return; | ||||
|         } | ||||
|         // 删除原有关联 | ||||
|         userPostMapper.delete(Wrappers.<UserPostDO>lambdaQuery().eq(UserPostDO::getUserId, userId)); | ||||
|         // 保存最新关联 | ||||
|         List<UserPostDO> userPostList = | ||||
|             postIds.stream().map(postId -> new UserPostDO(userId, postId)).collect(Collectors.toList()); | ||||
|         userPostMapper.insertBatch(userPostList); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Long countByPostIds(List<Long> postIds) { | ||||
|         return userPostMapper.selectCount(Wrappers.<UserPostDO>lambdaQuery().in(UserPostDO::getPostId, postIds)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<Long> listPostIdsByUserId(Long userId) { | ||||
|         List<UserPostDO> userPostList = userPostMapper.selectList( | ||||
|             Wrappers.<UserPostDO>lambdaQuery().select(UserPostDO::getPostId).eq(UserPostDO::getUserId, userId)); | ||||
|         if (CollUtil.isEmpty(userPostList)) { | ||||
|             return Collections.emptyList(); | ||||
|         } | ||||
|         return userPostList.stream().map(UserPostDO::getPostId).collect(Collectors.toList()); | ||||
|     } | ||||
| } | ||||
| @@ -64,8 +64,6 @@ import top.charles7c.cnadmin.system.service.*; | ||||
| public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, UserDetailVO, UserQuery, UserRequest> | ||||
|     implements UserService, CommonUserService { | ||||
|  | ||||
|     private final UserPostService userPostService; | ||||
|     private final PostService postService; | ||||
|     private final UserRoleService userRoleService; | ||||
|     private final RoleService roleService; | ||||
|     private final LocalStorageProperties localStorageProperties; | ||||
| @@ -85,8 +83,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | ||||
|         super.lambdaUpdate() | ||||
|             .set(UserDO::getPassword, SecureUtils.md5Salt(Constants.DEFAULT_PASSWORD, userId.toString())) | ||||
|             .set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getUserId, userId).update(); | ||||
|         // 保存用户和岗位关联 | ||||
|         userPostService.save(request.getPostIds(), userId); | ||||
|         // 保存用户和角色关联 | ||||
|         userRoleService.save(request.getRoleIds(), userId); | ||||
|         return userId; | ||||
| @@ -102,8 +98,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | ||||
|         // 更新用户 | ||||
|         super.update(request); | ||||
|         Long userId = request.getUserId(); | ||||
|         // 保存用户和岗位关联 | ||||
|         userPostService.save(request.getPostIds(), userId); | ||||
|         // 保存用户和角色关联 | ||||
|         userRoleService.save(request.getRoleIds(), userId); | ||||
|     } | ||||
| @@ -130,9 +124,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | ||||
|             List<Long> roleIds = userRoleService.listRoleIdsByUserId(detailVO.getUserId()); | ||||
|             detailVO.setRoleIds(roleIds); | ||||
|             detailVO.setRoleNames(String.join(",", roleService.listRoleNamesByRoleIds(roleIds))); | ||||
|             List<Long> postIds = userPostService.listPostIdsByUserId(detailVO.getUserId()); | ||||
|             detailVO.setPostIds(postIds); | ||||
|             detailVO.setPostNames(String.join(",", postService.listPostNamesByPostIds(postIds))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user