测试用户
2023-04-13 43393f2bb11cbf9e6af40077bbc5284660e8a754
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
69
70
71
72
73
74
75
76
package com.deloitte.system.controller;
 
import com.common.core.beans.Result;
import com.common.core.enums.ResultCodeEnum;
import com.common.core.utils.IdUtils;
import com.deloitte.system.request.LoanerUserDto;
import com.deloitte.system.request.QuotesDto;
import com.deloitte.system.request.SearchDto;
import com.deloitte.system.service.QuotesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RestController
@RequestMapping("/quotes")
public class QuotesController {
 
    @Autowired
    QuotesService quotesService;
 
    @Autowired
    private IdUtils idWorker;
 
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public Result<QuotesDto> query(@RequestParam("dataId") String dataId) {
        QuotesDto dto = quotesService.queryForOne(dataId);
        Result<QuotesDto> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setObject(dto);
        return res;
    }
 
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Result<List<QuotesDto>> insert(@RequestBody List<QuotesDto> quotesDtoList) {
        String txId = idWorker.nextId();
        List<QuotesDto> respList = quotesService.insertList(quotesDtoList, txId);
        Result<List<QuotesDto>> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setTxId(txId);
        res.setObject(respList);
        return res;
    }
 
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result<List<QuotesDto>> update(@RequestBody List<QuotesDto> quotesDtoList) {
        String txId = idWorker.nextId();
        List<QuotesDto> respList = quotesService.updateList(quotesDtoList, txId);
        Result<List<QuotesDto>> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setTxId(txId);
        res.setObject(respList);
        return res;
    }
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Result<Boolean> delete(@RequestParam("dataId") String dataId) {
        Boolean flag = quotesService.deleteOne(dataId);
        Result<Boolean> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setObject(flag);
        return res;
    }
 
    @RequestMapping(value = "/undelete", method = RequestMethod.POST)
    public Result<Boolean> undelete(@RequestParam("dataId") String dataId) {
        Boolean flag = quotesService.undeleteOne(dataId);
        Result<Boolean> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setObject(flag);
        return res;
    }
 
    @RequestMapping(value = "/search", method = RequestMethod.POST)
    public Result<List<QuotesDto>> search(@RequestBody SearchDto searchDto){
        List<QuotesDto> dtoList = quotesService.search(searchDto.getDataIds());
        Result<List<QuotesDto>> res = Result.resp(ResultCodeEnum.RT_SUCCESS);
        res.setObject(dtoList);
        return res;
    }
 
}