包括部门,文件,员工管理 #4

Merged
pxf8gw7s3 merged 3 commits from hrm/jwh into develop 3 months ago

@ -2,7 +2,7 @@ package com.qiujie.controller;
import com.qiujie.entity.Dept;
import com.qiujie.dto.ResponseDTO;
import com.qiujie.service.DeptService;
import com.qiujie.service.DeptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -24,68 +24,122 @@ import java.util.List;
* @since 2022-03-07
*/
@RestController
// 标识当前类为REST风格控制器返回数据为JSON格式
@RequestMapping("/dept")
// 定义基础请求路径,所有接口路径前缀为/dept
public class DeptController {
// 定义基础请求路径,所有接口路径前缀为/dept
@Autowired
private DeptService deptService;
/**
*
* @param dept
* @return
*/
@ApiOperation("新增")// Swagger文档注解说明接口功能
@PostMapping// 接收POST请求完整路径为/dept
@ApiOperation("新增")
@PostMapping
@PreAuthorize("hasAnyAuthority('system:department:add')")
public ResponseDTO add(@RequestBody Dept dept) {
return this.deptService.add(dept);
}
/**
*
* @param id IDURL
* @return
*/
@ApiOperation("逻辑删除")
@DeleteMapping("/{id}")
@PreAuthorize("hasAnyAuthority('system:department:delete')")
@DeleteMapping("/{id}")// 接收DELETE请求完整路径为/dept/{id}
@PreAuthorize("hasAnyAuthority('system:department:delete')")// 权限控制
public ResponseDTO delete(@PathVariable Integer id) {
return this.deptService.delete(id);
}
/**
*
* @param ids IDURLID
* @return
*/
@ApiOperation("批量逻辑删除")
@DeleteMapping("/batch/{ids}")
@PreAuthorize("hasAnyAuthority('system:department:delete')")
@DeleteMapping("/batch/{ids}")// 接收DELETE请求完整路径为/dept/batch/{ids}
@PreAuthorize("hasAnyAuthority('system:department:delete')")// 权限控制
public ResponseDTO deleteBatch(@PathVariable List<Integer> ids) {
return this.deptService.deleteBatch(ids);
}
/**
*
* @param dept
* @return
*/
@ApiOperation("编辑更新")
@PutMapping
@PreAuthorize("hasAnyAuthority('system:department:edit')")
@PutMapping// 接收PUT请求完整路径为/dept
@PreAuthorize("hasAnyAuthority('system:department:edit')")// 权限控制
public ResponseDTO edit(@RequestBody Dept dept) {
return this.deptService.edit(dept);
}
/**
* ID
* @param id IDURL
* @return
*/
@ApiOperation("查询")//根据ID查询部门
@GetMapping("/{id}")// 接收GET请求完整路径为/dept/{id}
@ApiOperation("查询")
@GetMapping("/{id}")
public ResponseDTO query(@PathVariable Integer id) {
return this.deptService.query(id);
}
/**
*
* @return
*/
@ApiOperation("查询所有")
@GetMapping("/all")
@ApiOperation("查询所有")//查询所有部门
@GetMapping("/all")// 接收GET请求完整路径为/dept/all
public ResponseDTO queryAll(){
return this.deptService.queryAll();
}
/**
*
* @param current 1
* @param size 10
* @param name
* @return
*/
@ApiOperation("条件查询")
@GetMapping
@ApiOperation("条件查询")//条件分页查询部门
@GetMapping// 接收GET请求完整路径为/dept
@PreAuthorize("hasAnyAuthority('system:department:list','system:department:search')")
// 权限控制:拥有两个权限中的任意一个即可访问
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String name) {
return this.deptService.list(current, size, name);
}
/**
*
* @param response HTTP
* @param filename
* @throws Exception IO
*/
@ApiOperation("数据导出接口")
@GetMapping("/export/{filename}")
@PreAuthorize("hasAnyAuthority('system:department:export')")
@ApiOperation("数据导出接口")//部门数据导出接口
@GetMapping("/export/{filename}")// 接收GET请求完整路径为/dept/export/{filename}
@PreAuthorize("hasAnyAuthority('system:department:export')")// 权限控制
public void export(HttpServletResponse response,@PathVariable String filename) throws Exception {
this.deptService.export(response,filename);
}
/**
*
* @param file
* @return /
* @throws IOException
*/
@ApiOperation("数据导入接口")
@PostMapping("/import")
@PreAuthorize("hasAnyAuthority('system:department:import')")
@PostMapping("/import")// 接收POST请求完整路径为/dept/import
@PreAuthorize("hasAnyAuthority('system:department:import')")// 权限控制
public ResponseDTO imp(MultipartFile file) throws IOException {
return this.deptService.imp(file);
}

