feat(新增): 用户管理CURD查询
This commit is contained in:
parent
50a01b3309
commit
e7784e7ae6
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerIntercep
|
|||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
* MybatisPlus配置类
|
||||
*/
|
||||
@EnableTransactionManagement
|
||||
@MapperScan("com.atguigu.ssyx.*.mapper")
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class MybatisPlusConfig {
|
||||
|
@ -24,7 +26,7 @@ public class MybatisPlusConfig {
|
|||
@Bean
|
||||
public MybatisPlusInterceptor optimisticLockerInnerInterceptor() {
|
||||
log.info("注入MybatisPlus配置类...");
|
||||
|
||||
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 向Mybatis过滤器链中添加分页拦截器
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
|
|
|
@ -19,11 +19,9 @@ import java.io.Serializable;
|
|||
@Data
|
||||
@ApiModel(description = "角色查询实体")
|
||||
public class RoleQueryVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
private String roleName;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
private String roleName;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,59 @@
|
|||
<url>https://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<docker.repostory>192.168.1.4:1100</docker.repostory>
|
||||
<docker.registry.name>ssyx</docker.registry.name>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<!--将插件绑定在某个phase执行-->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<!--将插件绑定在package这个phase(阶段)上。也就是说,用户只需执行mvn package,就会自动执行mvn docker:build-->
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>harbor</serverId>
|
||||
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||
<!-- 配置docker主机地址 -->
|
||||
<dockerHost>http://192.168.1.4:2375</dockerHost>
|
||||
<!--指定生成的镜像名-->
|
||||
<imageName>
|
||||
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
|
||||
</imageName>
|
||||
<!-- 指定 dockerfile 路径-->
|
||||
<dockerDirectory>${project.basedir}</dockerDirectory>
|
||||
<!-- 是否跳过docker构建 -->
|
||||
<skipDockerBuild>false</skipDockerBuild>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package com.atguigu.ssyx.acl;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.atguigu.ssyx", "com.atguigu.ssyx.acl"})
|
||||
@MapperScan("com.atguigu.ssyx.*.mapper")
|
||||
public class ServiceAclApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceAclApplication.class, args);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.atguigu.ssyx.acl.controller;
|
||||
|
||||
import com.atguigu.ssyx.acl.service.RoleService;
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.acl.Role;
|
||||
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/acl/role")
|
||||
@Api(tags = "用户管理")
|
||||
@Slf4j
|
||||
public class RoleController {
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@ApiOperation(value = "获取角色分页列表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<IPage<Role>> index(@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
|
||||
@ApiParam(name = "roleQueryVo", value = "查询对象")
|
||||
RoleQueryVo vo) {
|
||||
IPage<Role> roleIPage = roleService.selectPage(page, limit, vo);
|
||||
return Result.success(roleIPage);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取角色")
|
||||
@GetMapping("get/{id}")
|
||||
public Result<Role> getRole(@PathVariable Long id) {
|
||||
Role role = roleService.getById(id);
|
||||
return Result.success(role);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增角色")
|
||||
@PostMapping("save")
|
||||
public Result<Role> saveRole(@RequestBody Role role) {
|
||||
roleService.updateById(role);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除角色")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result<Role> removeRole(@PathVariable Long id) {
|
||||
roleService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id列表删除角色")
|
||||
@DeleteMapping("batchRemove")
|
||||
public Result<List<Long>> batchRemove(@RequestBody List<Long> ids) {
|
||||
roleService.removeByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
package com.atguigu.ssyx.acl.service;
|
||||
|
||||
import com.atguigu.ssyx.model.acl.Role;
|
||||
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface RoleService extends IService<Role> {
|
||||
// 获取角色分页列表
|
||||
IPage<Role> selectPage(Long page, Long limit, RoleQueryVo vo);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,30 @@ package com.atguigu.ssyx.acl.service.impl;
|
|||
import com.atguigu.ssyx.acl.mapper.RoleMapper;
|
||||
import com.atguigu.ssyx.acl.service.RoleService;
|
||||
import com.atguigu.ssyx.model.acl.Role;
|
||||
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||
@Override
|
||||
public IPage<Role> selectPage(Long page, Long limit, RoleQueryVo vo) {
|
||||
Page<Role> rolePage = new Page<>(page, limit);
|
||||
// 获取条件值
|
||||
String roleName = vo.getRoleName();
|
||||
// 创建mp对象
|
||||
LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>();
|
||||
// 判断条件值是否为空
|
||||
if (StringUtils.isEmpty(roleName)) {
|
||||
wrapper.like(Role::getRoleName, rolePage);
|
||||
}
|
||||
// 调用犯法实现分页查询
|
||||
return baseMapper.selectPage(rolePage, wrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
server:
|
||||
port: 8201
|
||||
|
||||
port: 8200
|
||||
|
||||
bunny:
|
||||
datasource:
|
||||
host: 106.15.251.123
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 8291
|
||||
port: 8200
|
||||
spring:
|
||||
application:
|
||||
name: service-acl
|
||||
|
@ -36,8 +36,8 @@ mybatis-plus:
|
|||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||
# global-config:
|
||||
# db-config:
|
||||
# 设置表名前缀,不用在每个tableName添加前缀
|
||||
# table-prefix: t_
|
||||
# 设置表名前缀,不用在每个tableName添加前缀
|
||||
# table-prefix: t_
|
||||
# 全局配置主键值方式
|
||||
# id-type: assign_id
|
||||
# 指定逻辑删除-未删除
|
||||
|
|
Loading…
Reference in New Issue