wip: 项目结构重构开发中

This commit is contained in:
Ray.Hao 2024-09-03 18:22:46 +08:00
parent a5c0081885
commit 954bd11a2d
79 changed files with 564 additions and 391 deletions

View File

@ -23,13 +23,6 @@
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<!-- 单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Cloud & Alibaba -->
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@ -17,6 +17,12 @@ import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* 会员管理
*
* @author Ray
* @since 1.0.0
*/
@Tag(name = "Admin-会员管理")
@RestController
@ -28,8 +34,8 @@ public class MemberController {
@Operation(summary = "会员分页列表")
@GetMapping("/page")
public PageResult<MemberPageVO> listPagedMembers(MemberPageQuery pageQuery) {
IPage<MemberPageVO> page = memberService.listPagedMembers(pageQuery);
public PageResult<MemberPageVO> getMemberPage(MemberPageQuery pageQuery) {
IPage<MemberPageVO> page = memberService.getMemberPage(pageQuery);
return PageResult.success(page);
}

View File

@ -25,5 +25,5 @@ public interface MemberMapper extends BaseMapper<Member> {
* @param queryParams 查询参数
* @return
*/
Page<MemberBO> listPagedMembers(Page<MemberBO> page, MemberPageQuery queryParams);
Page<MemberBO> getMemberPage(Page<MemberBO> page, MemberPageQuery queryParams);
}

View File

@ -25,7 +25,7 @@ public interface MemberService extends IService<Member> {
/**
* 会员分页列表
*/
IPage<MemberPageVO> listPagedMembers(MemberPageQuery queryParams);
IPage<MemberPageVO> getMemberPage(MemberPageQuery queryParams);
/**

View File

@ -51,8 +51,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
* @return 会员分页列表
*/
@Override
public IPage<MemberPageVO> listPagedMembers(MemberPageQuery queryParams) {
Page<MemberBO> boPage = this.baseMapper.listPagedMembers(
public IPage<MemberPageVO> getMemberPage(MemberPageQuery queryParams) {
Page<MemberBO> boPage = this.baseMapper.getMemberPage(
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
queryParams
);

View File

@ -12,7 +12,7 @@
</resultMap>
<!-- 会员分页列表 -->
<select id="listPagedMembers" resultMap="MemberPageResultMap">
<select id="getMemberPage" resultMap="MemberPageResultMap">
SELECT
id,
nickName,

View File

@ -6,6 +6,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 商品服务启动类
*
* @since 1.0.0
* @author Ray
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = {MemberFeignClient.class})

View File

@ -11,7 +11,6 @@
<artifactId>sale-boot</artifactId>
<properties>
<service.port>8804</service.port>
<service.nodeport>32002</service.nodeport>
</properties>
@ -23,13 +22,6 @@
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<!-- 单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Cloud & Alibaba -->
<dependency>
<groupId>org.springframework.cloud</groupId>
@ -53,11 +45,6 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>sale-api</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-core</artifactId>
@ -73,6 +60,11 @@
<artifactId>common-security</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>sale-api</artifactId>
</dependency>
</dependencies>
<build>
@ -85,5 +77,4 @@
</plugins>
</build>
</project>

View File

@ -16,6 +16,13 @@ import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
/**
* 营销广告
*
* @author Ray
* @since 1.0.0
*/
@Tag(name = "Admin-营销广告")
@RestController
@RequestMapping("/api/v1/adverts")
@ -73,8 +80,6 @@ public class AdvertController {
public Result deleteAdverts(@Parameter(description = "广告ID多个以英文逗号(,)分割") @PathVariable("ids") String ids) {
boolean status = advertService.removeByIds(Arrays.asList(ids.split(",")));
return Result.judge(status);
}
}

View File

@ -7,7 +7,10 @@ import com.youlai.mall.sale.mapper.CouponHistoryMapper;
import org.springframework.stereotype.Service;
/**
* 优惠券领取历史记录 服务实现类
*
* @author Ray
* @since 2.0.0
*/
@Service
public class CouponHistoryServiceImpl extends ServiceImpl<CouponHistoryMapper, CouponHistory>

View File

@ -21,8 +21,7 @@
<module>mall-member</module>
<module>mall-product</module>
<module>mall-order</module>
<module>youlai-common/common-framework</module>
<module>youlai-common/common-service</module>
<module>youlai-generator</module>
</modules>
<parent>

View File

@ -64,6 +64,21 @@
<artifactId>weixin-java-miniapp</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-base</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-sms</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>member-api</artifactId>
@ -74,16 +89,6 @@
<artifactId>system-api</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-base</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-sms</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -20,7 +20,10 @@ import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
import java.util.List;
/**
* 默认安全配置
* Spring Security安全配置
*
* @author Ray
* @since 3.0.0
*/
@ConfigurationProperties(prefix = "security")
@Configuration(proxyBeanMethods = false)
@ -31,7 +34,7 @@ public class SecurityConfig {
* 白名单路径列表
*/
@Setter
private List<String> whitelistPaths;
private List<String> ignoreUris;
/**
* Spring Security 安全过滤器链配置
@ -45,9 +48,9 @@ public class SecurityConfig {
MvcRequestMatcher.Builder mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspector);
http.authorizeHttpRequests((requests) ->
{
if (CollectionUtil.isNotEmpty(whitelistPaths)) {
for (String whitelistPath : whitelistPaths) {
requests.requestMatchers(mvcMatcherBuilder.pattern(whitelistPath)).permitAll();
if (CollectionUtil.isNotEmpty(ignoreUris)) {
for (String ignoreUri : ignoreUris) {
requests.requestMatchers(mvcMatcherBuilder.pattern(ignoreUri)).permitAll();
}
}
requests.anyRequest().authenticated();

View File

@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Optional;
/**
* 自定义 OIDC 用户信息服务

View File

@ -14,8 +14,9 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* Feign 响应解码器
*
* @author Ray
* @link https://zhuanlan.zhihu.com/p/545505705
* @since 2023/8/23
*/
public class FeignDecoder implements Decoder {

View File

@ -52,8 +52,6 @@
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -23,6 +23,11 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-base</artifactId>
</dependency>
<!-- MinIO -->
<dependency>
<groupId>io.minio</groupId>

View File

@ -1,8 +1,10 @@
package com.youlai.system.controller;
package com.youlai.common.file.contoller;
import com.youlai.common.file.model.FileInfo;
import com.youlai.common.file.service.OssService;
import com.youlai.common.result.Result;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -10,7 +12,14 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Tag(name = "06.文件接口")
/**
* 文件控制器
*
* @author Ray
* @since 1.0.0
*/
@Tag(name = "11.文件接口")
@RestController
@RequestMapping("/api/v1/files")
@RequiredArgsConstructor
@ -19,9 +28,15 @@ public class FileController {
private final OssService ossService;
@PostMapping
@Operation(summary= "文件上传")
@Operation(summary = "上传文件")
public Result<FileInfo> uploadFile(
@Parameter(name = "file",description = "表单文件对象")
@Parameter(
name = "file",
description = "表单文件对象",
required = true,
in = ParameterIn.DEFAULT,
schema = @Schema(name = "file", format = "binary")
)
@RequestParam(value = "file") MultipartFile file
) {
FileInfo fileInfo = ossService.uploadFile(file);
@ -29,7 +44,7 @@ public class FileController {
}
@DeleteMapping
@Operation(summary= "文件删除")
@Operation(summary = "删除文件")
public Result deleteFile(
@Parameter(description = "文件路径") @RequestParam String filePath
) {

View File

@ -16,6 +16,7 @@
<modules>
<module>common-base</module>
<module>common-core</module>
<module>common-framework</module>
<module>common-middleware</module>
<module>common-service</module>
</modules>

View File

@ -7,7 +7,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* 网关服务启动类
*
* @author ray
* @author Ray
* @since 0.0.1
*/
@SpringBootApplication
@EnableDiscoveryClient

View File

@ -30,7 +30,7 @@ import java.text.ParseException;
@Component
@RequiredArgsConstructor
@Slf4j
public class TokenValidationGlobalFilter implements GlobalFilter, Ordered {
public class TokenBlacklistGlobalFilter implements GlobalFilter, Ordered {
private final RedisTemplate<String, Object> redisTemplate;

View File

@ -18,13 +18,6 @@
<dependencies>
<!-- 单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Cloud & Alibaba -->
<dependency>
<groupId>org.springframework.cloud</groupId>
@ -73,12 +66,7 @@
<dependency>
<groupId>com.youlai</groupId>
<artifactId>system-api</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-mybatis</artifactId>
<artifactId>common-core</artifactId>
</dependency>
<dependency>
@ -88,7 +76,7 @@
<dependency>
<groupId>com.youlai</groupId>
<artifactId>common-core</artifactId>
<artifactId>common-mybatis</artifactId>
</dependency>
<dependency>
@ -106,6 +94,11 @@
<artifactId>common-file</artifactId>
</dependency>
<dependency>
<groupId>com.youlai</groupId>
<artifactId>system-api</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -7,7 +7,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* 系统服务启动类
*
* @author ray
* @author Ray
* @since 0.0.1
*/
@SpringBootApplication
@EnableDiscoveryClient

View File

@ -6,7 +6,7 @@ import com.youlai.system.model.form.DeptForm;
import com.youlai.system.model.query.DeptQuery;
import com.youlai.system.model.vo.DeptVO;
import com.youlai.common.core.model.Option;
import com.youlai.system.service.SysDeptService;
import com.youlai.system.service.DeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -30,8 +30,8 @@ import java.util.List;
@RequestMapping("/api/v1/dept")
@RequiredArgsConstructor
@Slf4j
public class SysDeptController {
private final SysDeptService deptService;
public class DeptController {
private final DeptService deptService;
@Operation(summary = "获取部门列表")
@GetMapping

View File

@ -28,7 +28,7 @@ import java.util.List;
@RestController
@RequestMapping("/api/v1/dict")
@RequiredArgsConstructor
public class SysDictController {
public class DictController {
private final SysDictService dictService;

View File

@ -8,7 +8,7 @@ import com.youlai.system.model.query.MenuQuery;
import com.youlai.system.model.vo.MenuVO;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.vo.RouteVO;
import com.youlai.system.service.SysMenuService;
import com.youlai.system.service.MenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -33,9 +33,9 @@ import java.util.Set;
@RequestMapping("/api/v1/menus")
@RequiredArgsConstructor
@Slf4j
public class SysMenuController {
public class MenuController {
private final SysMenuService menuService;
private final MenuService menuService;
@Operation(summary = "菜单列表")
@GetMapping

View File

@ -8,7 +8,7 @@ import com.youlai.common.core.model.Option;
import com.youlai.system.model.form.RoleForm;
import com.youlai.system.model.query.RolePageQuery;
import com.youlai.system.model.vo.RolePageVO;
import com.youlai.system.service.SysRoleService;
import com.youlai.system.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -25,9 +25,9 @@ import java.util.List;
@RestController
@RequestMapping("/api/v1/roles")
@RequiredArgsConstructor
public class SysRoleController {
public class RoleController {
private final SysRoleService roleService;
private final RoleService roleService;
@Operation(summary = "角色分页列表" )
@GetMapping("/page")

View File

@ -9,12 +9,13 @@ import com.youlai.common.result.Result;
import com.youlai.common.core.annotation.RepeatSubmit;
import com.youlai.system.dto.UserAuthInfo;
import com.youlai.system.listener.excel.UserImportListener;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.form.UserForm;
import com.youlai.system.model.form.UserRegisterForm;
import com.youlai.system.model.query.UserPageQuery;
import com.youlai.mall.system.model.vo.*;
import com.youlai.system.model.vo.*;
import com.youlai.system.service.SysUserService;
import com.youlai.system.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -38,22 +39,22 @@ import java.util.List;
* 用户控制器
*
* @author Ray
* @since 2022/10/16
* @since 0.0.1
*/
@Tag(name = "01.用户接口")
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor
public class SysUserController {
public class UserController {
private final SysUserService userService;
private final UserService userService;
@Operation(summary = "用户分页列表")
@GetMapping("/page")
public PageResult<UserPageVO> listPagedUsers(
public PageResult<UserPageVO> getUserPage(
@ParameterObject UserPageQuery queryParams
) {
IPage<UserPageVO> result = userService.listPagedUsers(queryParams);
IPage<UserPageVO> result = userService.getUserPage(queryParams);
return PageResult.success(result);
}
@ -114,9 +115,9 @@ public class SysUserController {
@Parameter(description = "用户ID") @PathVariable Long userId,
@Parameter(description = "用户状态(1:启用;0:禁用)") @RequestParam Integer status
) {
boolean result = userService.update(new LambdaUpdateWrapper<SysUser>()
.eq(SysUser::getId, userId)
.set(SysUser::getStatus, status)
boolean result = userService.update(new LambdaUpdateWrapper<User>()
.eq(User::getId, userId)
.set(User::getStatus, status)
);
return Result.judge(result);
}

View File

@ -1,6 +1,6 @@
package com.youlai.system.converter;
import com.youlai.system.model.entity.SysDept;
import com.youlai.system.model.entity.Dept;
import com.youlai.system.model.form.DeptForm;
import com.youlai.system.model.vo.DeptVO;
import org.mapstruct.Mapper;
@ -14,9 +14,9 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface DeptConverter {
DeptForm convertToForm(SysDept entity);
DeptVO entity2Vo(SysDept entity);
DeptForm convertToForm(Dept entity);
DeptVO entity2Vo(Dept entity);
SysDept convertToForm(DeptForm deptForm);
Dept convertToForm(DeptForm deptForm);
}

View File

@ -1,7 +1,7 @@
package com.youlai.system.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.model.entity.SysDict;
import com.youlai.system.model.entity.Dict;
import com.youlai.system.model.form.DictForm;
import com.youlai.system.model.vo.DictPageVO;
import org.mapstruct.Mapper;
@ -15,9 +15,9 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface DictConverter {
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
Page<DictPageVO> convertToPageVo(Page<Dict> page);
DictForm convertToForm(SysDict entity);
DictForm convertToForm(Dict entity);
SysDict convertToEntity(DictForm entity);
Dict convertToEntity(DictForm entity);
}

View File

@ -2,7 +2,7 @@ package com.youlai.system.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.model.entity.DictItem;
import com.youlai.system.model.form.DictForm;
import com.youlai.system.model.vo.DictPageVO;
import org.mapstruct.Mapper;
@ -20,20 +20,20 @@ import java.util.List;
@Mapper(componentModel = "spring")
public interface DictItemConverter {
Page<DictPageVO> convertToPageVo(Page<SysDictItem> page);
Page<DictPageVO> convertToPageVo(Page<DictItem> page);
DictForm convertToForm(SysDictItem entity);
DictForm convertToForm(DictItem entity);
SysDictItem convertToEntity(DictForm.DictItem dictFormDictItems);
List<SysDictItem> convertToEntity(List<DictForm.DictItem> dictFormDictItems);
DictItem convertToEntity(DictForm.DictItem dictFormDictItems);
List<DictItem> convertToEntity(List<DictForm.DictItem> dictFormDictItems);
DictForm.DictItem convertToDictFormDictItem(SysDictItem entity);
List<DictForm.DictItem> convertToDictFormDictItem(List<SysDictItem> entities);
DictForm.DictItem convertToDictFormDictItem(DictItem entity);
List<DictForm.DictItem> convertToDictFormDictItem(List<DictItem> entities);
@Mappings({
@Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name")
})
Option convertToOption(SysDictItem dictItem);
List<Option> convertToOption(List<SysDictItem> dictItems);
Option convertToOption(DictItem dictItem);
List<Option> convertToOption(List<DictItem> dictItems);
}

View File

@ -1,6 +1,6 @@
package com.youlai.system.converter;
import com.youlai.system.model.entity.SysMenu;
import com.youlai.system.model.entity.Menu;
import com.youlai.system.model.form.MenuForm;
import com.youlai.system.model.vo.MenuVO;
import org.mapstruct.Mapper;
@ -15,11 +15,11 @@ import org.mapstruct.Mapping;
@Mapper(componentModel = "spring")
public interface MenuConverter {
MenuVO entity2Vo(SysMenu entity);
MenuVO entity2Vo(Menu entity);
@Mapping(target = "params", ignore = true)
MenuForm convertToForm(SysMenu entity);
MenuForm convertToForm(Menu entity);
@Mapping(target = "params", ignore = true)
SysMenu toEntity(MenuForm menuForm);
Menu toEntity(MenuForm menuForm);
}

View File

@ -2,7 +2,7 @@ package com.youlai.system.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.entity.SysRole;
import com.youlai.system.model.entity.Role;
import com.youlai.system.model.form.RoleForm;
import com.youlai.system.model.vo.RolePageVO;
import org.mapstruct.Mapper;
@ -20,18 +20,18 @@ import java.util.List;
@Mapper(componentModel = "spring")
public interface RoleConverter {
Page<RolePageVO> entity2Page(Page<SysRole> page);
Page<RolePageVO> entity2Page(Page<Role> page);
@Mappings({
@Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name")
})
Option entity2Option(SysRole role);
Option entity2Option(Role role);
List<Option> entities2Options(List<SysRole> roles);
List<Option> entities2Options(List<Role> roles);
SysRole toEntity(RoleForm roleForm);
Role toEntity(RoleForm roleForm);
RoleForm convertToForm(SysRole entity);
RoleForm convertToForm(Role entity);
}

View File

@ -2,7 +2,7 @@ package com.youlai.system.converter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.model.bo.UserBO;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.form.UserForm;
import com.youlai.system.model.vo.UserImportVO;
import com.youlai.system.model.vo.UserInfoVO;
@ -31,17 +31,17 @@ public interface UserConverter {
UserForm toForm(UserBO bo);
UserForm convertToForm(SysUser entity);
UserForm convertToForm(User entity);
@InheritInverseConfiguration(name = "convertToForm")
SysUser toEntity(UserForm entity);
User toEntity(UserForm entity);
@Mappings({
@Mapping(target = "userId", source = "id")
})
UserInfoVO entity2InfoVo(SysUser entity);
UserInfoVO entity2InfoVo(User entity);
SysUser importVo2Entity(UserImportVO vo);
User importVo2Entity(UserImportVO vo);
@Mappings({
@Mapping(target = "genderLabel", expression = "java(com.youlai.common.base.IBaseEnum.getLabelByValue(bo.getGender(), com.youlai.common.enums.GenderEnum.class))")

View File

@ -12,13 +12,13 @@ import com.youlai.common.constant.SystemConstants;
import com.youlai.common.enums.GenderEnum;
import com.youlai.common.enums.StatusEnum;
import com.youlai.system.converter.UserConverter;
import com.youlai.system.model.entity.SysRole;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.SysUserRole;
import com.youlai.system.model.entity.Role;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.entity.UserRole;
import com.youlai.system.model.vo.UserImportVO;
import com.youlai.system.service.SysRoleService;
import com.youlai.system.service.SysUserRoleService;
import com.youlai.system.service.SysUserService;
import com.youlai.system.service.RoleService;
import com.youlai.system.service.UserRoleService;
import com.youlai.system.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
@ -49,22 +49,22 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
// 部门ID
private final Long deptId;
private final SysUserService userService;
private final UserService userService;
private final PasswordEncoder passwordEncoder;
private final UserConverter userConverter;
private final SysRoleService roleService;
private final RoleService roleService;
private final SysUserRoleService userRoleService;
private final UserRoleService userRoleService;
public UserImportListener(Long deptId) {
this.deptId = deptId;
this.userService = SpringUtil.getBean(SysUserService.class);
this.userService = SpringUtil.getBean(UserService.class);
this.passwordEncoder = SpringUtil.getBean(PasswordEncoder.class);
this.roleService = SpringUtil.getBean(SysRoleService.class);
this.userRoleService = SpringUtil.getBean(SysUserRoleService.class);
this.roleService = SpringUtil.getBean(RoleService.class);
this.userRoleService = SpringUtil.getBean(UserRoleService.class);
this.userConverter = SpringUtil.getBean(UserConverter.class);
}
@ -87,7 +87,7 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
if (StrUtil.isBlank(username)) {
validationMsg.append("用户名为空;");
} else {
long count = userService.count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
long count = userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, username));
if (count > 0) {
validationMsg.append("用户名已存在;");
}
@ -109,7 +109,7 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
if (validationMsg.length() == 0) {
// 校验通过持久化至数据库
SysUser entity = userConverter.importVo2Entity(userImportVO);
User entity = userConverter.importVo2Entity(userImportVO);
entity.setDeptId(deptId); // 部门
entity.setPassword(passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD)); // 默认密码
// 性别翻译
@ -124,10 +124,10 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
List<Long> roleIds = null;
if (StrUtil.isNotBlank(roleCodes)) {
roleIds = roleService.list(
new LambdaQueryWrapper<SysRole>()
.in(SysRole::getCode, roleCodes.split(","))
.eq(SysRole::getStatus, StatusEnum.ENABLE.getValue())
.select(SysRole::getId)
new LambdaQueryWrapper<Role>()
.in(Role::getCode, roleCodes.split(","))
.eq(Role::getStatus, StatusEnum.ENABLE.getValue())
.select(Role::getId)
).stream()
.map(role -> role.getId())
.collect(Collectors.toList());
@ -139,8 +139,8 @@ public class UserImportListener extends MyAnalysisEventListener<UserImportVO> {
validCount++;
// 保存用户角色关联
if (CollectionUtil.isNotEmpty(roleIds)) {
List<SysUserRole> userRoles = roleIds.stream()
.map(roleId -> new SysUserRole(entity.getId(), roleId))
List<UserRole> userRoles = roleIds.stream()
.map(roleId -> new UserRole(entity.getId(), roleId))
.collect(Collectors.toList());
userRoleService.saveBatch(userRoles);
}

View File

@ -1,13 +1,10 @@
package com.youlai.system.listener.rabbitmq;
import com.youlai.system.service.SysMenuService;
import com.youlai.system.service.MenuService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import java.util.Arrays;
/**
* Canal + RabbitMQ 监听数据库数据变化
*
@ -19,7 +16,7 @@ import java.util.Arrays;
@RequiredArgsConstructor
public class CanalListener {
private final SysMenuService menuService;
private final MenuService menuService;
//@RabbitListener(queues = "canal.queue")
public void handleDataChange() {

View File

@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.youlai.common.core.annotation.DataPermission;
import com.youlai.system.model.entity.SysDept;
import com.youlai.system.model.entity.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -12,9 +12,9 @@ import java.util.List;
@Mapper
public interface SysDeptMapper extends BaseMapper<SysDept> {
public interface DeptMapper extends BaseMapper<Dept> {
@DataPermission(deptIdColumnName = "id")
@Override
List<SysDept> selectList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
List<Dept> selectList(@Param(Constants.WRAPPER) Wrapper<Dept> queryWrapper);
}

View File

@ -1,7 +1,7 @@
package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.model.entity.DictItem;
import org.apache.ibatis.annotations.Mapper;
/**
@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2.9.0
*/
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
public interface DictItemMapper extends BaseMapper<DictItem> {
}

View File

@ -2,7 +2,7 @@ package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.system.model.entity.SysDict;
import com.youlai.system.model.entity.Dict;
import com.youlai.system.model.query.DictPageQuery;
import com.youlai.system.model.vo.DictPageVO;
import org.apache.ibatis.annotations.Mapper;
@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2.9.0
*/
@Mapper
public interface SysDictMapper extends BaseMapper<SysDict> {
public interface DictMapper extends BaseMapper<Dict> {
/**
* 字典分页列表

View File

@ -2,7 +2,7 @@ package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.model.bo.RouteBO;
import com.youlai.system.model.entity.SysMenu;
import com.youlai.system.model.entity.Menu;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -17,7 +17,7 @@ import java.util.Set;
*/
@Mapper
public interface SysMenuMapper extends BaseMapper<SysMenu> {
public interface MenuMapper extends BaseMapper<Menu> {
/**
* 获取菜单路由列表

View File

@ -1,13 +1,13 @@
package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.model.entity.SysRole;
import com.youlai.system.model.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import java.util.Set;
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
public interface RoleMapper extends BaseMapper<Role> {
/**

View File

@ -2,7 +2,7 @@ package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.model.bo.RolePermsBO;
import com.youlai.system.model.entity.SysRoleMenu;
import com.youlai.system.model.entity.RoleMenu;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -14,7 +14,7 @@ import java.util.List;
* @since 2022/6/4
*/
@Mapper
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
/**
* 获取角色拥有的菜单ID集合

View File

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.core.annotation.DataPermission;
import com.youlai.system.dto.UserAuthInfo;
import com.youlai.system.model.bo.UserBO;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.query.UserPageQuery;
import com.youlai.system.model.vo.UserExportVO;
import org.apache.ibatis.annotations.Mapper;
@ -19,7 +19,7 @@ import java.util.List;
* @since 2022/1/14
*/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
public interface UserMapper extends BaseMapper<User> {
/**
* 获取用户分页列表
@ -29,7 +29,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return {@link List<UserBO>}
*/
@DataPermission(deptAlias = "u")
Page<UserBO> listPagedUsers(Page<UserBO> page, UserPageQuery queryParams);
Page<UserBO> getUserPage(Page<UserBO> page, UserPageQuery queryParams);
/**
* 获取用户表单详情

View File

@ -1,7 +1,7 @@
package com.youlai.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youlai.system.model.entity.SysUserRole;
import com.youlai.system.model.entity.UserRole;
import org.apache.ibatis.annotations.Mapper;
/**
@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2022/1/15
*/
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
public interface UserRoleMapper extends BaseMapper<UserRole> {
/**
* 获取角色绑定的用户数

View File

@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysDept extends BaseEntity {
public class Dept extends BaseEntity {
/**
* 主键
*/

View File

@ -12,7 +12,7 @@ import lombok.Data;
* @since 2022/12/17
*/
@Data
public class SysDict extends BaseEntity {
public class Dict extends BaseEntity {
/**
* 主键
*/

View File

@ -4,16 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
/**
* 字典项实体
*
* @author haoxr
* @since 2022/12/17
* @since 0.0.1
*/
@Data
public class SysDictItem implements Serializable {
public class DictItem {
/**
* 主键
*/

View File

@ -0,0 +1,53 @@
package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.base.BaseEntity;
import lombok.Getter;
import lombok.Setter;
/**
* 代码生成基础配置
*
* @author Ray
* @since 2.10.0
*/
@TableName(value = "gen_config")
@Getter
@Setter
public class GenConfig extends BaseEntity {
/**
* 表名
*/
private String tableName;
/**
* 包名
*/
private String packageName;
/**
* 模块名
*/
private String moduleName;
/**
* 实体类名
*/
private String entityName;
/**
* 业务名
*/
private String businessName;
/**
* 父菜单ID
*/
private Long parentMenuId;
/**
* 作者
*/
private String author;
}

View File

@ -0,0 +1,105 @@
package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.youlai.boot.common.base.BaseEntity;
import com.youlai.boot.common.enums.FormTypeEnum;
import com.youlai.boot.common.enums.QueryTypeEnum;
import lombok.Getter;
import lombok.Setter;
/**
* 字段生成配置实体
*
* @author Ray
* @since 2.10.0
*/
@TableName(value = "gen_field_config")
@Getter
@Setter
public class GenFieldConfig extends BaseEntity {
/**
* 关联的配置ID
*/
private Long configId;
/**
* 列名
*/
private String columnName;
/**
* 列类型
*/
private String columnType;
/**
* 字段长度
*/
private Integer maxLength;
/**
* 字段名称
*/
private String fieldName;
/**
* 字段排序
*/
private Integer fieldSort;
/**
* 字段类型
*/
private String fieldType;
/**
* 字段描述
*/
private String fieldComment;
/**
* 表单类型
*/
private FormTypeEnum formType;
/**
* 查询方式
*/
private QueryTypeEnum queryType;
/**
* 是否在列表显示
*/
private Integer isShowInList;
/**
* 是否在表单显示
*/
private Integer isShowInForm;
/**
* 是否在查询条件显示
*/
private Integer isShowInQuery;
/**
* 是否必填
*/
private Integer isRequired;
/**
* TypeScript类型
*/
@TableField(exist = false)
@JsonIgnore
private String tsType;
/**
* 字典类型
*/
private String dictType;
}

View File

@ -1,7 +1,6 @@
package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.youlai.common.base.BaseEntity;
import com.youlai.system.enums.MenuTypeEnum;
import lombok.Data;
@ -15,7 +14,7 @@ import java.util.Date;
*/
@TableName(value ="sys_menu")
@Data
public class SysMenu{
public class Menu {
/**
* 菜单ID
*/

View File

@ -2,7 +2,6 @@ package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -12,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysRole extends BaseEntity {
public class Role extends BaseEntity {
/**
*
*/

View File

@ -1,6 +1,5 @@
package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -8,11 +7,14 @@ import lombok.NoArgsConstructor;
/**
* 角色和菜单关联表
*
* @author Ray
* @since 0.0.1
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysRoleMenu {
public class RoleMenu {
/**
* 角色ID
*/
@ -22,7 +24,4 @@ public class SysRoleMenu {
* 菜单ID
*/
private Long menuId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -8,12 +8,15 @@ import lombok.EqualsAndHashCode;
/**
* 用户实体
*
* @author Ray
* @since 0.0.1
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysUser extends BaseEntity {
public class User extends BaseEntity {
/**
*
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
@ -29,7 +32,7 @@ public class SysUser extends BaseEntity {
private String nickname;
/**
* 性别((1:;2:))
* 性别(1:;2:)
*/
private Integer gender;

View File

@ -1,6 +1,5 @@
package com.youlai.system.model.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -15,7 +14,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUserRole {
public class UserRole {
/**
* 用户ID
*/
@ -26,6 +25,4 @@ public class SysUserRole {
*/
private Long roleId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -1,7 +1,7 @@
package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysDept;
import com.youlai.system.model.entity.Dept;
import com.youlai.system.model.form.DeptForm;
import com.youlai.system.model.query.DeptQuery;
import com.youlai.system.model.vo.DeptVO;
@ -15,7 +15,7 @@ import java.util.List;
* @author Ray
* @since 2021/8/22
*/
public interface SysDeptService extends IService<SysDept> {
public interface DeptService extends IService<Dept> {
/**
* 部门列表
*/

View File

@ -1,7 +1,7 @@
package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.model.entity.DictItem;
/**
* 字典项 接口
@ -9,7 +9,7 @@ import com.youlai.system.model.entity.SysDictItem;
* @author Ray Hao
* @since 2023/3/4
*/
public interface SysDictItemService extends IService<SysDictItem> {
public interface DictItemService extends IService<DictItem> {
/**
* 根据字典ID删除字典项

View File

@ -3,7 +3,7 @@ package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.entity.SysDict;
import com.youlai.system.model.entity.Dict;
import com.youlai.system.model.form.DictForm;
import com.youlai.system.model.query.DictPageQuery;
import com.youlai.system.model.vo.DictPageVO;
@ -16,7 +16,7 @@ import java.util.List;
* @author haoxr
* @since 2022/10/12
*/
public interface SysDictService extends IService<SysDict> {
public interface SysDictService extends IService<Dict> {
/**
* 字典分页列表

View File

@ -1,7 +1,7 @@
package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysMenu;
import com.youlai.system.model.entity.Menu;
import com.youlai.system.model.form.MenuForm;
import com.youlai.system.model.query.MenuQuery;
import com.youlai.system.model.vo.MenuVO;
@ -17,7 +17,7 @@ import java.util.Set;
* @author Ray
* @since 2020/11/06
*/
public interface SysMenuService extends IService<SysMenu> {
public interface MenuService extends IService<Menu> {
/**
* 获取菜单表格列表

View File

@ -2,7 +2,7 @@ package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysRoleMenu;
import com.youlai.system.model.entity.RoleMenu;
import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
* @author Ray
* @since 0.0.1
*/
public interface SysRoleMenuService extends IService<SysRoleMenu> {
public interface RoleMenuService extends IService<RoleMenu> {
/**
* 获取角色拥有的菜单ID集合

View File

@ -3,7 +3,7 @@ package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysRole;
import com.youlai.system.model.entity.Role;
import com.youlai.system.model.form.RoleForm;
import com.youlai.system.model.query.RolePageQuery;
import com.youlai.common.core.model.Option;
@ -18,7 +18,7 @@ import java.util.Set;
* @author Ray
* @since 2022/6/3
*/
public interface SysRoleService extends IService<SysRole> {
public interface RoleService extends IService<Role> {
/**
* 角色分页列表

View File

@ -2,7 +2,7 @@ package com.youlai.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.model.entity.SysUserRole;
import com.youlai.system.model.entity.UserRole;
import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
* @author Ray
* @since 0.0.1
*/
public interface SysUserRoleService extends IService<SysUserRole> {
public interface UserRoleService extends IService<UserRole> {
/**
* 保存用户角色

View File

@ -4,7 +4,7 @@ package com.youlai.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.youlai.system.dto.UserAuthInfo;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.form.UserForm;
import com.youlai.system.model.form.UserRegisterForm;
import com.youlai.system.model.query.UserPageQuery;
@ -21,15 +21,14 @@ import java.util.List;
* @author Ray
* @since 2022/1/14
*/
public interface SysUserService extends IService<SysUser> {
public interface UserService extends IService<User> {
/**
* 用户分页列表
*
* @return {@link IPage<UserPageVO>}
*/
IPage<UserPageVO> listPagedUsers(UserPageQuery queryParams);
IPage<UserPageVO> getUserPage(UserPageQuery queryParams);
/**
* 获取用户表单数据
@ -39,7 +38,6 @@ public interface SysUserService extends IService<SysUser> {
*/
UserForm getUserFormData(Long userId);
/**
* 新增用户
*
@ -57,7 +55,6 @@ public interface SysUserService extends IService<SysUser> {
*/
boolean updateUser(Long userId, UserForm userForm);
/**
* 删除用户
*
@ -66,7 +63,6 @@ public interface SysUserService extends IService<SysUser> {
*/
boolean deleteUsers(String idsStr);
/**
* 修改用户密码
*

View File

@ -7,13 +7,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.constant.GlobalConstants;
import com.youlai.common.enums.StatusEnum;
import com.youlai.system.converter.DeptConverter;
import com.youlai.system.mapper.SysDeptMapper;
import com.youlai.system.model.entity.SysDept;
import com.youlai.system.mapper.DeptMapper;
import com.youlai.system.model.entity.Dept;
import com.youlai.system.model.form.DeptForm;
import com.youlai.system.model.query.DeptQuery;
import com.youlai.system.model.vo.DeptVO;
import com.youlai.common.core.model.Option;
import com.youlai.system.service.SysDeptService;
import com.youlai.system.service.DeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -30,7 +30,7 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements DeptService {
private final DeptConverter deptConverter;
@ -45,19 +45,19 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
Integer status = queryParams.getStatus();
// 查询数据
List<SysDept> deptList = this.list(
new LambdaQueryWrapper<SysDept>()
.like(StrUtil.isNotBlank(keywords), SysDept::getName, keywords)
.eq(status != null, SysDept::getStatus, status)
.orderByAsc(SysDept::getSort)
List<Dept> deptList = this.list(
new LambdaQueryWrapper<Dept>()
.like(StrUtil.isNotBlank(keywords), Dept::getName, keywords)
.eq(status != null, Dept::getStatus, status)
.orderByAsc(Dept::getSort)
);
Set<Long> deptIds = deptList.stream()
.map(SysDept::getId)
.map(Dept::getId)
.collect(Collectors.toSet());
Set<Long> parentIds = deptList.stream()
.map(SysDept::getParentId)
.map(Dept::getParentId)
.collect(Collectors.toSet());
List<Long> rootIds = CollectionUtil.subtractToList(parentIds, deptIds);
@ -76,7 +76,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @param deptList
* @return
*/
public List<DeptVO> recurDeptList(Long parentId, List<SysDept> deptList) {
public List<DeptVO> recurDeptList(Long parentId, List<Dept> deptList) {
return deptList.stream()
.filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> {
@ -95,18 +95,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
@Override
public List<Option> listDeptOptions() {
List<SysDept> deptList = this.list(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, StatusEnum.ENABLE.getValue())
.select(SysDept::getId, SysDept::getParentId, SysDept::getName)
.orderByAsc(SysDept::getSort)
List<Dept> deptList = this.list(new LambdaQueryWrapper<Dept>()
.eq(Dept::getStatus, StatusEnum.ENABLE.getValue())
.select(Dept::getId, Dept::getParentId, Dept::getName)
.orderByAsc(Dept::getSort)
);
Set<Long> parentIds = deptList.stream()
.map(SysDept::getParentId)
.map(Dept::getParentId)
.collect(Collectors.toSet());
Set<Long> deptIds = deptList.stream()
.map(SysDept::getId)
.map(Dept::getId)
.collect(Collectors.toSet());
List<Long> rootIds = CollectionUtil.subtractToList(parentIds, deptIds);
@ -126,7 +126,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
*/
@Override
public Long saveDept(DeptForm formData) {
SysDept entity = deptConverter.convertToForm(formData);
Dept entity = deptConverter.convertToForm(formData);
// 部门层级路径
String treePath = buildTreePath(formData.getParentId());
entity.setTreePath(treePath);
@ -142,7 +142,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @param deptList
* @return
*/
public static List<Option> recurDeptTreeOptions(long parentId, List<SysDept> deptList) {
public static List<Option> recurDeptTreeOptions(long parentId, List<Dept> deptList) {
List<Option> list = CollectionUtil.emptyIfNull(deptList).stream()
.filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> {
@ -170,8 +170,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
if (StrUtil.isNotBlank(ids)) {
String[] deptIds = ids.split(",");
for (String deptId : deptIds) {
this.remove(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId)
this.remove(new LambdaQueryWrapper<Dept>()
.eq(Dept::getId, deptId)
.or()
.apply("CONCAT (',',tree_path,',') LIKE CONCAT('%,',{0},',%')", deptId));
}
@ -187,14 +187,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
@Override
public DeptForm getDeptForm(Long deptId) {
SysDept entity = this.getOne(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getId, deptId)
Dept entity = this.getOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getId, deptId)
.select(
SysDept::getId,
SysDept::getName,
SysDept::getParentId,
SysDept::getStatus,
SysDept::getSort
Dept::getId,
Dept::getName,
Dept::getParentId,
Dept::getStatus,
Dept::getSort
));
return deptConverter.convertToForm(entity);
@ -212,7 +212,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
if (GlobalConstants.ROOT_NODE_ID.equals(parentId)) {
treePath = String.valueOf(parentId);
} else {
SysDept parent = this.getById(parentId);
Dept parent = this.getById(parentId);
if (parent != null) {
treePath = parent.getTreePath() + "," + parent.getId();
}

View File

@ -1,9 +1,9 @@
package com.youlai.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.mapper.SysDictItemMapper;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.service.SysDictItemService;
import com.youlai.system.mapper.DictItemMapper;
import com.youlai.system.model.entity.DictItem;
import com.youlai.system.service.DictItemService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
*/
@Service
@RequiredArgsConstructor
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
public class DictItemServiceImpl extends ServiceImpl<DictItemMapper, DictItem> implements DictItemService {
/**
* 根据字典ID删除字典项

View File

@ -15,16 +15,16 @@ import com.youlai.common.core.model.KeyValue;
import com.youlai.system.enums.MenuTypeEnum;
import com.youlai.common.enums.StatusEnum;
import com.youlai.system.converter.MenuConverter;
import com.youlai.system.mapper.SysMenuMapper;
import com.youlai.system.mapper.MenuMapper;
import com.youlai.system.model.bo.RouteBO;
import com.youlai.system.model.entity.SysMenu;
import com.youlai.system.model.entity.Menu;
import com.youlai.system.model.form.MenuForm;
import com.youlai.system.model.query.MenuQuery;
import com.youlai.system.model.vo.MenuVO;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.vo.RouteVO;
import com.youlai.system.service.SysMenuService;
import com.youlai.system.service.SysRoleMenuService;
import com.youlai.system.service.MenuService;
import com.youlai.system.service.RoleMenuService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -40,10 +40,10 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
private final MenuConverter menuConverter;
private final SysRoleMenuService roleMenuService;
private final RoleMenuService roleMenuService;
/**
* 菜单列表
@ -52,16 +52,16 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public List<MenuVO> listMenus(MenuQuery queryParams) {
List<SysMenu> menus = this.list(new LambdaQueryWrapper<SysMenu>()
.like(StrUtil.isNotBlank(queryParams.getKeywords()), SysMenu::getName, queryParams.getKeywords())
.orderByAsc(SysMenu::getSort)
List<Menu> menus = this.list(new LambdaQueryWrapper<Menu>()
.like(StrUtil.isNotBlank(queryParams.getKeywords()), Menu::getName, queryParams.getKeywords())
.orderByAsc(Menu::getSort)
);
Set<Long> parentIds = menus.stream()
.map(SysMenu::getParentId)
.map(Menu::getParentId)
.collect(Collectors.toSet());
Set<Long> menuIds = menus.stream()
.map(SysMenu::getId)
.map(Menu::getId)
.collect(Collectors.toSet());
// 获取根节点ID
@ -83,7 +83,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @param menuList 菜单列表
* @return 菜单列表
*/
private List<MenuVO> buildMenuTree(Long parentId, List<SysMenu> menuList) {
private List<MenuVO> buildMenuTree(Long parentId, List<Menu> menuList) {
return CollectionUtil.emptyIfNull(menuList)
.stream()
.filter(menu -> menu.getParentId().equals(parentId))
@ -100,7 +100,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public List<Option> listMenuOptions() {
List<SysMenu> menuList = this.list(new LambdaQueryWrapper<SysMenu>().orderByAsc(SysMenu::getSort));
List<Menu> menuList = this.list(new LambdaQueryWrapper<Menu>().orderByAsc(Menu::getSort));
return buildMenuOptions(GlobalConstants.ROOT_NODE_ID, menuList);
}
@ -111,10 +111,10 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @param menuList 菜单列表
* @return 菜单下拉列表
*/
private List<Option> buildMenuOptions(Long parentId, List<SysMenu> menuList) {
private List<Option> buildMenuOptions(Long parentId, List<Menu> menuList) {
List<Option> menuOptions = new ArrayList<>();
for (SysMenu menu : menuList) {
for (Menu menu : menuList) {
if (menu.getParentId().equals(parentId)) {
Option option = new Option(menu.getId(), menu.getName());
List<Option> subMenuOptions = buildMenuOptions(menu.getId(), menuList);
@ -228,7 +228,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
menuForm.setComponent(null);
}
SysMenu entity = menuConverter.toEntity(menuForm);
Menu entity = menuConverter.toEntity(menuForm);
String treePath = generateMenuTreePath(menuForm.getParentId());
entity.setTreePath(treePath);
@ -261,7 +261,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
if (GlobalConstants.ROOT_NODE_ID.equals(parentId)) {
return String.valueOf(parentId);
} else {
SysMenu parent = this.getById(parentId);
Menu parent = this.getById(parentId);
return parent != null ? parent.getTreePath() + "," + parent.getId() : null;
}
}
@ -276,9 +276,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public boolean updateMenuVisible(Long menuId, Integer visible) {
return this.update(new LambdaUpdateWrapper<SysMenu>()
.eq(SysMenu::getId, menuId)
.set(SysMenu::getVisible, visible)
return this.update(new LambdaUpdateWrapper<Menu>()
.eq(Menu::getId, menuId)
.set(Menu::getVisible, visible)
);
}
@ -290,7 +290,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public MenuForm getMenuForm(Long id) {
SysMenu entity = this.getById(id);
Menu entity = this.getById(id);
Assert.isTrue(entity != null, "菜单不存在");
MenuForm formData = menuConverter.convertToForm(entity);
// 路由参数字符串 {"id":"1","name":"张三"} 转换为 [{key:"id", value:"1"}, {key:"name", value:"张三"}]
@ -324,8 +324,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
*/
@Override
public boolean deleteMenu(Long id) {
boolean result = this.remove(new LambdaQueryWrapper<SysMenu>()
.eq(SysMenu::getId, id)
boolean result = this.remove(new LambdaQueryWrapper<Menu>()
.eq(Menu::getId, id)
.or()
.apply("CONCAT (',',tree_path,',') LIKE CONCAT('%,',{0},',%')", id));

View File

@ -3,10 +3,10 @@ package com.youlai.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.constant.RedisConstants;
import com.youlai.system.mapper.SysRoleMenuMapper;
import com.youlai.system.mapper.RoleMenuMapper;
import com.youlai.system.model.bo.RolePermsBO;
import com.youlai.system.model.entity.SysRoleMenu;
import com.youlai.system.service.SysRoleMenuService;
import com.youlai.system.model.entity.RoleMenu;
import com.youlai.system.service.RoleMenuService;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
@ -20,7 +20,7 @@ import java.util.Set;
*/
@Service
@RequiredArgsConstructor
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {
private final RedisTemplate<String, Object> redisTemplate;

View File

@ -10,16 +10,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.constant.SystemConstants;
import com.youlai.common.security.util.SecurityUtils;
import com.youlai.system.converter.RoleConverter;
import com.youlai.system.mapper.SysRoleMapper;
import com.youlai.system.model.entity.SysRole;
import com.youlai.system.model.entity.SysRoleMenu;
import com.youlai.system.mapper.RoleMapper;
import com.youlai.system.model.entity.Role;
import com.youlai.system.model.entity.RoleMenu;
import com.youlai.system.model.form.RoleForm;
import com.youlai.system.model.query.RolePageQuery;
import com.youlai.common.core.model.Option;
import com.youlai.system.model.vo.RolePageVO;
import com.youlai.system.service.SysRoleMenuService;
import com.youlai.system.service.SysRoleService;
import com.youlai.system.service.SysUserRoleService;
import com.youlai.system.service.RoleMenuService;
import com.youlai.system.service.RoleService;
import com.youlai.system.service.UserRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
@ -36,10 +36,10 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
private final SysRoleMenuService roleMenuService;
private final SysUserRoleService userRoleService;
private final RoleMenuService roleMenuService;
private final UserRoleService userRoleService;
private final RoleConverter roleConverter;
/**
@ -56,15 +56,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
String keywords = queryParams.getKeywords();
// 查询数据
Page<SysRole> rolePage = this.page(new Page<>(pageNum, pageSize),
new LambdaQueryWrapper<SysRole>()
Page<Role> rolePage = this.page(new Page<>(pageNum, pageSize),
new LambdaQueryWrapper<Role>()
.and(StrUtil.isNotBlank(keywords),
wrapper ->
wrapper.like(StrUtil.isNotBlank(keywords), SysRole::getName, keywords)
wrapper.like(StrUtil.isNotBlank(keywords), Role::getName, keywords)
.or()
.like(StrUtil.isNotBlank(keywords), SysRole::getCode, keywords)
.like(StrUtil.isNotBlank(keywords), Role::getCode, keywords)
)
.ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE) // 非超级管理员不显示超级管理员角色
.ne(!SecurityUtils.isRoot(), Role::getCode, SystemConstants.ROOT_ROLE_CODE) // 非超级管理员不显示超级管理员角色
);
// 实体转换
@ -80,10 +80,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@Override
public List<Option> listRoleOptions() {
// 查询数据
List<SysRole> roleList = this.list(new LambdaQueryWrapper<SysRole>()
.ne(!SecurityUtils.isRoot(), SysRole::getCode, SystemConstants.ROOT_ROLE_CODE)
.select(SysRole::getId, SysRole::getName)
.orderByAsc(SysRole::getSort)
List<Role> roleList = this.list(new LambdaQueryWrapper<Role>()
.ne(!SecurityUtils.isRoot(), Role::getCode, SystemConstants.ROOT_ROLE_CODE)
.select(Role::getId, Role::getName)
.orderByAsc(Role::getSort)
);
// 实体转换
@ -102,22 +102,22 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
Long roleId = roleForm.getId();
// 编辑角色时判断角色是否存在
SysRole oldRole = null;
Role oldRole = null;
if (roleId != null) {
oldRole = this.getById(roleId);
Assert.isTrue(oldRole != null, "角色不存在");
}
String roleCode = roleForm.getCode();
long count = this.count(new LambdaQueryWrapper<SysRole>()
.ne(roleId != null, SysRole::getId, roleId)
long count = this.count(new LambdaQueryWrapper<Role>()
.ne(roleId != null, Role::getId, roleId)
.and(wrapper ->
wrapper.eq(SysRole::getCode, roleCode).or().eq(SysRole::getName, roleForm.getName())
wrapper.eq(Role::getCode, roleCode).or().eq(Role::getName, roleForm.getName())
));
Assert.isTrue(count == 0, "角色名称或角色编码已存在,请修改后重试!");
// 实体转换
SysRole role = roleConverter.toEntity(roleForm);
Role role = roleConverter.toEntity(roleForm);
boolean result = this.saveOrUpdate(role);
if (result) {
@ -141,7 +141,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
*/
@Override
public RoleForm getRoleForm(Long roleId) {
SysRole entity = this.getById(roleId);
Role entity = this.getById(roleId);
return roleConverter.convertToForm(entity);
}
@ -154,7 +154,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
*/
@Override
public boolean updateRoleStatus(Long roleId, Integer status) {
SysRole role = this.getById(roleId);
Role role = this.getById(roleId);
Assert.isTrue(role != null, "角色不存在");
role.setStatus(status);
@ -180,7 +180,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
.toList();
for (Long roleId : roleIds) {
SysRole role = this.getById(roleId);
Role role = this.getById(roleId);
Assert.isTrue(role != null, "角色不存在");
// 判断角色是否被用户关联
@ -218,15 +218,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@Transactional
@CacheEvict(cacheNames = "menu", key = "'routes'")
public boolean assignMenusToRole(Long roleId, List<Long> menuIds) {
SysRole role = this.getById(roleId);
Role role = this.getById(roleId);
Assert.isTrue(role != null, "角色不存在");
// 删除角色菜单
roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
roleMenuService.remove(new LambdaQueryWrapper<RoleMenu>().eq(RoleMenu::getRoleId, roleId));
// 新增角色菜单
if (CollectionUtil.isNotEmpty(menuIds)) {
List<SysRoleMenu> roleMenus = menuIds.stream()
.map(menuId -> new SysRoleMenu(roleId, menuId))
List<RoleMenu> roleMenus = menuIds.stream()
.map(menuId -> new RoleMenu(roleId, menuId))
.collect(Collectors.toList());
roleMenuService.saveBatch(roleMenus);
}

View File

@ -10,13 +10,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.common.core.model.Option;
import com.youlai.system.converter.DictConverter;
import com.youlai.system.converter.DictItemConverter;
import com.youlai.system.mapper.SysDictMapper;
import com.youlai.system.model.entity.SysDict;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.mapper.DictMapper;
import com.youlai.system.model.entity.Dict;
import com.youlai.system.model.entity.DictItem;
import com.youlai.system.model.form.DictForm;
import com.youlai.system.model.query.DictPageQuery;
import com.youlai.system.model.vo.DictPageVO;
import com.youlai.system.service.SysDictItemService;
import com.youlai.system.service.DictItemService;
import com.youlai.system.service.SysDictService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -33,9 +33,9 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
public class SysDictServiceImpl extends ServiceImpl<DictMapper, Dict> implements SysDictService {
private final SysDictItemService dictItemService;
private final DictItemService dictItemService;
private final DictConverter dictConverter;
private final DictItemConverter dictItemConverter;
@ -62,11 +62,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public boolean saveDict(DictForm dictForm) {
// 保存字典
SysDict entity = dictConverter.convertToEntity(dictForm);
Dict entity = dictConverter.convertToEntity(dictForm);
// 校验 code 是否唯一
long count = this.count(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, entity.getCode())
long count = this.count(new LambdaQueryWrapper<Dict>()
.eq(Dict::getCode, entity.getCode())
);
Assert.isTrue(count == 0, "字典编码已存在");
@ -74,7 +74,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
// 保存字典项
if (result) {
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
List<DictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
dictItems.forEach(dictItem -> dictItem.setDictId(entity.getId()));
dictItemService.saveBatch(dictItems);
}
@ -90,13 +90,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public DictForm getDictForm(Long id) {
// 获取字典
SysDict entity = this.getById(id);
Dict entity = this.getById(id);
Assert.isTrue(entity != null, "字典不存在");
DictForm dictForm = dictConverter.convertToForm(entity);
// 获取字典项集合
List<SysDictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getDictId, id)
List<DictItem> dictItems = dictItemService.list(new LambdaQueryWrapper<DictItem>()
.eq(DictItem::getDictId, id)
);
// 转换数据项
List<DictForm.DictItem> dictItemList = dictItemConverter.convertToDictFormDictItem(dictItems);
@ -113,12 +113,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public boolean updateDict(Long id, DictForm dictForm) {
// 更新字典
SysDict entity = dictConverter.convertToEntity(dictForm);
Dict entity = dictConverter.convertToEntity(dictForm);
// 校验 code 是否唯一
long count = this.count(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, entity.getCode())
.ne(SysDict::getId, id)
long count = this.count(new LambdaQueryWrapper<Dict>()
.eq(Dict::getCode, entity.getCode())
.ne(Dict::getId, id)
);
Assert.isTrue(count == 0, "字典编码已存在");
@ -127,21 +127,21 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
if (result) {
// 更新字典项
List<DictForm.DictItem> dictFormDictItems = dictForm.getDictItems();
List<SysDictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
List<DictItem> dictItems = dictItemConverter.convertToEntity(dictFormDictItems);
// 获取当前数据库中的字典项
List<SysDictItem> currentDictItemEntities = dictItemService.list(new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getDictId, id)
List<DictItem> currentDictItemEntities = dictItemService.list(new LambdaQueryWrapper<DictItem>()
.eq(DictItem::getDictId, id)
);
// 获取当前数据库中存在的字典项ID集合
Set<Long> currentDictItemIds = currentDictItemEntities.stream()
.map(SysDictItem::getId)
.map(DictItem::getId)
.collect(Collectors.toSet());
// 获取新提交的字典项ID集合
Set<Long> newAttrIds = dictItems.stream()
.map(SysDictItem::getId)
.map(DictItem::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
@ -155,7 +155,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 更新或新增字典项
for (SysDictItem dictItem : dictItems) {
for (DictItem dictItem : dictItems) {
if (dictItem.getId() != null && currentDictItemIds.contains(dictItem.getId())) {
// 更新现有字典项
dictItemService.updateById(dictItem);
@ -200,9 +200,9 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public List<Option> listDictItemsByCode(String code) {
// 根据字典编码获取字典ID
SysDict dict = this.getOne(new LambdaQueryWrapper<SysDict>()
.eq(SysDict::getCode, code)
.select(SysDict::getId)
Dict dict = this.getOne(new LambdaQueryWrapper<Dict>()
.eq(Dict::getCode, code)
.select(Dict::getId)
.last("limit 1")
);
// 如果字典不存在则返回空集合
@ -211,9 +211,9 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
// 获取字典项
List<SysDictItem> dictItems = dictItemService.list(
new LambdaQueryWrapper<SysDictItem>()
.eq(SysDictItem::getDictId, dict.getId())
List<DictItem> dictItems = dictItemService.list(
new LambdaQueryWrapper<DictItem>()
.eq(DictItem::getDictId, dict.getId())
);
// 转换为 Option

View File

@ -3,9 +3,9 @@ package com.youlai.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.system.mapper.SysUserRoleMapper;
import com.youlai.system.model.entity.SysUserRole;
import com.youlai.system.service.SysUserRoleService;
import com.youlai.system.mapper.UserRoleMapper;
import com.youlai.system.model.entity.UserRole;
import com.youlai.system.service.UserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -13,7 +13,7 @@ import java.util.List;
import java.util.stream.Collectors;
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
/**
* 保存用户角色
@ -31,10 +31,10 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
}
// 用户原角色ID集合
List<Long> userRoleIds = this.list(new LambdaQueryWrapper<SysUserRole>()
.eq(SysUserRole::getUserId, userId))
List<Long> userRoleIds = this.list(new LambdaQueryWrapper<UserRole>()
.eq(UserRole::getUserId, userId))
.stream()
.map(SysUserRole::getRoleId)
.map(UserRole::getRoleId)
.collect(Collectors.toList());
// 新增用户角色
@ -47,9 +47,9 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
.collect(Collectors.toList());
}
List<SysUserRole> saveUserRoles = saveRoleIds
List<UserRole> saveUserRoles = saveRoleIds
.stream()
.map(roleId -> new SysUserRole(userId, roleId))
.map(roleId -> new UserRole(userId, roleId))
.collect(Collectors.toList());
this.saveBatch(saveUserRoles);
@ -60,9 +60,9 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(removeRoleIds)) {
this.remove(new LambdaQueryWrapper<SysUserRole>()
.eq(SysUserRole::getUserId, userId)
.in(SysUserRole::getRoleId, removeRoleIds)
this.remove(new LambdaQueryWrapper<UserRole>()
.eq(UserRole::getUserId, userId)
.in(UserRole::getRoleId, removeRoleIds)
);
}
}

View File

@ -19,9 +19,9 @@ import com.youlai.common.sms.config.AliyunSmsProperties;
import com.youlai.common.sms.service.SmsService;
import com.youlai.system.converter.UserConverter;
import com.youlai.system.dto.UserAuthInfo;
import com.youlai.system.mapper.SysUserMapper;
import com.youlai.system.mapper.UserMapper;
import com.youlai.system.model.bo.UserBO;
import com.youlai.system.model.entity.SysUser;
import com.youlai.system.model.entity.User;
import com.youlai.system.model.form.UserForm;
import com.youlai.system.model.form.UserRegisterForm;
import com.youlai.system.model.query.UserPageQuery;
@ -29,9 +29,9 @@ import com.youlai.system.model.vo.UserExportVO;
import com.youlai.system.model.vo.UserInfoVO;
import com.youlai.system.model.vo.UserPageVO;
import com.youlai.system.model.vo.UserProfileVO;
import com.youlai.system.service.SysRoleService;
import com.youlai.system.service.SysUserRoleService;
import com.youlai.system.service.SysUserService;
import com.youlai.system.service.RoleService;
import com.youlai.system.service.UserRoleService;
import com.youlai.system.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -52,13 +52,13 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
private final PasswordEncoder passwordEncoder;
private final SysUserRoleService userRoleService;
private final UserRoleService userRoleService;
private final SysRoleService roleService;
private final RoleService roleService;
private final UserConverter userConverter;
@ -77,9 +77,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return {@link UserPageVO}
*/
@Override
public IPage<UserPageVO> listPagedUsers(UserPageQuery queryParams) {
public IPage<UserPageVO> getUserPage(UserPageQuery queryParams) {
Page<UserBO> userPage = this.baseMapper.listPagedUsers(
Page<UserBO> userPage = this.baseMapper.getUserPage(
new Page<>(queryParams.getPageNum(), queryParams.getPageSize()),
queryParams
);
@ -111,11 +111,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String username = userForm.getUsername();
long count = this.count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
long count = this.count(new LambdaQueryWrapper<User>().eq(User::getUsername, username));
Assert.isTrue(count == 0, "用户名已存在");
// 实体转换 form->entity
SysUser entity = userConverter.toEntity(userForm);
User entity = userConverter.toEntity(userForm);
// 设置默认加密密码
String defaultEncryptPwd = passwordEncoder.encode(SystemConstants.DEFAULT_PASSWORD);
@ -144,14 +144,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String username = userForm.getUsername();
long count = this.count(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getUsername, username)
.ne(SysUser::getId, userId)
long count = this.count(new LambdaQueryWrapper<User>()
.eq(User::getUsername, username)
.ne(User::getId, userId)
);
Assert.isTrue(count == 0, "用户名已存在");
// form -> entity
SysUser entity = userConverter.toEntity(userForm);
User entity = userConverter.toEntity(userForm);
// 修改用户
boolean result = this.updateById(entity);
@ -188,9 +188,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public boolean updatePassword(Long userId, String password) {
return this.update(new LambdaUpdateWrapper<SysUser>()
.eq(SysUser::getId, userId)
.set(SysUser::getPassword, passwordEncoder.encode(password))
return this.update(new LambdaUpdateWrapper<User>()
.eq(User::getId, userId)
.set(User::getPassword, passwordEncoder.encode(password))
);
}
@ -234,12 +234,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
public UserInfoVO getCurrentUserInfo() {
// 登录用户entity
SysUser user = this.getOne(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getUsername, SecurityUtils.getUsername())
User user = this.getOne(new LambdaQueryWrapper<User>()
.eq(User::getUsername, SecurityUtils.getUsername())
.select(
SysUser::getId,
SysUser::getNickname,
SysUser::getAvatar
User::getId,
User::getNickname,
User::getAvatar
)
);
// entity->VO
@ -305,14 +305,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
redisTemplate.delete(RedisConstants.REGISTER_SMS_CODE_PREFIX + mobile);
// 校验手机号是否已注册
long count = this.count(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getMobile, mobile)
long count = this.count(new LambdaQueryWrapper<User>()
.eq(User::getMobile, mobile)
.or()
.eq(SysUser::getUsername, mobile)
.eq(User::getUsername, mobile)
);
Assert.isTrue(count == 0, "手机号已注册");
SysUser entity = new SysUser();
User entity = new User();
entity.setUsername(mobile);
entity.setMobile(mobile);
entity.setStatus(GlobalConstants.STATUS_YES);

View File

@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysDeptMapper">
<mapper namespace="com.youlai.system.mapper.DeptMapper">
</mapper>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysDictItemMapper">
<mapper namespace="com.youlai.system.mapper.DictItemMapper">
<!-- 根据字典编码获取字典列表 -->
<select id="listDictItemsByDictId" resultType="com.youlai.system.model.vo.DictPageVO$DictItem">

View File

@ -2,13 +2,13 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysDictMapper">
<mapper namespace="com.youlai.system.mapper.DictMapper">
<!-- 字典映射 -->
<resultMap id="DictMap" type="com.youlai.system.model.vo.DictPageVO">
<collection property="dictItems"
column="{dictId=id}"
select="com.youlai.system.mapper.SysDictItemMapper.listDictItemsByDictId">
select="com.youlai.system.mapper.DictItemMapper.listDictItemsByDictId">
</collection>
</resultMap>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysMenuMapper">
<mapper namespace="com.youlai.system.mapper.MenuMapper">
<!-- 菜单路由映射 -->
<resultMap id="RouteMap" type="com.youlai.system.model.bo.RouteBO">

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysRoleMapper">
<mapper namespace="com.youlai.system.mapper.RoleMapper">
<!-- 获取最大范围的数据权限 -->
<select id="getMaxDataRangeDataScope" resultType="java.lang.Integer">

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysRoleMenuMapper">
<mapper namespace="com.youlai.system.mapper.RoleMenuMapper">
<!-- 获取角色拥有的菜单ID集合 -->
<select id="listMenuIdsByRoleId" resultType="java.lang.Long">

View File

@ -2,10 +2,10 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysUserMapper">
<mapper namespace="com.youlai.system.mapper.UserMapper">
<!-- 用户分页列表 -->
<select id="listPagedUsers" resultType="com.youlai.system.model.bo.UserBO">
<select id="getUserPage" resultType="com.youlai.system.model.bo.UserBO">
SELECT
u.id,
u.username,
@ -55,7 +55,7 @@
<collection
property="roleIds"
column="id"
select="com.youlai.system.mapper.SysUserRoleMapper.listRoleIdsByUserId" >
select="com.youlai.system.mapper.UserRoleMapper.listRoleIdsByUserId" >
<result column="role_id" />
</collection>
</resultMap>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysUserRoleMapper">
<mapper namespace="com.youlai.system.mapper.UserRoleMapper">
<!-- 根据用户ID获取角色ID集合 -->
<select id="listRoleIdsByUserId" resultType="java.lang.Long">