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;
|
}
|
|
}
|