@ -16,92 +16,161 @@ import java.io.IOException;
import java.util.List;
/**
*
*
*
*
* @Author qiujie
* @Date 2022/2/24
* @Version 1.0
*/
@RestController
@RequestMapping("/docs")
@RestController // 标识为REST风格控制器返回JSON格式响应
@RequestMapping("/docs") // 基础请求路径,所有接口路径前缀为/docs
public class DocsController {
// 自动注入文件文档服务层对象,用于调用业务逻辑
@Autowired
private DocsService docsService;
@ApiOperation("新增")
@PostMapping
/**
*
* @param docs
* @return
*/
@ApiOperation("新增文件文档记录") // Swagger注解描述接口功能
@PostMapping // 接收POST请求完整路径为/docs
public ResponseDTO add(@RequestBody Docs docs) {
return this.docsService.add(docs);
}
@ApiOperation("逻辑删除")
@DeleteMapping("/{id}")
@PreAuthorize("hasAnyAuthority('system:docs:delete')")
/**
*
* @param id IDURL
* @return
*/
@ApiOperation("逻辑删除文件文档记录")
@DeleteMapping("/{id}") // 接收DELETE请求完整路径为/docs/{id}
@PreAuthorize("hasAnyAuthority('system:docs:delete')") // 权限控制:仅拥有该权限的用户可访问
public ResponseDTO delete(@PathVariable Integer id) {
return this.docsService.delete(id);
}
@ApiOperation("批量逻辑删除")
@DeleteMapping("/batch/{ids}")
@PreAuthorize("hasAnyAuthority('system:docs:delete')")
/**
*
* @param ids IDURLID
* @return
*/
@ApiOperation("批量逻辑删除文件文档记录")
@DeleteMapping("/batch/{ids}") // 接收DELETE请求完整路径为/docs/batch/{ids}
@PreAuthorize("hasAnyAuthority('system:docs:delete')") // 权限控制
public ResponseDTO deleteBatch(@PathVariable List<Integer> ids) {
return this.docsService.deleteBatch(ids);
}
@ApiOperation("编辑更新")
@PutMapping
@PreAuthorize("hasAnyAuthority('system:docs:edit')")
/**
*
* @param docs
* @return
*/
@ApiOperation("编辑更新文件文档记录")
@PutMapping // 接收PUT请求完整路径为/docs
@PreAuthorize("hasAnyAuthority('system:docs:edit')") // 权限控制
public ResponseDTO edit(@RequestBody Docs docs) {
return this.docsService.edit(docs);
}
@ApiOperation("查询")
@GetMapping("/{id}")
/**
* ID
* @param id IDURL
* @return
*/
@ApiOperation("根据ID查询文件文档详情")
@GetMapping("/{id}") // 接收GET请求完整路径为/docs/{id}
public ResponseDTO query(@PathVariable Integer id) {
return this.docsService.query(id);
}
@ApiOperation("分页条件查询")
@GetMapping
@PreAuthorize("hasAnyAuthority('system:docs:list','system:docs:search')")
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String oldName, String staffName) {
/**
*
* @param current 1
* @param size 10
* @param oldName
* @param staffName
* @return
*/
@ApiOperation("分页条件查询文件文档列表")
@GetMapping // 接收GET请求完整路径为/docs
@PreAuthorize("hasAnyAuthority('system:docs:list','system:docs:search')") // 权限控制:拥有两个权限中的任意一个即可访问
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current,
@RequestParam(defaultValue = "10") Integer size,
String oldName,
String staffName) {
return this.docsService.list(current, size, oldName, staffName);
}
@ApiOperation("数据导出接口")
@GetMapping("/export/{filename}")
@PreAuthorize("hasAnyAuthority('system:docs:export')")
public void export(HttpServletResponse response,@PathVariable String filename) throws IOException {
this.docsService.export(response,filename);
/**
*
* @param response HTTP
* @param filename
* @throws IOException IO
*/
@ApiOperation("文件文档数据导出接口")
@GetMapping("/export/{filename}") // 接收GET请求完整路径为/docs/export/{filename}
@PreAuthorize("hasAnyAuthority('system:docs:export')") // 权限控制
public void export(HttpServletResponse response, @PathVariable String filename) throws IOException {
this.docsService.export(response, filename);
}
@ApiOperation("数据导入接口")
@PostMapping("/import")
@PreAuthorize("hasAnyAuthority('system:docs:import')")
/**
*
* @param file
* @return
* @throws IOException
*/
@ApiOperation("文件文档数据导入接口")
@PostMapping("/import") // 接收POST请求完整路径为/docs/import
@PreAuthorize("hasAnyAuthority('system:docs:import')") // 权限控制
public ResponseDTO imp(MultipartFile file) throws IOException {
return this.docsService.imp(file);
}
@ApiOperation("文件上传")
@PostMapping("/upload/{id}")
@PreAuthorize("hasAnyAuthority('system:docs:upload')")
/**
*
* @param file
* @param id IDURL
* @return
* @throws IOException IO
*/
@ApiOperation("文件上传接口")
@PostMapping("/upload/{id}") // 接收POST请求完整路径为/docs/upload/{id}
@PreAuthorize("hasAnyAuthority('system:docs:upload')") // 权限控制
public ResponseDTO upload(MultipartFile file, @PathVariable Integer id) throws IOException {
return this.docsService.upload(file, id);
}
@ApiOperation("文件下载")
@GetMapping("/download/{filename}")
@PreAuthorize("hasAnyAuthority('system:docs:download')")
/**
*
* @param filename URL
* @param response HTTP
* @throws IOException
*/
@ApiOperation("文件下载接口")
@GetMapping("/download/{filename}") // 接收GET请求完整路径为/docs/download/{filename}
@PreAuthorize("hasAnyAuthority('system:docs:download')") // 权限控制
public void download(@PathVariable String filename, HttpServletResponse response) throws IOException {
this.docsService.download(filename, response);
}
@ApiOperation("文件下载")
/**
*
* @param filename URL
* @param response HTTP
* @throws IOException
*/
@ApiOperation("头像文件下载接口")
@GetMapping("/avatar/{filename}")
// 接收GET请求完整路径为/docs/avatar/{filename}
public void getAvatar(@PathVariable String filename, HttpServletResponse response) throws IOException {
this.docsService.download(filename, response);
}
}
}

