🚀 用户管理接口CURD完成
This commit is contained in:
parent
8dd2be3438
commit
f8c44113a8
|
@ -4,10 +4,6 @@ target/
|
||||||
!**/src/test/**/target/
|
!**/src/test/**/target/
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea/modules.xml
|
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
@ -37,4 +33,4 @@ build/
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
/logs/
|
logs
|
|
@ -18,7 +18,7 @@ public class CodeGet {
|
||||||
// 全局配置
|
// 全局配置
|
||||||
GlobalConfig gc = new GlobalConfig();
|
GlobalConfig gc = new GlobalConfig();
|
||||||
// TODO 需要修改路径名称
|
// TODO 需要修改路径名称
|
||||||
gc.setOutputDir("F:\\File\\Java\\ssyx\\ssyx-parent\\service\\service-order" + "/src/main/java");
|
gc.setOutputDir("G:\\java项目\\guigu-oa\\guigu-oa-parent\\service-oa" + "/src/main/java");
|
||||||
|
|
||||||
gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
||||||
gc.setAuthor("bunny");
|
gc.setAuthor("bunny");
|
||||||
|
@ -28,7 +28,7 @@ public class CodeGet {
|
||||||
// 3、数据源配置
|
// 3、数据源配置
|
||||||
DataSourceConfig dsc = new DataSourceConfig();
|
DataSourceConfig dsc = new DataSourceConfig();
|
||||||
// TODO 需要修改数据库
|
// TODO 需要修改数据库
|
||||||
dsc.setUrl("jdbc:mysql://106.15.251.123:3305/shequ-order?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
|
dsc.setUrl("jdbc:mysql://106.15.251.123:3305/guigu-oa?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
|
||||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||||
dsc.setUsername("root");
|
dsc.setUsername("root");
|
||||||
dsc.setPassword("02120212");
|
dsc.setPassword("02120212");
|
||||||
|
@ -37,9 +37,9 @@ public class CodeGet {
|
||||||
|
|
||||||
// 4、包配置
|
// 4、包配置
|
||||||
PackageConfig pc = new PackageConfig();
|
PackageConfig pc = new PackageConfig();
|
||||||
pc.setParent("com.atguigu.ssyx");
|
pc.setParent("com.atguigu");
|
||||||
// TODO 需要修改模块名
|
// TODO 需要修改模块名
|
||||||
pc.setModuleName("order");
|
pc.setModuleName("auth");
|
||||||
pc.setController("controller");
|
pc.setController("controller");
|
||||||
pc.setService("service");
|
pc.setService("service");
|
||||||
pc.setMapper("mapper");
|
pc.setMapper("mapper");
|
||||||
|
@ -47,7 +47,6 @@ public class CodeGet {
|
||||||
|
|
||||||
// 5、策略配置
|
// 5、策略配置
|
||||||
StrategyConfig strategy = getStrategyConfig();
|
StrategyConfig strategy = getStrategyConfig();
|
||||||
|
|
||||||
mpg.setStrategy(strategy);
|
mpg.setStrategy(strategy);
|
||||||
|
|
||||||
// 6、执行
|
// 6、执行
|
||||||
|
@ -57,7 +56,7 @@ public class CodeGet {
|
||||||
private static StrategyConfig getStrategyConfig() {
|
private static StrategyConfig getStrategyConfig() {
|
||||||
StrategyConfig strategy = new StrategyConfig();
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
// TODO 要生成的表
|
// TODO 要生成的表
|
||||||
strategy.setInclude("cart_info", "order_item", "order_info", "order_deliver");
|
strategy.setInclude("sys_user", "sys_role");
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
||||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
||||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||||
|
|
Binary file not shown.
|
@ -5,48 +5,50 @@ import com.atguigu.common.result.Result;
|
||||||
import com.atguigu.model.system.SysRole;
|
import com.atguigu.model.system.SysRole;
|
||||||
import com.atguigu.vo.system.SysRoleQueryVo;
|
import com.atguigu.vo.system.SysRoleQueryVo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Api(tags = "角色管理")
|
@Tag(name = "角色管理接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/system/sysRole")
|
@RequestMapping("/admin/system/sysRole")
|
||||||
public class SysRoleController {
|
public class SysRoleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleService sysRoleService;
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
@ApiOperation(value = "查询全部角色列表")
|
@Operation(summary = "查询全部角色列表", description = "查询全部角色列表")
|
||||||
@GetMapping("findAll")
|
@GetMapping("findAll")
|
||||||
public Result<List<SysRole>> findAll() {
|
public Result<List<SysRole>> findAll() {
|
||||||
List<SysRole> sysRoleList = sysRoleService.list();
|
List<SysRole> sysRoleList = sysRoleService.list();
|
||||||
return Result.success(sysRoleList);
|
return Result.success(sysRoleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("角色条件分页查询")
|
@Operation(summary = "角色条件分页查询", description = "角色条件分页查询")
|
||||||
@GetMapping("{page}/{limit}")
|
@GetMapping("{page}/{limit}")
|
||||||
public Result<IPage<SysRole>> pageResult(@PathVariable Long page, @PathVariable Long limit, SysRoleQueryVo sysRoleQueryVo) {
|
public Result<IPage<SysRole>> pageResult(@PathVariable Long page, @PathVariable Long limit, SysRoleQueryVo sysRoleQueryVo) {
|
||||||
IPage<SysRole> sysRoleIPage = sysRoleService.pageResult(page, limit, sysRoleQueryVo);
|
IPage<SysRole> sysRoleIPage = sysRoleService.pageResult(page, limit, sysRoleQueryVo);
|
||||||
return Result.success(sysRoleIPage);
|
return Result.success(sysRoleIPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "新增角色")
|
@Operation(summary = "新增角色", description = "新增角色")
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
public Result<SysRole> save(@RequestBody SysRole sysRole) {
|
public Result<SysRole> save(@RequestBody SysRole sysRole) {
|
||||||
sysRoleService.save(sysRole);
|
sysRoleService.save(sysRole);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改角色")
|
@Operation(summary = "修改角色", description = "修改角色")
|
||||||
@PutMapping("update")
|
@PutMapping("update")
|
||||||
public Result<SysRole> update(@RequestBody SysRole sysRole) {
|
public Result<SysRole> update(@RequestBody SysRole sysRole) {
|
||||||
sysRoleService.updateById(sysRole);
|
sysRoleService.updateById(sysRole);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除角色", description = "删除角色")
|
||||||
@ApiOperation(value = "删除角色")
|
@ApiOperation(value = "删除角色")
|
||||||
@DeleteMapping("remove/{id}")
|
@DeleteMapping("remove/{id}")
|
||||||
public Result<SysRole> remove(@PathVariable Long id) {
|
public Result<SysRole> remove(@PathVariable Long id) {
|
||||||
|
@ -54,7 +56,7 @@ public class SysRoleController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "根据id列表删除")
|
@Operation(summary = "根据id列表删除", description = "根据id列表删除")
|
||||||
@DeleteMapping("batchRemove")
|
@DeleteMapping("batchRemove")
|
||||||
public Result<SysRole> batchRemove(@RequestBody List<Long> idList) {
|
public Result<SysRole> batchRemove(@RequestBody List<Long> idList) {
|
||||||
sysRoleService.removeByIds(idList);
|
sysRoleService.removeByIds(idList);
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.atguigu.auth.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.auth.service.SysUserService;
|
||||||
|
import com.atguigu.common.result.Result;
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
|
import com.atguigu.vo.system.SysUserQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
@Tag(name = "用户管理接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/system/sysUser")
|
||||||
|
public class SysUserController {
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Operation(summary = "用户条件分页查询", description = "用户条件分页查询")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<SysUser>> getUserByPage(@PathVariable Long page,
|
||||||
|
@PathVariable Long limit,
|
||||||
|
SysUserQueryVo sysUserQueryVo) {
|
||||||
|
IPage<SysUser> pageModel = sysUserService.getUserByPage(page, limit, sysUserQueryVo);
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取用户", description = "获取用户")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<SysUser> getById(@PathVariable Long id) {
|
||||||
|
SysUser sysUser = sysUserService.getById(id);
|
||||||
|
return Result.success(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "保存用户", description = "保存用户")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<SysUser> save(@RequestBody SysUser user) {
|
||||||
|
sysUserService.save(user);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新用户", description = "更新用户")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<SysUser> update(@RequestBody SysUser user) {
|
||||||
|
sysUserService.updateById(user);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除用户", description = "删除用户")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<SysUser> remove(@PathVariable Long id) {
|
||||||
|
sysUserService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "批量删除用户", description = "批量删除用户")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<SysUser> batchRemove(@RequestBody List<Long> idList) {
|
||||||
|
sysUserService.removeByIds(idList);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.auth.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.atguigu.auth.service;
|
||||||
|
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
|
import com.atguigu.vo.system.SysUserQueryVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
public interface SysUserService extends IService<SysUser> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 查询条件
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
IPage<SysUser> getUserByPage(Long page, Long limit, SysUserQueryVo vo);
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.atguigu.auth.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.auth.mapper.SysUserMapper;
|
||||||
|
import com.atguigu.auth.service.SysUserService;
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
|
import com.atguigu.vo.system.SysUserQueryVo;
|
||||||
|
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 org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户条件分页查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页记录数
|
||||||
|
* @param vo 查询条件
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<SysUser> getUserByPage(Long page, Long limit, SysUserQueryVo vo) {
|
||||||
|
// 创建条件值
|
||||||
|
String username = vo.getKeyword();
|
||||||
|
String createTimeBegin = vo.getCreateTimeBegin();
|
||||||
|
String createTimeEnd = vo.getCreateTimeEnd();
|
||||||
|
|
||||||
|
// 创建分页对象
|
||||||
|
Page<SysUser> pageParam = new Page<>(page, limit);
|
||||||
|
|
||||||
|
// 分装查询对象
|
||||||
|
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.like(!StringUtils.isEmpty(username), SysUser::getUsername, username);
|
||||||
|
// 大于
|
||||||
|
wrapper.ge(!StringUtils.isEmpty(createTimeBegin), SysUser::getCreateTime, createTimeBegin);
|
||||||
|
// 小于
|
||||||
|
wrapper.le(!StringUtils.isEmpty(createTimeEnd), SysUser::getCreateTime, createTimeEnd);
|
||||||
|
|
||||||
|
return page(pageParam, wrapper);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 角色 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/order/sys-role")
|
||||||
|
public class SysRoleController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author bunny
|
||||||
|
* @since 2024-04-22
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/order/sys-user")
|
||||||
|
public class SysUserController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue