codeGenerator修改
Dieser Commit ist enthalten in:
Ursprung
9c649ccdcd
Commit
e0a947f050
@ -1,116 +0,0 @@
|
||||
package com.cnbm.generator.code.controller;
|
||||
|
||||
import com.cnbm.admin.annotation.LogOperation;
|
||||
import com.cnbm.common.constant.Constant;
|
||||
import com.cnbm.common.page.PageData;
|
||||
import com.cnbm.common.utils.ExcelUtils;
|
||||
import com.cnbm.common.utils.Result;
|
||||
import com.cnbm.common.validator.AssertUtils;
|
||||
import com.cnbm.common.validator.ValidatorUtils;
|
||||
import com.cnbm.common.validator.group.AddGroup;
|
||||
import com.cnbm.common.validator.group.DefaultGroup;
|
||||
import com.cnbm.common.validator.group.UpdateGroup;
|
||||
import com.cnbm.generator.code.dto.UserDTO;
|
||||
import com.cnbm.generator.code.excel.UserExcel;
|
||||
import com.cnbm.generator.code.service.IUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 系统用户 前端控制器
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/code/user")
|
||||
@Api(tags="系统用户")
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
|
||||
})
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:page')")
|
||||
public Result<PageData<UserDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<UserDTO> page = userService.page(params);
|
||||
|
||||
return new Result<PageData<UserDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("信息")
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:info')")
|
||||
public Result<UserDTO> get(@PathVariable("id") Long id){
|
||||
UserDTO data = userService.get(id);
|
||||
|
||||
return new Result<UserDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("保存")
|
||||
@LogOperation("保存")
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:save')")
|
||||
public Result<Long> save(@RequestBody UserDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
userService.save(dto);
|
||||
|
||||
return new Result<Long>().ok(dto.getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改")
|
||||
@LogOperation("修改")
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:update')")
|
||||
public Result<Long> update(@RequestBody UserDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
userService.update(dto);
|
||||
|
||||
return new Result<Long>().ok(dto.getId());
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除")
|
||||
@LogOperation("删除")
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:delete')")
|
||||
public Result delete(@RequestBody Long[] ids){
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
userService.delete(ids);
|
||||
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
@ApiOperation("导出")
|
||||
@LogOperation("导出")
|
||||
@PreAuthorize("@ex.hasAuthority('code:user:export')")
|
||||
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<UserDTO> list = userService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.cnbm.generator.code.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "系统用户DTO对象")
|
||||
public class UserDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String headUrl;
|
||||
|
||||
@ApiModelProperty(value = "性别 0:男 1:女 2:保密")
|
||||
private Integer gender;
|
||||
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "超级管理员 0:否 1:是")
|
||||
private Integer superAdmin;
|
||||
|
||||
@ApiModelProperty(value = "状态 0:停用 1:正常")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "创建者")
|
||||
private Long creator;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createDate;
|
||||
|
||||
@ApiModelProperty(value = "更新者")
|
||||
private Long updater;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updateDate;
|
||||
|
||||
@ApiModelProperty(value = "删除标识,是否有效:1可用 0不可用")
|
||||
private Integer valid;
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package com.cnbm.generator.code.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户
|
||||
* </p>
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user")
|
||||
@ApiModel(value = "User对象", description = "系统用户")
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String headUrl;
|
||||
|
||||
@ApiModelProperty("性别 0:男 1:女 2:保密")
|
||||
private Integer gender;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty("超级管理员 0:否 1:是")
|
||||
private Integer superAdmin;
|
||||
|
||||
@ApiModelProperty("状态 0:停用 1:正常")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("创建者")
|
||||
private Long creator;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createDate;
|
||||
|
||||
@ApiModelProperty("更新者")
|
||||
private Long updater;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateDate;
|
||||
|
||||
@ApiModelProperty("删除标识,是否有效:1可用 0不可用")
|
||||
@TableLogic
|
||||
private Integer valid;
|
||||
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.cnbm.generator.code.excel;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@Data
|
||||
public class UserExcel {
|
||||
@Excel(name = "id")
|
||||
private Long id;
|
||||
@Excel(name = "用户名")
|
||||
private String username;
|
||||
@Excel(name = "密码")
|
||||
private String password;
|
||||
@Excel(name = "姓名")
|
||||
private String realName;
|
||||
@Excel(name = "头像")
|
||||
private String headUrl;
|
||||
@Excel(name = "性别 0:男 1:女 2:保密")
|
||||
private Integer gender;
|
||||
@Excel(name = "邮箱")
|
||||
private String email;
|
||||
@Excel(name = "手机号")
|
||||
private String mobile;
|
||||
@Excel(name = "部门ID")
|
||||
private Long deptId;
|
||||
@Excel(name = "超级管理员 0:否 1:是")
|
||||
private Integer superAdmin;
|
||||
@Excel(name = "状态 0:停用 1:正常")
|
||||
private Integer status;
|
||||
@Excel(name = "创建者")
|
||||
private Long creator;
|
||||
@Excel(name = "创建时间")
|
||||
private LocalDateTime createDate;
|
||||
@Excel(name = "更新者")
|
||||
private Long updater;
|
||||
@Excel(name = "更新时间")
|
||||
private LocalDateTime updateDate;
|
||||
@Excel(name = "删除标识,是否有效:1可用 0不可用")
|
||||
private Integer valid;
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.cnbm.generator.code.mapper;
|
||||
|
||||
import com.cnbm.common.dao.BaseDao;
|
||||
import com.cnbm.generator.code.entity.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseDao<User> {
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cnbm.generator.code.mapper.UserMapper">
|
||||
<resultMap type="com.cnbm.generator.code.entity.User" id="UserMap">
|
||||
<id column="id" property="id" />
|
||||
<id column="username" property="username" />
|
||||
<id column="password" property="password" />
|
||||
<id column="real_name" property="realName" />
|
||||
<id column="head_url" property="headUrl" />
|
||||
<id column="gender" property="gender" />
|
||||
<id column="email" property="email" />
|
||||
<id column="mobile" property="mobile" />
|
||||
<id column="dept_id" property="deptId" />
|
||||
<id column="super_admin" property="superAdmin" />
|
||||
<id column="status" property="status" />
|
||||
<id column="creator" property="creator" />
|
||||
<id column="create_date" property="createDate" />
|
||||
<id column="updater" property="updater" />
|
||||
<id column="update_date" property="updateDate" />
|
||||
<id column="valid" property="valid" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@ -1,7 +0,0 @@
|
||||
-- 菜单初始SQL
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1561967314641956865, 1067246875800000035, '系统用户', 'code/user', NULL, 0, 'icon-desktop', 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623361, 1561967314641956865, '查看', NULL, 'code:user:page,code:user:info', 1, NULL, 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623362, 1561967314641956865, '新增', NULL, 'code:user:save', 1, NULL, 1, 1067246875800000001, now(), 1067246875800000001, now());
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623363, 1561967314641956865, '修改', NULL, 'code:user:update', 1, NULL, 2, 1067246875800000001, now(), 1067246875800000001, now());
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623364, 1561967314641956865, '删除', NULL, 'code:user:delete', 1, NULL, 3, 1067246875800000001, now(), 1067246875800000001, now());
|
||||
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1561967315476623365, 1561967314641956865, '导出', NULL, 'code:user:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now());
|
@ -1,15 +0,0 @@
|
||||
package com.cnbm.generator.code.service;
|
||||
|
||||
import com.cnbm.common.service.CrudService;
|
||||
import com.cnbm.generator.code.dto.UserDTO;
|
||||
import com.cnbm.generator.code.entity.User;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
public interface IUserService extends CrudService<User, UserDTO> {
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.cnbm.generator.code.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cnbm.common.service.impl.CrudServiceImpl;
|
||||
import com.cnbm.generator.code.dto.UserDTO;
|
||||
import com.cnbm.generator.code.mapper.UserMapper;
|
||||
import com.cnbm.generator.code.entity.User;
|
||||
import com.cnbm.generator.code.service.IUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author why
|
||||
* @since 2022-08-23
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl extends CrudServiceImpl<UserMapper, User, UserDTO> implements IUserService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<User> getWrapper(Map<String, Object> params){
|
||||
String id = (String)params.get("id");
|
||||
|
||||
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren