Initial commit
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
package com.atguigu.process.controller;
|
||||
|
||||
|
||||
import com.atguigu.common.result.Result;
|
||||
import com.atguigu.model.process.ProcessTemplate;
|
||||
import com.atguigu.process.service.OaProcessTemplateService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 审批模板 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2023-06-15
|
||||
*/
|
||||
@Api(value = "审批模板管理", tags = "审批模板管理")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/process/processTemplate")
|
||||
public class OaProcessTemplateController {
|
||||
|
||||
@Autowired
|
||||
private OaProcessTemplateService processTemplateService;
|
||||
|
||||
/**
|
||||
* 测试文件上传
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String path = new File(ResourceUtils.getURL("classpath:").getPath()).getAbsolutePath();
|
||||
System.out.println("path = " + path); //E:\CodeLife\IdeaProject\guigu-oa\guigu-oa-parent\service-oa\target\classes
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件流程
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processTemplate.templateSet')")
|
||||
@ApiOperation(value = "上传流程定义")
|
||||
@PostMapping("/uploadProcessDefinition")
|
||||
public Result uploadProcessDefinition(MultipartFile file) throws FileNotFoundException {
|
||||
|
||||
// 获取classes目录位置
|
||||
String path = new File(ResourceUtils.getURL("classpath:").getPath()).getAbsolutePath();
|
||||
// 设置上传文件夹
|
||||
File tempFile = new File(path + "/processes/");
|
||||
if (!tempFile.exists()) {
|
||||
tempFile.mkdirs();
|
||||
}
|
||||
// 创建空文件,实现文件写入
|
||||
String filename = file.getOriginalFilename();
|
||||
File zipFile = new File(path + "/processes/" + filename);
|
||||
|
||||
// 保存文件
|
||||
try {
|
||||
file.transferTo(zipFile);
|
||||
} catch (IOException e) {
|
||||
return Result.fail();
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//根据上传地址后续部署流程定义,文件名称为流程定义的默认key
|
||||
map.put("processDefinitionPath", "processes/" + filename);
|
||||
map.put("processDefinitionKey", filename.substring(0, filename.lastIndexOf(".")));
|
||||
return Result.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询审批模板
|
||||
*
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取分页查询审批模板数据")
|
||||
@GetMapping("{page}/{pageSize}")
|
||||
public Result index(@PathVariable Long page, @PathVariable Long pageSize) {
|
||||
Page<ProcessTemplate> pageInfo = new Page<>(page, pageSize);
|
||||
//分页查询审批模板,把审批类型对应名称查询
|
||||
IPage<ProcessTemplate> pageModel =
|
||||
processTemplateService.selectPageProcessTemplate(pageInfo);
|
||||
return Result.ok(pageModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取审批模板
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processTemplate.list')")
|
||||
@ApiOperation(value = "获取")
|
||||
@GetMapping("get/{id}")
|
||||
public Result get(@PathVariable Long id) {
|
||||
ProcessTemplate processTemplate = processTemplateService.getById(id);
|
||||
return Result.ok(processTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增审批模板
|
||||
*
|
||||
* @param processTemplate
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processTemplate.templateSet')")
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("save")
|
||||
public Result save(@RequestBody ProcessTemplate processTemplate) {
|
||||
processTemplateService.save(processTemplate);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审批模板
|
||||
*
|
||||
* @param processTemplate
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processTemplate.templateSet')")
|
||||
@ApiOperation(value = "修改")
|
||||
@PutMapping("update")
|
||||
public Result updateById(@RequestBody ProcessTemplate processTemplate) {
|
||||
processTemplateService.updateById(processTemplate);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除审批模板
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processTemplate.remove')")
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result remove(@PathVariable Long id) {
|
||||
processTemplateService.removeById(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.atguigu.process.controller;
|
||||
|
||||
|
||||
import com.atguigu.common.result.Result;
|
||||
import com.atguigu.model.process.ProcessType;
|
||||
import com.atguigu.process.service.OaProcessTypeService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 审批类型 前端控制器
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2023-06-15
|
||||
*/
|
||||
@Api(value = "审批类型", tags = "审批类型")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/process/processType")
|
||||
//@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class OaProcessTypeController {
|
||||
|
||||
@Autowired
|
||||
private OaProcessTypeService processTypeService;
|
||||
|
||||
/**
|
||||
* 查询所有的审批类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取全部审批分类")
|
||||
@GetMapping("findAll")
|
||||
public Result findAll() {
|
||||
return Result.ok(processTypeService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询 审批类型
|
||||
*
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取分页列表")
|
||||
@GetMapping("{page}/{pageSize}")
|
||||
public Result index(@PathVariable Long page, @PathVariable Long pageSize) {
|
||||
|
||||
Page<ProcessType> pageInfo = new Page<>(page, pageSize);
|
||||
Page<ProcessType> pageModel = processTypeService.page(pageInfo);
|
||||
|
||||
return Result.ok(pageModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审批类型
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processType.list')")
|
||||
@ApiOperation(value = "获取")
|
||||
@GetMapping("get/{id}")
|
||||
public Result get(@PathVariable Long id) {
|
||||
ProcessType processType = processTypeService.getById(id);
|
||||
return Result.ok(processType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增审批类型
|
||||
*
|
||||
* @param processType
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processType.add')")
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("save")
|
||||
public Result save(@RequestBody ProcessType processType) {
|
||||
processTypeService.save(processType);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审批类型
|
||||
*
|
||||
* @param processType
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAuthority('bnt.processType.update')")
|
||||
@ApiOperation(value = "修改")
|
||||
@PutMapping("update")
|
||||
public Result updateById(@RequestBody ProcessType processType) {
|
||||
processTypeService.updateById(processType);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除审批类型
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result remove(@PathVariable Long id) {
|
||||
processTypeService.removeById(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user