|
@@ -5,6 +5,7 @@ import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -36,12 +37,14 @@ public class ChartController {
|
|
|
private final static Logger log = LoggerFactory.getLogger(ChartController.class);
|
|
|
@Resource
|
|
|
private ChartService chartService;
|
|
|
+ @PreAuthorize("@ps.hasRole('用户')")
|
|
|
@GetMapping("/getChartById/{id}")
|
|
|
@ResponseBody
|
|
|
public ResponseResult getChartById(@PathVariable("id") Long id){
|
|
|
Chart chart = chartService.getById(id);
|
|
|
return ResponseResult.okResult(chart);
|
|
|
}
|
|
|
+ @PreAuthorize("@ps.hasRole('管理员')")
|
|
|
@PostMapping("/add")
|
|
|
@ResponseBody
|
|
|
public ResponseResult addChart(@RequestBody Chart chart){
|
|
@@ -52,33 +55,29 @@ public class ChartController {
|
|
|
chartService.save(chart);
|
|
|
return ResponseResult.okResult();
|
|
|
}
|
|
|
+ @PreAuthorize("@ps.hasRole('用户')")
|
|
|
@DeleteMapping("/{ids}")
|
|
|
@ResponseBody
|
|
|
public ResponseResult deleteChartById(@PathVariable List<Long> ids){
|
|
|
chartService.removeByIds(ids);
|
|
|
return ResponseResult.okResult();
|
|
|
}
|
|
|
+ @PreAuthorize("@ps.hasRole('管理员')")
|
|
|
@PutMapping("/update")
|
|
|
@ResponseBody
|
|
|
public ResponseResult updateChart(@RequestBody Chart chart){
|
|
|
chartService.updateById(chart);
|
|
|
return ResponseResult.okResult();
|
|
|
}
|
|
|
+ @PreAuthorize("@ps.hasRole('用户')")
|
|
|
@GetMapping("/list")
|
|
|
@ResponseBody
|
|
|
- public ResponseResult page(Integer pageNum,Integer pageSize){
|
|
|
- Page<Chart> page = chartService.page(new Page<Chart>(pageNum, pageSize));
|
|
|
- List<ChartVO> voList = new ArrayList<>();
|
|
|
- for (Chart chart : page.getRecords()) {
|
|
|
- ChartVO chartVO = BeanCopyUtil.copyBean(chart, ChartVO.class);
|
|
|
- chartVO.setId(chart.getId().toString());
|
|
|
- chartVO.setUserId(chart.getUserId().toString());
|
|
|
- voList.add(chartVO);
|
|
|
- }
|
|
|
- PageVO pageVO = new PageVO(voList, page.getTotal());
|
|
|
+ public ResponseResult page(Integer pageNum,Integer pageSize,String name,Long UserId){
|
|
|
+ PageVO pageVO = chartService.getChartPage(pageNum,pageSize,name,UserId);
|
|
|
return ResponseResult.okResult(pageVO);
|
|
|
}
|
|
|
|
|
|
+ @PreAuthorize("@ps.hasRole('用户')")
|
|
|
@PostMapping("/generateChartByAI")
|
|
|
@ResponseBody
|
|
|
public ResponseResult generateChartByAI(ChartDTO chartDTO, MultipartFile file) throws IOException {
|