视频基本信息新增,修改,删除,分页查询修改,视频点目录新增,修改,树查询修改,系统字典树查询修改
parent
f97daaac72
commit
13f5230732
|
|
@ -10,7 +10,9 @@ import com.gunshi.core.result.R;
|
|||
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||
import com.gunshi.project.xyt.entity.vo.CctvControlVo;
|
||||
import com.gunshi.project.xyt.model.AttCctvBase;
|
||||
import com.gunshi.project.xyt.model.CctvBMenu;
|
||||
import com.gunshi.project.xyt.service.AttCctvBaseService;
|
||||
import com.gunshi.project.xyt.service.CctvBMenuService;
|
||||
import com.gunshi.project.xyt.util.OkHttpUtil;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
|
|
@ -20,6 +22,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -30,6 +34,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 视频基本信息表
|
||||
|
|
@ -44,12 +49,24 @@ public class AttCctvBaseController {
|
|||
@Autowired
|
||||
private AttCctvBaseService service;
|
||||
|
||||
@Autowired
|
||||
private CctvBMenuService menuService;
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<AttCctvBase> insert(@Validated(Insert.class) @RequestBody AttCctvBase dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateTime(new Date());
|
||||
if (StringUtils.isNotBlank(dto.getName()) && service.lambdaQuery().eq(AttCctvBase::getName,dto.getName())
|
||||
.count() > 0){
|
||||
throw new IllegalArgumentException("当前名称已存在");
|
||||
}
|
||||
if (Objects.nonNull(dto.getMenuId()) && menuService.lambdaQuery().eq(CctvBMenu::getId,dto.getMenuId())
|
||||
.count() == 0
|
||||
){
|
||||
throw new IllegalArgumentException("当前视频点目录不存在");
|
||||
}
|
||||
dto.setCreateTime(new Date());
|
||||
boolean result = service.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
|
@ -57,9 +74,22 @@ public class AttCctvBaseController {
|
|||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<AttCctvBase> update(@Validated(Update.class) @RequestBody AttCctvBase dto) {
|
||||
|
||||
if (Objects.isNull(service.getById(dto.getId()))){
|
||||
throw new RuntimeException("当前数据不存在");
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getName()) && service.lambdaQuery().eq(AttCctvBase::getName,dto.getName())
|
||||
.ne(AttCctvBase::getId,dto.getId())
|
||||
.count() > 0){
|
||||
throw new IllegalArgumentException("当前名称已存在");
|
||||
}
|
||||
|
||||
if (Objects.nonNull(dto.getMenuId()) && menuService.lambdaQuery().eq(CctvBMenu::getId,dto.getMenuId())
|
||||
.count() == 0
|
||||
){
|
||||
throw new IllegalArgumentException("当前视频点目录不存在");
|
||||
}
|
||||
dto.setCreateTime(null);
|
||||
boolean result = service.updateById(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
|
@ -96,7 +126,24 @@ public class AttCctvBaseController {
|
|||
if (ObjectUtils.isNotNull(page.getType())) {
|
||||
query.eq(AttCctvBase::getType, Integer.valueOf(page.getType()));
|
||||
}
|
||||
return R.ok(service.page(page.getPageSo().toPage(), query));
|
||||
query.orderByDesc(AttCctvBase::getCreateTime);
|
||||
Page<AttCctvBase> basePage = service.page(page.getPageSo().toPage(), query);
|
||||
List<AttCctvBase> records = basePage.getRecords();
|
||||
if (CollectionUtils.isNotEmpty(records)){
|
||||
List<CctvBMenu> list = menuService.list();
|
||||
if (CollectionUtils.isNotEmpty(list)){
|
||||
Map<Long, List<String>> listMap = list.stream().
|
||||
collect(Collectors.groupingBy(CctvBMenu::getId, Collectors.mapping(CctvBMenu::getName, Collectors.toList())));
|
||||
|
||||
records.forEach(item -> {
|
||||
if (Objects.nonNull(item.getMenuId())){
|
||||
item.setMenuName(listMap.get(item.getMenuId()).getFirst());
|
||||
}
|
||||
});
|
||||
}
|
||||
basePage.setRecords(records);
|
||||
}
|
||||
return R.ok(basePage);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预览地址")
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@ import com.gunshi.project.xyt.validate.markers.Update;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 视频点目录
|
||||
* author: xusan
|
||||
|
|
@ -32,6 +35,13 @@ public class CctvBMenuController {
|
|||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<CctvBMenu> insert(@Validated(Insert.class) @RequestBody CctvBMenu dto) {
|
||||
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("当前名称已存在");
|
||||
}
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = service.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
|
|
@ -40,6 +50,11 @@ public class CctvBMenuController {
|
|||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<CctvBMenu> update(@Validated(Update.class) @RequestBody CctvBMenu dto) {
|
||||
if (StringUtils.isNotBlank(dto.getName()) && service.lambdaQuery().eq(CctvBMenu::getName,dto.getName())
|
||||
.ne(CctvBMenu::getId,dto.getId())
|
||||
.count() > 0){
|
||||
throw new IllegalArgumentException("当前名称已存在");
|
||||
}
|
||||
boolean result = service.updateById(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,13 @@ public class AttCctvBase implements Serializable {
|
|||
@Schema(description="menu_id")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* menu_id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description="所在区域")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class CctvBMenu implements Serializable {
|
|||
*/
|
||||
@TableField(value="parent_id")
|
||||
@Schema(description="parent_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -26,14 +25,14 @@ public class CctvBMenuService extends ServiceImpl<CctvBMenuMapper, CctvBMenu>
|
|||
{
|
||||
|
||||
public List<CctvBMenu> tree() {
|
||||
List<CctvBMenu> list = list(lambdaQuery().orderByDesc(CctvBMenu::getId));
|
||||
List<CctvBMenu> list = list();
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
Map<Long, List<CctvBMenu>> listMap = list.stream().collect(Collectors.groupingBy(CctvBMenu::getParentId));
|
||||
|
||||
list.forEach(o -> o.setChildren(listMap.get(o.getId())));
|
||||
List<CctvBMenu> parentList = list.stream().filter(o -> Objects.isNull(o.getParentId())).collect(Collectors.toList());
|
||||
List<CctvBMenu> parentList = list.stream().filter(o -> 0L == o.getParentId()).collect(Collectors.toList());
|
||||
return sorted(parentList);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -27,14 +26,14 @@ public class SysDictBService extends ServiceImpl<SysDictBMapper, SysDictB>
|
|||
|
||||
|
||||
public List<SysDictB> tree() {
|
||||
List<SysDictB> list = list(lambdaQuery().orderByDesc(SysDictB::getId));
|
||||
List<SysDictB> list = list();
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
Map<Long, List<SysDictB>> listMap = list.stream().collect(Collectors.groupingBy(SysDictB::getPid));
|
||||
|
||||
list.forEach(o -> o.setChildren(listMap.get(o.getId())));
|
||||
List<SysDictB> parentList = list.stream().filter(o -> Objects.isNull(o.getPid())).collect(Collectors.toList());
|
||||
List<SysDictB> parentList = list.stream().filter(o -> 0L == o.getPid()).collect(Collectors.toList());
|
||||
return sorted(parentList);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue