package com.dragoninfo.dcuc.authweb.restcontroller.sub; import com.dragoninfo.dcuc.app.facade.sub.IFieldClaFacade; import com.dragoninfo.dcuc.app.dto.sub.FieldClaAcceptDTO; import com.dragoninfo.dcuc.app.dto.sub.FieldClaDTO; import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.data.FieldClaAcceptVo; import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.data.FieldClaVo; import com.dragoninfo.dcuc.authweb.util.VersionUtils; import com.dragoninfo.duceap.core.response.Result; import com.dragonsoft.duceap.base.entity.http.ResponseStatus; import com.dragonsoft.duceap.base.entity.search.SearchDTO; import com.dragonsoft.duceap.core.search.Searchable; import io.swagger.annotations.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; /** * @author mazq * @date 2021/5/25 */ @Api(tags = {"主客体授权-字段分类表码接口"}) @RestController @RequestMapping(value = "/fieldclassifysvr/"+ VersionUtils.VERSION_UID) public class FieldClassifyController { @Autowired private IFieldClaFacade fieldClaFacade; @ApiOperation(value = "数据资源分类分页列表") @ApiImplicitParam(name = "Searchable", value = "Searchable 数据资源分类分页查询对象,查询条件[name:firName op: like] [name: secName op: like] ") @PostMapping(value = "search") public Result dataClassifyPageList(Searchable searchable) { Page page = fieldClaFacade.pageSearch(searchable.toSearchDTO()); List content = page.getContent(); List vos = content.stream().map(item -> { FieldClaAcceptVo vo = new FieldClaAcceptVo(); BeanUtils.copyProperties(item, vo); return vo; }).collect(Collectors.toList()); return Result.success(page.getTotalElements(), vos); } @ApiOperation(value = "添加字段分类表") @ApiImplicitParam(name = "FieldClaAcceptVo", value = "FieldClaAcceptVo 字段分类表Vo") @PostMapping(value = "save") public Result fieldClaAdd(@RequestBody FieldClaAcceptVo vo){ FieldClaAcceptDTO dto = new FieldClaAcceptDTO(); BeanUtils.copyProperties(vo,dto); ResponseStatus status = fieldClaFacade.fieldClassifyAdd(dto); if(status.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)) { return Result.success(ResponseStatus.SUCCESS_CODE); }else { return Result.fail(ResponseStatus.FAIL_CODE,status.getMessage()); } } @ApiOperation(value = "修改字段分类") @ApiImplicitParam(name = "FieldClaAcceptVo", value = "FieldClaAcceptVo 字段分类Vo") @PostMapping(value = "update") public Result dataClassifyUpdate(@RequestBody FieldClaAcceptVo vo){ FieldClaAcceptDTO dto = new FieldClaAcceptDTO(); BeanUtils.copyProperties(vo,dto); Boolean b = fieldClaFacade.fieldClassifyUpdate(dto); if (b) { return Result.success(); } else { return Result.fail(); } } @ApiOperation(value = "字段分类详情") @ApiImplicitParam(name = "id", value = "id 字段分类 字段分类id") @GetMapping(value = "detailAllLevel/{id}") public Result detailAllLevel(@PathVariable("id") String id){ FieldClaAcceptDTO viewDTO = fieldClaFacade.detailAllLevel(id); FieldClaAcceptVo vo = new FieldClaAcceptVo(); BeanUtils.copyProperties(viewDTO, vo); return Result.success(vo); } @ApiOperation(value = "根据code和path查询字段分类详情") @ApiImplicitParams({ @ApiImplicitParam(name = "code", value = "code: 该级代码"), @ApiImplicitParam(name = "path", value = "path: 上级层级id组成 1-2-3-4 一级为空") }) @GetMapping(value = "getByCodeAndPath") public Result getByCodeAndPath(@RequestParam("code") String code, @RequestParam(value = "path", required = false) String path) { FieldClaDTO dto = fieldClaFacade.getByCodeAndPath(code, path); FieldClaVo vo = new FieldClaVo(); BeanUtils.copyProperties(dto, vo); return Result.success(vo); } @ApiOperation(value = "字段分类删除,根据Id删除所有层级数据") @ApiImplicitParam(name = "id", value = "字段分类id") @DeleteMapping(value = "deleteById/{id}") public Result deleteAllLevel(@PathVariable("id") String id){ Boolean b = fieldClaFacade.deleteAllLevel(id); if (b) { return Result.success(); } else { return Result.fail(); } } @ApiModelProperty(value = "查询二级字段分类") @ApiImplicitParam(name = "Searchable", value = "Searchable 查询条件 id not in") @PostMapping(value = "getSecLevelColumn") public Result> getSecLevelColumn(SearchDTO searchDTO) { List dtos = fieldClaFacade.getSecLevelColumn(searchDTO); List vos = dtos.stream().map(item -> { FieldClaVo vo = new FieldClaVo(); BeanUtils.copyProperties(item, vo); return vo; }).collect(Collectors.toList()); return Result.success(vos); } }