mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_role
|
||||
* 备注:角色表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysRole {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRole;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleService implements LambdaService<SysRole, SysRoleMapper> {
|
||||
|
||||
public PageInfo<SysRole> doPage(LambdaQuery<SysRole> query) {
|
||||
query.orderByDesc(SysRole::getId);
|
||||
PageInfo<SysRole> page = this.page(query);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
|
||||
return isvInfo;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param statusUpdateDTO 修改值
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
public int updateStatus(StatusUpdateDTO statusUpdateDTO) {
|
||||
return this.query()
|
||||
.eq(SysRole::getId, statusUpdateDTO.getId())
|
||||
.set(SysRole::getStatus, statusUpdateDTO.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.req.IdParam;
|
||||
import com.gitee.sop.adminbackend.common.req.StatusUpdateParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysRoleParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRole;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysRoleService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/role")
|
||||
public class SysRoleController {
|
||||
|
||||
@Resource
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<SysRole>> page(SysRoleParam param) {
|
||||
LambdaQuery<SysRole> query = param.toLambdaQuery(SysRole.class);
|
||||
PageInfo<SysRole> pageInfo = sysRoleService.doPage(query);
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param sysRole 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody SysRole sysRole) {
|
||||
sysRoleService.save(sysRole);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(sysRole.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param sysRole 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody SysRole sysRole) {
|
||||
return Result.ok(sysRoleService.update(sysRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result<Integer> delete(@Validated @RequestBody IdParam param) {
|
||||
return Result.ok(sysRoleService.deleteById(param.getId()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/updateStatus")
|
||||
public Result<Integer> updateStatus(@Validated @RequestBody StatusUpdateParam param) {
|
||||
StatusUpdateDTO statusUpdateDTO = CopyUtil.copyBean(param, StatusUpdateDTO::new);
|
||||
return Result.ok(sysRoleService.updateStatus(statusUpdateDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 备注:角色表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysRoleParam extends PageParam {
|
||||
private static final long serialVersionUID = 7794265174728302379L;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色code
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user