| | |
| | | |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.domain.group.Add; |
| | | import com.ycl.system.domain.group.Update; |
| | | import constant.TableNameConstants; |
| | | 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 io.swagger.annotations.ApiOperation; |
| | | import com.ycl.platform.service.DynamicColumnService; |
| | | import com.ycl.platform.domain.form.DynamicColumnForm; |
| | | import com.ycl.platform.domain.query.DynamicColumnQuery; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import static constant.TableNameConstants.COLUMN_NAME_VIDEO; |
| | | |
| | | /** |
| | | * 动态列 前端控制器 |
| | |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn:edit')") |
| | | public Result update(@RequestBody @Validated(Update.class) DynamicColumnForm form) { |
| | | return dynamicColumnService.update(form); |
| | | public Result update(@RequestBody @NotEmpty(message = "数据为空,无法保存") List<DynamicColumnForm> columnList) { |
| | | return dynamicColumnService.update(columnList); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn:del')") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return dynamicColumnService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn:del:batch')") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return dynamicColumnService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn:page')") |
| | | public Result page(DynamicColumnQuery query) { |
| | | return dynamicColumnService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn:detail')") |
| | | public Result detail(@PathVariable("id") Integer id) { |
| | | return dynamicColumnService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @PreAuthorize("@ss.hasPermi('dynamicColumn: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); |
| | | } |
| | | |
| | | |
| | | |
| | | @PutMapping("/updateByTableName") |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result updateByTableName(@RequestParam @NotNull(message = "路径名不能为空")String pathName, @RequestBody @NotEmpty(message = "数据为空,无法保存") List<DynamicColumnForm> columnList){ |
| | | String tableName = getTableNameByPathNane(pathName); |
| | | if ("".equals(tableName)){ |
| | | return null; |
| | | } |
| | | return dynamicColumnService.updateByTableName(tableName,columnList); |
| | | } |
| | | |
| | | private String getTableNameByPathNane(String pathName) { |
| | | String tableName = ""; |
| | | if ("录像可用率".equals(pathName)){ |
| | | tableName = TableNameConstants.COLUMN_NAME_VIDEO; |
| | | }else if("车辆点位在线率".equals(pathName)){ |
| | | tableName = TableNameConstants.COLUMN_NAME_CAR_POINT; |
| | | }else if("人脸点位在线率".equals(pathName)){ |
| | | tableName = TableNameConstants.COLUMN_NAME_FACE_POINT; |
| | | }else if("视频点位在线率".equals(pathName)){ |
| | | tableName = TableNameConstants.COLUMN_NAME_VIDEO_POINT; |
| | | } |
| | | return tableName; |
| | | } |
| | | } |