2025-07-17 15:26:39 +08:00
|
|
|
package com.gunshi.project.hsz.controller;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
2024-08-19 11:25:25 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.core.result.R;
|
2025-07-17 15:26:39 +08:00
|
|
|
import com.gunshi.project.hsz.model.CctvBMenu;
|
|
|
|
|
import com.gunshi.project.hsz.service.CctvBMenuService;
|
2025-11-04 16:14:38 +08:00
|
|
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
|
|
|
|
import com.gunshi.project.hsz.common.validate.markers.Update;
|
2024-07-08 17:47:02 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2024-08-20 13:59:43 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2024-07-08 17:47:02 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.List;
|
2024-08-20 13:59:43 +08:00
|
|
|
import java.util.Objects;
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 视频点目录
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-07-08 17:40:37
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "视频点目录")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value="/cctvBMenu")
|
|
|
|
|
public class CctvBMenuController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CctvBMenuService service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public R<CctvBMenu> insert(@Validated(Insert.class) @RequestBody CctvBMenu dto) {
|
2024-08-20 13:59:43 +08:00
|
|
|
if (Objects.isNull(dto.getParentId())){
|
|
|
|
|
dto.setParentId(0L);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getName()) && service.lambdaQuery().eq(CctvBMenu::getName,dto.getName())
|
|
|
|
|
.count() > 0){
|
|
|
|
|
throw new IllegalArgumentException("当前名称已存在");
|
|
|
|
|
}
|
2024-08-19 11:25:25 +08:00
|
|
|
dto.setId(IdWorker.getId());
|
2024-08-20 15:42:55 +08:00
|
|
|
if (Objects.isNull(dto.getOrderIndex())){
|
|
|
|
|
CctvBMenu one = service.lambdaQuery()
|
|
|
|
|
.select(CctvBMenu::getOrderIndex)
|
|
|
|
|
.orderByDesc(CctvBMenu::getOrderIndex)
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.nonNull(one)){
|
|
|
|
|
dto.setOrderIndex(one.getOrderIndex() + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.save(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改")
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
public R<CctvBMenu> update(@Validated(Update.class) @RequestBody CctvBMenu dto) {
|
2024-08-20 13:59:43 +08:00
|
|
|
if (StringUtils.isNotBlank(dto.getName()) && service.lambdaQuery().eq(CctvBMenu::getName,dto.getName())
|
|
|
|
|
.ne(CctvBMenu::getId,dto.getId())
|
|
|
|
|
.count() > 0){
|
|
|
|
|
throw new IllegalArgumentException("当前名称已存在");
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.updateById(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@GetMapping("/del/{id}")
|
|
|
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
|
|
|
return R.ok(service.removeById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "列表")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public R<List<CctvBMenu>> list() {
|
|
|
|
|
return R.ok(service.lambdaQuery().list());
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 17:38:06 +08:00
|
|
|
@Operation(summary = "树")
|
|
|
|
|
@GetMapping("/tree")
|
|
|
|
|
public R<List<CctvBMenu>> tree() {
|
|
|
|
|
return R.ok(service.tree());
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-22 17:11:26 +08:00
|
|
|
// @Operation(summary = "分页")
|
|
|
|
|
// @PostMapping("/page")
|
2024-07-08 17:47:02 +08:00
|
|
|
public R<List<CctvBMenu>> page() {
|
|
|
|
|
return R.ok(service.page(null,null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|