@ -1,6 +1,5 @@
package com.qiujie.controller;
import com.qiujie.dto.ResponseDTO;
import com.qiujie.entity.Staff;
import com.qiujie.service.StaffRoleService;
@ -17,107 +16,187 @@ import java.util.List;
/**
* <p>
*
*
*
* </p>
*
* @author qiujie
* @since 2022-01-27
*/
@RestController
@RequestMapping("/staff")
@RestController // 标识为REST风格控制器返回JSON格式响应
@RequestMapping("/staff") // 基础请求路径,所有接口路径前缀为/staff
public class StaffController {
// 自动注入员工服务层对象,处理员工核心业务逻辑
@Autowired
private StaffService staffService;
// 自动注入员工-角色关联服务层对象,处理员工角色分配相关业务
@Autowired
private StaffRoleService staffRoleService;
@ApiOperation("新增")
@PostMapping
@PreAuthorize("hasAnyAuthority('system:staff:add')")
/**
*
* @param staff
* @return
*/
@ApiOperation("新增员工") // Swagger注解描述接口功能
@PostMapping // 接收POST请求完整路径为/staff
@PreAuthorize("hasAnyAuthority('system:staff:add')") // 权限控制:仅拥有该权限的用户可访问
public ResponseDTO add(@RequestBody Staff staff) {
return this.staffService.add(staff);
}
@ApiOperation("逻辑删除")
@DeleteMapping("/{id}")
@PreAuthorize("hasAnyAuthority('system:staff:delete')")
/**
*
* @param id IDURL
* @return
*/
@ApiOperation("逻辑删除员工")
@DeleteMapping("/{id}") // 接收DELETE请求完整路径为/staff/{id}
@PreAuthorize("hasAnyAuthority('system:staff:delete')") // 权限控制
public ResponseDTO delete(@PathVariable Integer id) {
return this.staffService.delete(id);
}
@ApiOperation("批量逻辑删除")
@DeleteMapping("/batch/{ids}")
@PreAuthorize("hasAnyAuthority('system:staff:delete')")
/**
*
* @param ids IDURLID
* @return
*/
@ApiOperation("批量逻辑删除员工")
@DeleteMapping("/batch/{ids}") // 接收DELETE请求完整路径为/staff/batch/{ids}
@PreAuthorize("hasAnyAuthority('system:staff:delete')") // 权限控制
public ResponseDTO deleteBatch(@PathVariable List<Integer> ids) {
return this.staffService.deleteBatch(ids);
}
@ApiOperation("编辑更新")
@PutMapping
@PreAuthorize("hasAnyAuthority('system:staff:edit','system:staff:enable')")
/**
* /
* @param staff
* @return
*/
@ApiOperation("编辑更新员工信息")
@PutMapping // 接收PUT请求完整路径为/staff
@PreAuthorize("hasAnyAuthority('system:staff:edit','system:staff:enable')") // 权限控制:拥有两个权限中的任意一个即可访问
public ResponseDTO edit(@RequestBody Staff staff) {
return this.staffService.edit(staff);
}
@ApiOperation("查询")
@GetMapping("/{id}")
/**
* ID
* @param id IDURL
* @return
*/
@ApiOperation("根据ID查询员工基础信息")
@GetMapping("/{id}") // 接收GET请求完整路径为/staff/{id}
public ResponseDTO query(@PathVariable Integer id) {
return this.staffService.query(id);
}
@ApiOperation("查询员工信息")
@GetMapping("/info/{id}")
/**
* ID
* @param id IDURL
* @return
*/
@ApiOperation("根据ID查询员工详细信息")
@GetMapping("/info/{id}") // 接收GET请求完整路径为/staff/info/{id}
public ResponseDTO queryInfo(@PathVariable Integer id) {
return this.staffService.queryInfo(id);
}
@ApiOperation("多条件分页查询")
@GetMapping
@PreAuthorize("hasAnyAuthority('system:staff:list','system:staff:search')")
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String name, String birthday, Integer deptId, Integer status) {
/**
*
* @param current 1
* @param size 10
* @param name
* @param birthday
* @param deptId ID
* @param status /
* @return
*/
@ApiOperation("多条件分页查询员工列表")
@GetMapping // 接收GET请求完整路径为/staff
@PreAuthorize("hasAnyAuthority('system:staff:list','system:staff:search')") // 权限控制
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current,
@RequestParam(defaultValue = "10") Integer size,
String name,
String birthday,
Integer deptId,
Integer status) {
return this.staffService.list(current, size, name, birthday, deptId, status);
}
@ApiOperation("数据导出接口")
@GetMapping("/export/{filename}")
@PreAuthorize("hasAnyAuthority('system:staff:export')")
/**
*
* @param response HTTP
* @param filename URL
* @throws IOException IO
*/
@ApiOperation("员工数据导出接口")
@GetMapping("/export/{filename}") // 接收GET请求完整路径为/staff/export/{filename}
@PreAuthorize("hasAnyAuthority('system:staff:export')") // 权限控制
public void export(HttpServletResponse response, @PathVariable String filename) throws IOException {
this.staffService.export(response, filename);
}
@ApiOperation("数据导入接口")
@PostMapping("/import")
@PreAuthorize("hasAnyAuthority('system:staff:import')")
/**
*
* @param file
* @return
* @throws IOException
*/
@ApiOperation("员工数据导入接口")
@PostMapping("/import") // 接收POST请求完整路径为/staff/import
@PreAuthorize("hasAnyAuthority('system:staff:import')") // 权限控制
public ResponseDTO imp(MultipartFile file) throws IOException {
return this.staffService.imp(file);
}
/**
*
* @param id IDURL
* @param roleIds ID
* @return
*/
@ApiOperation("为员工设置角色")
@PostMapping("/set/{id}")
@PreAuthorize("hasAnyAuthority('system:staff:set_role')")
@PostMapping("/set/{id}") // 接收POST请求完整路径为/staff/set/{id}
@PreAuthorize("hasAnyAuthority('system:staff:set_role')") // 权限控制
public ResponseDTO setRole(@PathVariable Integer id, @RequestBody List<Integer> roleIds) {
return this.staffRoleService.setRole(id, roleIds);
}
@ApiOperation("得到员工的角色")
@GetMapping("/staff/{id}")
/**
*
* @param id IDURL
* @return
*/
@ApiOperation("查询员工已分配的角色")
@GetMapping("/staff/{id}") // 接收GET请求完整路径为/staff/staff/{id}
public ResponseDTO queryByStaffId(@PathVariable Integer id) {
return this.staffRoleService.queryByStaffId(id);
}
@ApiOperation("检查员工的密码")
@GetMapping("/{pwd}/{id}")
/**
*
* @param pwd URL
* @param id IDURL
* @return
*/
@ApiOperation("验证员工密码")
@GetMapping("/{pwd}/{id}") // 接收GET请求完整路径为/staff/{pwd}/{id}
public ResponseDTO validate(@PathVariable String pwd, @PathVariable Integer id) {
return this.staffService.validate(pwd, id);
}
@ApiOperation("更新密码")
@PutMapping("/reset")
/**
*
* @param staff ID
* @return
*/
@ApiOperation("重置员工密码")
@PutMapping("/reset") // 接收PUT请求完整路径为/staff/reset
public ResponseDTO reset(@RequestBody Staff staff) {
return this.staffService.reset(staff);
}
}
}
Loading…
Cancel
Save