TaskTempController.java
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.third.WechatMod;
import vion.dto.TaskTempDTO;
import vion.model.TaskTemp;
import vion.service.ITaskTempService;
import vion.vo.TaskTempVO;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 预工单
*/
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class TaskTempController {
private final ITaskTempService taskTempService;
private final WechatMod wechatMod;
private final Converter converter;
@GetMapping("/taskTemps")
@SaCheckPermission(value = "taskTemp:list", orRole="admin")
public Page<TaskTempVO> getTaskTempList(TaskTempDTO data) {
return taskTempService.getTaskTempList(data);
}
@GetMapping("/taskTemp")
@SaCheckPermission(value = "taskTemp:query", orRole="admin")
public TaskTempVO getTaskTempById(Long id) {
return taskTempService.getTaskTempById(id);
}
@PostMapping("/taskTemp")
@SaCheckPermission(value = "taskTemp:editAndSave", orRole="admin")
public Object saveOrUpdateTaskTemp(TaskTempDTO data) {
return taskTempService.saveOrUpdTaskTemp(data);
}
@GetMapping("/taskTemp/wechatCallback")
public Object wechatCallback(String code, HttpServletResponse res) throws IOException {
Object obj = wechatMod.wechatCallback(code);
if (obj instanceof String) {
res.sendRedirect("https://yunwei.vionyun.com/wap/?openid=" + obj);
} else {
return obj;
}
return "success";
}
@PostMapping("/taskTemp/{id}")
@SaCheckPermission(value = "taskTemp:edit", orRole="admin")
public String upd(@PathVariable(name = "id") Long id, TaskTempDTO data) {
TaskTemp taskTemp = converter.convert(data, new TaskTemp());
taskTemp.setId(id);
return taskTempService.updateById(taskTemp) ? "更新成功" : "更新失败";
}
}