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.SearchDto; import com.deloitte.system.service.LoanerUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/loaneruser") public class LoanerUserController { @Autowired LoanerUserService loanerUserService; @Autowired private IdUtils idWorker; @RequestMapping(value = "/query", method = RequestMethod.GET) public Result query(@RequestParam("dataId") String dataId) { LoanerUserDto dto = loanerUserService.queryForOne(dataId); Result res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setObject(dto); return res; } @RequestMapping(value = "/insert", method = RequestMethod.POST) public Result> insert(@RequestBody List loanerUserDtoList) { String txId = idWorker.nextId(); List respList = loanerUserService.insertList(loanerUserDtoList, txId); Result> res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setTxId(txId); res.setObject(respList); return res; } @RequestMapping(value = "/update", method = RequestMethod.POST) public Result> update(@RequestBody List loanerUserDtoList) { String txId = idWorker.nextId(); List respList = loanerUserService.updateList(loanerUserDtoList, txId); Result> res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setTxId(txId); res.setObject(respList); return res; } @RequestMapping(value = "/delete", method = RequestMethod.POST) public Result delete(@RequestParam("dataId") String dataId) { Boolean flag = loanerUserService.deleteOne(dataId); Result res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setObject(flag); return res; } @RequestMapping(value = "/undelete", method = RequestMethod.POST) public Result undelete(@RequestParam("dataId") String dataId) { Boolean flag = loanerUserService.undeleteOne(dataId); Result res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setObject(flag); return res; } @RequestMapping(value = "/search", method = RequestMethod.POST) public Result> search(@RequestBody SearchDto searchDto){ List dtoList = loanerUserService.search(searchDto.getDataIds()); Result> res = Result.resp(ResultCodeEnum.RT_SUCCESS); res.setObject(dtoList); return res; } }