mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
新增:新增系统管理/岗位管理(列表、查看详情、新增、修改、删除、导出)
This commit is contained in:
@@ -93,9 +93,9 @@ public class UserInfoVO implements Serializable {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 最后一次修改密码的时间
|
||||
* 最后一次修改密码时间
|
||||
*/
|
||||
@Schema(description = "最后一次修改密码的时间")
|
||||
@Schema(description = "最后一次修改密码时间")
|
||||
private LocalDateTime pwdResetTime;
|
||||
|
||||
/**
|
||||
|
@@ -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.PostDO;
|
||||
|
||||
/**
|
||||
* 岗位 Mapper
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/2/25 22:26
|
||||
*/
|
||||
public interface PostMapper extends BaseMapper<PostDO> {}
|
@@ -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.UserPostDO;
|
||||
|
||||
/**
|
||||
* 用户和岗位 Mapper
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/2/25 22:28
|
||||
*/
|
||||
public interface UserPostMapper extends BaseMapper<UserPostDO> {}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@@ -32,7 +32,7 @@ import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
|
||||
* @since 2023/2/8 22:54
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "sys_role", autoResultMap = true)
|
||||
@TableName("sys_role")
|
||||
public class RoleDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@@ -91,7 +91,7 @@ public class UserDO extends BaseDO {
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 最后一次修改密码的时间
|
||||
* 最后一次修改密码时间
|
||||
*/
|
||||
private LocalDateTime pwdResetTime;
|
||||
|
||||
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 = Create.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,6 +107,12 @@ public class UserRequest extends BaseRequest {
|
||||
@NotNull(message = "所属部门不能为空")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 岗位 ID 列表
|
||||
*/
|
||||
@Schema(description = "所属岗位")
|
||||
private List<Long> postIds;
|
||||
|
||||
/**
|
||||
* 角色 ID 列表
|
||||
*/
|
||||
|
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.charles7c.cnadmin.system.model.vo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -107,17 +108,10 @@ public class UserDetailVO extends BaseDetailVO {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 角色 ID 列表
|
||||
* 最后一次修改密码时间
|
||||
*/
|
||||
@Schema(description = "角色 ID 列表")
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 所属角色
|
||||
*/
|
||||
@Schema(description = "所属角色")
|
||||
@ExcelProperty(value = "所属角色")
|
||||
private String roleNames;
|
||||
@Schema(description = "最后一次修改密码时间")
|
||||
private LocalDateTime pwdResetTime;
|
||||
|
||||
/**
|
||||
* 部门 ID
|
||||
@@ -131,4 +125,30 @@ public class UserDetailVO extends BaseDetailVO {
|
||||
@Schema(description = "所属部门")
|
||||
@ExcelProperty(value = "所属部门")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 岗位 ID 列表
|
||||
*/
|
||||
@Schema(description = "岗位 ID 列表")
|
||||
private List<Long> postIds;
|
||||
|
||||
/**
|
||||
* 所属岗位
|
||||
*/
|
||||
@Schema(description = "所属岗位")
|
||||
@ExcelProperty(value = "所属岗位")
|
||||
private String postNames;
|
||||
|
||||
/**
|
||||
* 角色 ID 列表
|
||||
*/
|
||||
@Schema(description = "角色 ID 列表")
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 所属角色
|
||||
*/
|
||||
@Schema(description = "所属角色")
|
||||
@ExcelProperty(value = "所属角色")
|
||||
private String roleNames;
|
||||
}
|
||||
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
@@ -106,13 +106,4 @@ public interface UserService extends BaseService<UserVO, UserDetailVO, UserQuery
|
||||
* @return 用户数量
|
||||
*/
|
||||
Long countByDeptIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询
|
||||
*
|
||||
* @param roleIds
|
||||
* 角色 ID 列表
|
||||
* @return 用户数量
|
||||
*/
|
||||
Long countByRoleIds(List<Long> roleIds);
|
||||
}
|
||||
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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());
|
||||
}
|
||||
}
|
@@ -20,8 +20,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -57,15 +55,14 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
private final RoleMenuService roleMenuService;
|
||||
private final RoleDeptService roleDeptService;
|
||||
private final MenuService menuService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
private final UserRoleService userRoleService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(RoleRequest request) {
|
||||
String roleName = request.getRoleName();
|
||||
boolean isExist = this.checkNameExists(roleName, request.getRoleId());
|
||||
CheckUtils.throwIf(() -> isExist, String.format("新增失败,'%s'已存在", roleName));
|
||||
boolean isExists = this.checkNameExists(roleName, request.getRoleId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", roleName));
|
||||
|
||||
// 新增角色
|
||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
@@ -81,8 +78,8 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(RoleRequest request) {
|
||||
String roleName = request.getRoleName();
|
||||
boolean isExist = this.checkNameExists(roleName, request.getRoleId());
|
||||
CheckUtils.throwIf(() -> isExist, String.format("修改失败,'%s'已存在", roleName));
|
||||
boolean isExists = this.checkNameExists(roleName, request.getRoleId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", roleName));
|
||||
|
||||
// 更新角色
|
||||
super.update(request);
|
||||
@@ -96,7 +93,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> ids) {
|
||||
CheckUtils.throwIf(() -> userService.countByRoleIds(ids) > 0, "所选角色存在用户关联,请解除关联后重试");
|
||||
CheckUtils.throwIf(() -> userRoleService.countByRoleIds(ids) > 0, "所选角色存在用户关联,请解除关联后重试");
|
||||
super.delete(ids);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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());
|
||||
}
|
||||
}
|
@@ -51,10 +51,7 @@ import top.charles7c.cnadmin.system.model.request.UpdateUserRoleRequest;
|
||||
import top.charles7c.cnadmin.system.model.request.UserRequest;
|
||||
import top.charles7c.cnadmin.system.model.vo.UserDetailVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.UserVO;
|
||||
import top.charles7c.cnadmin.system.service.DeptService;
|
||||
import top.charles7c.cnadmin.system.service.RoleService;
|
||||
import top.charles7c.cnadmin.system.service.UserRoleService;
|
||||
import top.charles7c.cnadmin.system.service.UserService;
|
||||
import top.charles7c.cnadmin.system.service.*;
|
||||
|
||||
/**
|
||||
* 用户业务实现类
|
||||
@@ -67,19 +64,20 @@ import top.charles7c.cnadmin.system.service.UserService;
|
||||
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;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private DeptService deptService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UserRequest request) {
|
||||
String username = request.getUsername();
|
||||
boolean isExist = this.checkNameExists(username, request.getUserId());
|
||||
CheckUtils.throwIf(() -> isExist, String.format("新增失败,'%s'已存在", username));
|
||||
boolean isExists = this.checkNameExists(username, request.getUserId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("新增失败,'%s'已存在", username));
|
||||
|
||||
// 新增用户
|
||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||
@@ -87,6 +85,8 @@ 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;
|
||||
@@ -96,12 +96,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(UserRequest request) {
|
||||
String username = request.getUsername();
|
||||
boolean isExist = this.checkNameExists(username, request.getUserId());
|
||||
CheckUtils.throwIf(() -> isExist, String.format("修改失败,'%s'已存在", username));
|
||||
boolean isExists = this.checkNameExists(username, request.getUserId());
|
||||
CheckUtils.throwIf(() -> isExists, String.format("修改失败,'%s'已存在", username));
|
||||
|
||||
// 更新用户
|
||||
super.update(request);
|
||||
Long userId = request.getUserId();
|
||||
// 保存用户和岗位关联
|
||||
userPostService.save(request.getPostIds(), userId);
|
||||
// 保存用户和角色关联
|
||||
userRoleService.save(request.getRoleIds(), userId);
|
||||
}
|
||||
@@ -128,6 +130,9 @@ 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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,11 +232,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
return super.lambdaQuery().in(UserDO::getDeptId, deptIds).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countByRoleIds(List<Long> roleIds) {
|
||||
return userRoleService.countByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknameById(Long userId) {
|
||||
return super.getById(userId).getNickname();
|
||||
|
Reference in New Issue
Block a user