87 lines
2.9 KiB
Java
87 lines
2.9 KiB
Java
|
|
package com.youchain.businessdata.rest;
|
||
|
|
|
||
|
|
|
||
|
|
import com.youchain.annotation.AnonymousAccess;
|
||
|
|
import com.youchain.annotation.Log;
|
||
|
|
import com.youchain.businessdata.domain.Les;
|
||
|
|
import com.youchain.businessdata.inputJson.LesRequest;
|
||
|
|
import com.youchain.businessdata.service.LesService;
|
||
|
|
import com.youchain.businessdata.service.dto.LesQueryCriteria;
|
||
|
|
import com.youchain.exception.handler.LesResult;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.data.domain.Pageable;
|
||
|
|
import org.springframework.http.HttpStatus;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||
|
|
import org.springframework.validation.annotation.Validated;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
import java.io.IOException;
|
||
|
|
|
||
|
|
|
||
|
|
@RestController
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
@Api(tags = "les管理")
|
||
|
|
@RequestMapping("/api/les")
|
||
|
|
public class LesController {
|
||
|
|
private final LesService lesService;
|
||
|
|
|
||
|
|
@Log("导出数据")
|
||
|
|
@ApiOperation("导出数据")
|
||
|
|
@GetMapping(value = "/download")
|
||
|
|
@PreAuthorize("@el.check('les:list')")
|
||
|
|
public void exportLes(HttpServletResponse response, LesQueryCriteria criteria) throws IOException {
|
||
|
|
lesService.download(lesService.queryAll(criteria), response);
|
||
|
|
}
|
||
|
|
|
||
|
|
@GetMapping
|
||
|
|
@ApiOperation("查询les")
|
||
|
|
public ResponseEntity<Object> queryLes(LesQueryCriteria criteria, Pageable pageable) {
|
||
|
|
return new ResponseEntity<>(lesService.queryAll(criteria, pageable), HttpStatus.OK);
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping
|
||
|
|
@Log("新增les")
|
||
|
|
@ApiOperation("新增les")
|
||
|
|
@PreAuthorize("@el.check('les:add')")
|
||
|
|
public ResponseEntity<Object> createLes(@Validated @RequestBody Les resources) {
|
||
|
|
return new ResponseEntity<>(lesService.create(resources), HttpStatus.CREATED);
|
||
|
|
}
|
||
|
|
|
||
|
|
@PutMapping
|
||
|
|
@Log("修改les")
|
||
|
|
@ApiOperation("修改les")
|
||
|
|
@PreAuthorize("@el.check('les:edit')")
|
||
|
|
public ResponseEntity<Object> updateLes(@Validated @RequestBody Les resources) {
|
||
|
|
lesService.update(resources);
|
||
|
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||
|
|
}
|
||
|
|
|
||
|
|
@DeleteMapping
|
||
|
|
@Log("删除les")
|
||
|
|
@ApiOperation("删除les")
|
||
|
|
@PreAuthorize("@el.check('les:del')")
|
||
|
|
public ResponseEntity<Object> deleteLes(@RequestBody Long[] ids) {
|
||
|
|
lesService.deleteAll(ids);
|
||
|
|
return new ResponseEntity<>(HttpStatus.OK);
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/genAgvSchedulingTask")
|
||
|
|
@Log("Les任务下发")
|
||
|
|
@ApiOperation("Les任务下发")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResponseEntity<Object> genAgvSchedulingTask(@RequestBody LesRequest lesRequest) {
|
||
|
|
String id = lesRequest.getGuId();//请求id
|
||
|
|
try {
|
||
|
|
return new ResponseEntity<>(LesResult.success(id), HttpStatus.OK);
|
||
|
|
} catch (Exception e) {
|
||
|
|
return new ResponseEntity<>(LesResult.fail(id, e.getMessage()), HttpStatus.BAD_REQUEST);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|