feature(权限点):增加权限点API接口;
refactor(init): 补充依赖,删除示例代码
This commit is contained in:
parent
cfc3aa9e4e
commit
cb88f99a24
@ -0,0 +1,24 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeQueryReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限点API接口
|
||||
*
|
||||
* @version V1.0
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/6 14:48
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://localhost:8899}")
|
||||
public interface PermissionPointApi {
|
||||
|
||||
/** 查询权限点树形节点 **/
|
||||
@PostMapping(value = "/api/v1/permissionPoint/listTreeNodes")
|
||||
ApiResult<List<PermissionPointTreeNode>> listTreeNodes(PermissionPointTreeQueryReq request);
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.tyr.client.model.permission;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -9,6 +11,7 @@ import java.time.LocalDateTime;
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/5 15:50
|
||||
*/
|
||||
@Data
|
||||
public class PermissionPointDTO {
|
||||
|
||||
/**
|
||||
@ -68,7 +71,7 @@ public class PermissionPointDTO {
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 菜单适用于平台 0:企业工作台 1:项目工作台
|
||||
* 菜单适用工作台
|
||||
*/
|
||||
private String terminal;
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.tyr.client.model.permission;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -9,6 +11,7 @@ import java.util.List;
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/5 15:20
|
||||
*/
|
||||
@Data
|
||||
public class PermissionPointTreeNode {
|
||||
/** 权限点ID **/
|
||||
private Long permissionPointId;
|
||||
|
||||
@ -2,6 +2,8 @@ package cn.axzo.tyr.client.model.permission;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限点树形查询请求参数
|
||||
*
|
||||
@ -20,4 +22,7 @@ public class PermissionPointTreeQueryReq {
|
||||
|
||||
/** 权限点父级ID - 用于查询子节点 **/
|
||||
private Long parentId;
|
||||
|
||||
/** 权限点所属工作台 **/
|
||||
private List<String> terminalList;
|
||||
}
|
||||
|
||||
@ -20,6 +20,13 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.tyr</groupId>
|
||||
<artifactId>tyr-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-web-spring-boot-starter</artifactId>
|
||||
@ -36,16 +43,21 @@
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-processor-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!--mybatis-plus-->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-mybatisplus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- swagger-yapi -->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-swagger-yapi-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@ -1,13 +1,44 @@
|
||||
package cn.axzo.tyr.server;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@MapperScan(value = {"cn.axzo.**.mapper"})
|
||||
@SpringBootApplication
|
||||
@Slf4j
|
||||
@EnableAsync
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {
|
||||
"cn.axzo.data.collection.api",
|
||||
})
|
||||
@MapperScan(value = {"cn.axzo.tyr.server.repository.mapper"})
|
||||
@SpringBootApplication(scanBasePackages = "cn.axzo")
|
||||
public class TyrApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TyrApplication.class, args);
|
||||
ConfigurableApplicationContext run = SpringApplication.run(TyrApplication.class, args);
|
||||
Environment env = run.getEnvironment();
|
||||
log.info(
|
||||
"--------------------------------------------------------------------------------------------------------------------\n" +
|
||||
"Application 【{}】 is running on 【{}】 environment!\n" +
|
||||
"Api Local: \thttp://127.0.0.1:{}\n" +
|
||||
"Mysql: \t{}\t username:{}\n" +
|
||||
"Redis: \t{}:{}\t database:{}\n" +
|
||||
"RabbitMQ: \t{}\t username:{}",
|
||||
env.getProperty("spring.application.name"),
|
||||
env.getProperty("spring.profiles.active"),
|
||||
env.getProperty("server.port"),
|
||||
env.getProperty("spring.datasource.url"),
|
||||
env.getProperty("spring.datasource.username"),
|
||||
env.getProperty("spring.redis.host"),
|
||||
env.getProperty("spring.redis.port"),
|
||||
env.getProperty("spring.redis.database"),
|
||||
env.getProperty("spring.rabbitmq.addresses"),
|
||||
env.getProperty("spring.rabbitmq.username") +
|
||||
"\n----------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
package cn.axzo.tyr.server.controller.app;
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.axzo.tyr.server.controller.permission;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.PermissionPointApi;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeQueryReq;
|
||||
import cn.axzo.tyr.server.service.PermissionPointService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限点接口实现
|
||||
*
|
||||
* @version V1.0
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/6 14:55
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class PermissionPointController implements PermissionPointApi {
|
||||
|
||||
private final PermissionPointService permissionPointService;
|
||||
|
||||
@Override
|
||||
public ApiResult<List<PermissionPointTreeNode>> listTreeNodes(PermissionPointTreeQueryReq request) {
|
||||
|
||||
return ApiResult.ok(permissionPointService.listTreeNodes(request));
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
package cn.axzo.tyr.server.controller.web;
|
||||
|
||||
import cn.axzo.tyr.server.service.user.UserService;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.NewUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UpdateUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO;
|
||||
import cn.axzo.tyr.server.service.dto.response.user.UserVO;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "web-用户信息接口")
|
||||
@ApiSupport(author = "田立勇")
|
||||
@RequestMapping("/api/v1")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@ApiOperation(value = "创建用户")
|
||||
@PostMapping("/users")
|
||||
public CommonResponse<UserVO> createUser(@Valid @RequestBody NewUserDTO dto) {
|
||||
log.info("REST request to save user : {}", dto);
|
||||
// 校验入参
|
||||
dto.valid();
|
||||
UserVO result = userService.create(dto);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户")
|
||||
@PutMapping("/users/{id}")
|
||||
public CommonResponse<UserVO> updateUser(@ApiParam("用户ID") @PathVariable Long id,
|
||||
@Valid @RequestBody UpdateUserDTO dto) {
|
||||
log.info("REST request to update user : {}", dto);
|
||||
// 校验入参
|
||||
dto.valid();
|
||||
UserVO result = userService.update(id, dto);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/users")
|
||||
public CommonResponse<CommonPageResponse<UserVO>> getUsers(@Valid UserQO userQO) {
|
||||
CommonPageResponse<UserVO> results = userService.queryByPage(userQO);
|
||||
return CommonResponse.success(results);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户详情")
|
||||
@GetMapping("/users/{id}")
|
||||
public CommonResponse getUser(@ApiParam("用户ID") @PathVariable Long id) {
|
||||
UserVO result = userService.getOne(id);
|
||||
return CommonResponse.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户")
|
||||
@DeleteMapping("/users/{id}")
|
||||
public CommonResponse deleteUser(@ApiParam("用户ID") @PathVariable Long id) {
|
||||
userService.delete(id);
|
||||
return CommonResponse.success();
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
package cn.axzo.tyr.server.controller.web;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.page.PageResp;
|
||||
import cn.axzo.framework.web.http.ApiResponse;
|
||||
import cn.axzo.framework.web.http.ApiPageResponse;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.NewUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UpdateUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO1;
|
||||
import cn.axzo.tyr.server.service.dto.response.user.UserVO;
|
||||
import cn.axzo.tyr.server.service.user.UserService;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/10/28
|
||||
* @Description: 新项目搭建推荐方式
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "web-用户信息接口")
|
||||
@ApiSupport(author = "田立勇")
|
||||
@RequestMapping("/api/v2")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class UserResource {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@ApiOperation(value = "创建用户")
|
||||
@PostMapping("/users")
|
||||
public ApiResponse<UserVO> createUser(@Valid @RequestBody NewUserDTO dto) {
|
||||
log.info("REST request to save user : {}", dto);
|
||||
// 校验入参
|
||||
dto.valid();
|
||||
UserVO result = userService.create(dto);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户")
|
||||
@PutMapping("/users/{id}")
|
||||
public ApiResponse<UserVO> updateUser(@ApiParam("用户ID") @PathVariable Long id,
|
||||
@Valid @RequestBody UpdateUserDTO dto) {
|
||||
log.info("REST request to update user : {}", dto);
|
||||
// 校验入参
|
||||
dto.valid();
|
||||
UserVO result = userService.update(id, dto);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/users")
|
||||
public ApiPageResponse<UserVO> getUsers(@ModelAttribute UserQO1 userQo, PageQO page) {
|
||||
PageResp<UserVO> results = userService.find(userQo, page);
|
||||
return ApiPageResponse.ok(results);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户详情")
|
||||
@GetMapping("/users/{id}")
|
||||
public ApiResponse<UserVO> getUser(@ApiParam("用户ID") @PathVariable Long id) {
|
||||
UserVO result = userService.getOne(id);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户")
|
||||
@DeleteMapping("/users/{id}")
|
||||
public ApiResponse deleteUser(@ApiParam("用户ID") @PathVariable Long id) {
|
||||
userService.delete(id);
|
||||
return ApiResponse.ok();
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
package cn.axzo.tyr.server.repository;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.tyr.server.repository.mapper.UserMapper;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO1;
|
||||
import cn.axzo.tyr.server.repository.entity.user.User;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class UserDao extends ServiceImpl<UserMapper, User> {
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public User findById(Long id) {
|
||||
return userMapper.selectById(id);
|
||||
}
|
||||
|
||||
public void delete(Long id) {
|
||||
userMapper.deleteById(id);
|
||||
}
|
||||
|
||||
public IPage<User> queryByPage(UserQO userQO) {
|
||||
return userMapper.selectPage(userQO.toPage(),
|
||||
Wrappers.lambdaQuery(User.class)
|
||||
.eq(userQO.getId() != null, User::getId, userQO.getId())
|
||||
.like(StringUtils.isNotBlank(userQO.getName()), User::getName, userQO.getName())
|
||||
.like(StringUtils.isNotBlank(userQO.getPhone()), User::getPhone, userQO.getPhone())
|
||||
.like(StringUtils.isNotBlank(userQO.getEmail()), User::getEmail, userQO.getEmail())
|
||||
.orderByDesc(User::getCreateAt)
|
||||
);
|
||||
}
|
||||
|
||||
public IPage<User> find(UserQO1 userQO, PageQO page) {
|
||||
return userMapper.selectPage(page.toPage(),
|
||||
Wrappers.lambdaQuery(User.class)
|
||||
.eq(userQO.getId() != null, User::getId, userQO.getId())
|
||||
.like(StringUtils.isNotBlank(userQO.getName()), User::getName, userQO.getName())
|
||||
.like(StringUtils.isNotBlank(userQO.getPhone()), User::getPhone, userQO.getPhone())
|
||||
.like(StringUtils.isNotBlank(userQO.getEmail()), User::getEmail, userQO.getEmail())
|
||||
.orderByDesc(User::getCreateAt)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
package cn.axzo.tyr.server.repository.entity;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -10,7 +8,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
package cn.axzo.tyr.server.repository.entity.user;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@TableName("b_user")
|
||||
public class User extends BaseEntity<User> {
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer sex;
|
||||
|
||||
private Integer age;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String email;
|
||||
|
||||
private String address;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package cn.axzo.tyr.server.repository.mapper;
|
||||
|
||||
import cn.axzo.tyr.server.repository.entity.user.User;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeQueryReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限点服务
|
||||
*
|
||||
* @version V1.0
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/6 15:51
|
||||
*/
|
||||
public interface PermissionPointService {
|
||||
List<PermissionPointTreeNode> listTreeNodes(PermissionPointTreeQueryReq request);
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.converter;
|
||||
|
||||
import cn.axzo.tyr.server.service.dto.request.user.NewUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UpdateUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.response.user.UserVO;
|
||||
import cn.axzo.tyr.server.repository.entity.user.User;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
import static org.mapstruct.NullValueCheckStrategy.ALWAYS;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper(
|
||||
componentModel = "spring",
|
||||
nullValueCheckStrategy = ALWAYS
|
||||
)
|
||||
public interface UserConverter extends EntityConverter<UserVO, User> {
|
||||
|
||||
User toEntity(NewUserDTO dto);
|
||||
|
||||
void updateEntity(UpdateUserDTO dto, @MappingTarget User user);
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.request.user;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class NewUserDTO {
|
||||
|
||||
@ApiModelProperty(value = "名称", position = 1)
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "性别", position = 2)
|
||||
@NotNull
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "年龄", position = 3)
|
||||
private Integer age;
|
||||
|
||||
@ApiModelProperty(value = "电话", position = 4)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱", position = 5)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "地址", position = 6)
|
||||
private String address;
|
||||
|
||||
public void valid() {
|
||||
// 电话和邮箱不能都为空
|
||||
if (StringUtils.isEmpty(phone) && StringUtils.isEmpty(email)) {
|
||||
throw new RuntimeException("电话和邮箱不能都为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.request.user;
|
||||
|
||||
import cn.axzo.framework.domain.web.ApiException;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import static cn.axzo.tyr.server.common.enums.ErrorCode.USER_PHONE_EMAIL_IS_NULL;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UpdateUserDTO {
|
||||
|
||||
@ApiModelProperty(value = "名称", position = 1)
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "性别", position = 2)
|
||||
@NotNull
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "年龄", position = 3)
|
||||
private Integer age;
|
||||
|
||||
@ApiModelProperty(value = "电话", position = 4)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱", position = 5)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "地址", position = 6)
|
||||
private String address;
|
||||
|
||||
public void valid() {
|
||||
// 电话和邮箱不能都为空
|
||||
if (StringUtils.isEmpty(phone) && StringUtils.isEmpty(email)) {
|
||||
throw new ApiException(USER_PHONE_EMAIL_IS_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.request.user;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserQO extends PageQO {
|
||||
|
||||
@ApiParam("主键")
|
||||
private Long id;
|
||||
|
||||
@ApiParam("姓名")
|
||||
private String name;
|
||||
|
||||
@ApiParam("手机")
|
||||
private String phone;
|
||||
|
||||
@ApiParam("邮箱")
|
||||
private String email;
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.request.user;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/5
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserQO1 {
|
||||
|
||||
@ApiParam("主键")
|
||||
private Long id;
|
||||
|
||||
@ApiParam("姓名")
|
||||
private String name;
|
||||
|
||||
@ApiParam("手机")
|
||||
private String phone;
|
||||
|
||||
@ApiParam("邮箱")
|
||||
private String email;
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.dto.response.user;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserVO {
|
||||
|
||||
@ApiModelProperty(value = "id", position = 1)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "名称", position = 2)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "性别", position = 3)
|
||||
private Integer sex;
|
||||
|
||||
@ApiModelProperty(value = "年龄", position = 4)
|
||||
private Integer age;
|
||||
|
||||
@ApiModelProperty(value = "电话", position = 5)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱", position = 6)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "地址", position = 7)
|
||||
private String address;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeQueryReq;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.service.SaasFeatureDao;
|
||||
import cn.axzo.tyr.server.service.PermissionPointService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限点服务实现
|
||||
*
|
||||
* @version V1.0
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/6 15:51
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
private final SaasFeatureDao saasFeatureDao;
|
||||
|
||||
@Override
|
||||
public List<PermissionPointTreeNode> listTreeNodes(PermissionPointTreeQueryReq request) {
|
||||
List<SaasFeature> list = saasFeatureDao.list(new LambdaQueryWrapper<SaasFeature>()
|
||||
.eq(Objects.isNull(request.getDelegateType()), SaasFeature::getDelegatedType, request.getDelegateType())
|
||||
.eq(Objects.isNull(request.getParentId()), SaasFeature::getParentId, request.getParentId())
|
||||
.in(CollectionUtil.isEmpty(request.getTerminalList()), SaasFeature::getTerminal, request.getTerminalList())
|
||||
);
|
||||
return list.stream().map(this::feature2Node).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private PermissionPointTreeNode feature2Node(SaasFeature feature) {
|
||||
PermissionPointTreeNode node = new PermissionPointTreeNode();
|
||||
node.setPermissionPointId(feature.getId());
|
||||
node.setPermissionName(feature.getFeatureName());
|
||||
node.setParentId(feature.getParentId());
|
||||
node.setTerminal(feature.getTerminal());
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.user;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.page.PageResp;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.NewUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UpdateUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO1;
|
||||
import cn.axzo.tyr.server.service.dto.response.user.UserVO;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
public interface UserService {
|
||||
UserVO create(NewUserDTO dto);
|
||||
|
||||
UserVO update(Long id, UpdateUserDTO dto);
|
||||
|
||||
UserVO getOne(Long id);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
CommonPageResponse<UserVO> queryByPage(UserQO userQO);
|
||||
|
||||
PageResp<UserVO> find(UserQO1 userQo, PageQO page);
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
package cn.axzo.tyr.server.service.user.impl;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.page.PageResp;
|
||||
import cn.axzo.framework.domain.web.ApiException;
|
||||
import cn.axzo.tyr.server.common.enums.ErrorCode;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.NewUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UpdateUserDTO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO;
|
||||
import cn.axzo.tyr.server.service.dto.request.user.UserQO1;
|
||||
import cn.axzo.tyr.server.service.dto.response.user.UserVO;
|
||||
import cn.axzo.tyr.server.repository.entity.user.User;
|
||||
import cn.axzo.tyr.server.repository.UserDao;
|
||||
import cn.axzo.tyr.server.service.user.UserService;
|
||||
import cn.axzo.tyr.server.service.converter.UserConverter;
|
||||
import cn.azxo.framework.common.model.CommonPageResponse;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/2
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private final UserConverter userConverter;
|
||||
|
||||
private final UserDao userDao;
|
||||
|
||||
@Override
|
||||
public UserVO create(NewUserDTO dto) {
|
||||
User user = userConverter.toEntity(dto);
|
||||
userDao.save(user);
|
||||
return userConverter.toVo(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVO update(Long id, UpdateUserDTO dto) {
|
||||
User user = userDao.findById(id);
|
||||
if (user == null) {
|
||||
throw new ApiException(ErrorCode.USER_NOT_EXISTS, id);
|
||||
}
|
||||
userConverter.updateEntity(dto, user);
|
||||
return userConverter.toVo(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVO getOne(Long id) {
|
||||
User user = userDao.findById(id);
|
||||
return userConverter.toVo(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
userDao.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonPageResponse<UserVO> queryByPage(UserQO userQo) {
|
||||
IPage<User> page = userDao.queryByPage(userQo);
|
||||
List<User> userList = page.getRecords();
|
||||
if (CollectionUtils.isEmpty(userList)) {
|
||||
return CommonPageResponse.zero(userQo.getPage(), userQo.getPageSize());
|
||||
}
|
||||
return new CommonPageResponse<>(page.getCurrent(), page.getSize(), page.getTotal(), userConverter.toVo(page.getRecords()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResp<UserVO> find(UserQO1 userQo, PageQO page) {
|
||||
IPage<User> userPage = userDao.find(userQo, page);
|
||||
return PageResp.list(userPage, userConverter.toVo(userPage.getRecords()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.axzo.tyr.server.permission;
|
||||
|
||||
import cn.axzo.tyr.server.controller.permission.PermissionPointController;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.service.SaasFeatureDao;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限点测试
|
||||
*
|
||||
* @version V1.0
|
||||
* @author: ZhanSiHu
|
||||
* @date: 2023/9/6 14:59
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class PermissionPointTest {
|
||||
@Autowired
|
||||
private PermissionPointController controller;
|
||||
@Autowired
|
||||
private SaasFeatureDao saasFeatureDao;
|
||||
|
||||
@Test
|
||||
public void testList() {
|
||||
List<SaasFeature> saasFeatures = saasFeatureDao.listByIds(Arrays.asList(206L, 207L, 208L));
|
||||
System.out.println(JSON.toJSONString(saasFeatures));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user