package com.ycl.platform.controller;
|
|
import com.ycl.system.Result;
|
import com.ycl.system.domain.group.Add;
|
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotNull;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import lombok.RequiredArgsConstructor;
|
import java.util.List;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import com.ycl.platform.service.DynamicColumnService;
|
import com.ycl.platform.domain.form.DynamicColumnForm;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* 动态列 前端控制器
|
*
|
* @author xp
|
* @since 2024-08-16
|
*/
|
@Validated
|
@RequiredArgsConstructor
|
@Api(value = "动态列", tags = "动态列管理")
|
@RestController
|
@RequestMapping("/api/dynamic-column")
|
public class DynamicColumnController {
|
|
private final DynamicColumnService dynamicColumnService;
|
|
@PostMapping
|
@ApiOperation(value = "添加", notes = "添加")
|
@PreAuthorize("@ss.hasPermi('dynamicColumn:add')")
|
public Result add(@RequestBody @Validated(Add.class) DynamicColumnForm form) {
|
return dynamicColumnService.add(form);
|
}
|
|
@PutMapping
|
@ApiOperation(value = "修改", notes = "修改")
|
public Result update(@RequestBody @NotEmpty(message = "数据为空,无法保存") List<DynamicColumnForm> columnList) {
|
return dynamicColumnService.update(columnList);
|
}
|
|
@DeleteMapping("/{id}")
|
@ApiOperation(value = "ID删除", notes = "ID删除")
|
public Result removeById(@PathVariable("id") String id) {
|
return dynamicColumnService.removeById(id);
|
}
|
|
@GetMapping("/list")
|
@ApiOperation(value = "列表", notes = "列表")
|
public Result list() {
|
return dynamicColumnService.all();
|
}
|
|
@GetMapping("/listByTableName")
|
@ApiOperation(value = "列表", notes = "列表")
|
public Result listByTableName(@RequestParam @NotNull(message = "路径名不能为空")String pathName) {
|
String tableName = getTableNameByPathNane(pathName);
|
return dynamicColumnService.allByTableName(tableName);
|
}
|
|
@PostMapping("/addByTableName")
|
@ApiOperation(value = "添加", notes = "添加")
|
@PreAuthorize("@ss.hasPermi('dynamicColumn:add')")
|
public Result addByTableName(@RequestParam @NotNull(message = "路径名不能为空")String pathName,@RequestBody @Validated(Add.class) DynamicColumnForm form){
|
String tableName = getTableNameByPathNane(pathName);
|
return dynamicColumnService.addByTableName(tableName,form);
|
}
|
|
private final static String COLUMN_NAME_VIDEO = "uy_record_meta_d_sum";
|
private final static String COLUMN_NAME_POINT = "";
|
|
@PutMapping("/updateByTableName")
|
@ApiOperation(value = "修改", notes = "修改")
|
public Result updateByTableName(@RequestParam @NotNull(message = "路径名不能为空")String pathName, @RequestBody @NotEmpty(message = "数据为空,无法保存") List<DynamicColumnForm> columnList){
|
String tableName = getTableNameByPathNane(pathName);
|
return dynamicColumnService.updateByTableName(tableName,columnList);
|
}
|
|
private String getTableNameByPathNane(String pathName) {
|
String tableName = "";
|
if ("录像可用率".equals(pathName)){
|
tableName = COLUMN_NAME_VIDEO;
|
}else if("点位在线率".equals(pathName)){
|
tableName = COLUMN_NAME_POINT;
|
}
|
return tableName;
|
}
|
}
|