我要写一个查看被教师和校长驳回的信息,写一个coonterller专门去查看,代码应该怎么写,给我完整代码@Autowired private RuntimeService runtimeService; @Autowired private TaskService taskService; @Autowired private HistoryService historyService; @Autowired private RepositoryService repositoryService; @PostMapping("leave") public R startLeave(String name,Integer days){ //学生发起请假 Map<String, Object> map=new HashMap<>(); map.put("studentUser",name); map.put("day",days); //通过流程ID启动一个流程实例 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("StudentLeave", map); //根据流程processInstance实例id创建学生的任务,singleResult单个任务 Task studentTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); //让学生完成任务 taskService.complete(studentTask.getId()); return R.ok("发起请假成功"); }}
时间: 2024-04-16 10:28:26 浏览: 130
js代码-测试从审批流日志中获取下一个审批者账号
您想要编写一个Controller用于查看被教师和校长驳回的信息。以下是一个示例代码,供您参考:
```java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/rejected")
public class RejectedInfoController {
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@GetMapping
public R getRejectedInfo() {
// 查询被教师和校长驳回的任务历史记录
List<HistoricTaskInstance> rejectedTasks = historyService
.createHistoricTaskInstanceQuery()
.taskDeleteReason("rejected")
.list();
// 处理查询结果
List<Map<String, Object>> rejectedInfoList = new ArrayList<>();
for (HistoricTaskInstance task : rejectedTasks) {
Map<String, Object> rejectedInfo = new HashMap<>();
rejectedInfo.put("taskId", task.getId());
rejectedInfo.put("taskName", task.getName());
rejectedInfo.put("assignee", task.getAssignee());
rejectedInfo.put("processInstanceId", task.getProcessInstanceId());
// 可以根据需要添加更多相关信息
rejectedInfoList.add(rejectedInfo);
}
return R.ok().put("rejectedInfo", rejectedInfoList);
}
}
```
请注意,这只是一个示例代码,您可能需要根据您的具体需求进行适当的修改和调整。还请确保已正确注入相关的服务(如TaskService、HistoryService等)。
阅读全文