| | |
| | | package com.vci.ubcs.omd.controller; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.nacos.api.exception.NacosException; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.omd.constant.OmdCacheConstant; |
| | |
| | | import com.vci.ubcs.omd.entity.BtmType; |
| | | import com.vci.ubcs.omd.repeater.DomainRepeater; |
| | | import com.vci.ubcs.omd.service.IBtmTypeService; |
| | | import com.vci.ubcs.omd.vo.BtmTreeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.omd.vo.DomainVO; |
| | | import com.vci.ubcs.omd.wrapper.BtmTypeWrapper; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Description: 业务类型控制器 |
| | |
| | | * 业务类型服务 |
| | | */ |
| | | private final IBtmTypeService btmTypeService; |
| | | |
| | | |
| | | /** |
| | | * 查看详情 |
| | |
| | | @ApiImplicitParam(name = "name", value = "业务类型中文名称", paramType = "query", dataType = "string"), |
| | | @ApiImplicitParam(name = "tableName", value = "业务类型数据库表名", paramType = "query", dataType = "string"), |
| | | }) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "查询列表", notes = "传入查询") |
| | | public R<IPage<BtmTypeVO>> parentList(@ApiIgnore @RequestParam Map<String, Object> condition, Query query) { |
| | | IPage<BtmTypeVO> pageVO = new Page<>(); |
| | |
| | | return R.data(pageVO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @PostMapping("/submit/{auto}") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增或修改", notes = "传入业务类型对象") |
| | | public R submit(@Valid @RequestBody BtmTypeDTO dto,@PathVariable(value = "auto") boolean auto) { |
| | | CacheUtil.clear(OmdCacheConstant.BTM_CACHE); |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "删除", notes = "主键集合") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(OmdCacheConstant.BTM_CACHE); |
| | |
| | | * 获取领域值 |
| | | */ |
| | | @GetMapping("/domain") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "获取领域值") |
| | | public R<List<String>> getDomain(){ |
| | | public R<List<DomainVO>> getDomain(){ |
| | | try { |
| | | return R.data(DomainRepeater.getDomain()); |
| | | } catch (NacosException e) { |
| | | return R.fail(e.getErrMsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 按domain分组,查询业务类型的树形结构 |
| | | */ |
| | | @GetMapping("/tree-domain") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "业务类型树形结构", notes = "业务类型树形结构") |
| | | public R<List<BtmTreeVO>> treeDomain(){ |
| | | return R.data(btmTypeService.treeDomain()); |
| | | } |
| | | |
| | | /** |
| | | * 从数据库表中获取 |
| | | * @param domain 领域值 |
| | | * @return 读取结果 |
| | | */ |
| | | @GetMapping("/get-from-table") |
| | | @ApiOperation(value = "从数据库表中读取",notes = "从数据库表中读取") |
| | | @ApiOperationSupport(order = 8) |
| | | public R<List<BtmTypeVO>> getFromTable(String domain){ |
| | | return R.data(btmTypeService.getFromTable(domain)); |
| | | } |
| | | |
| | | /** |
| | | * 数据库选择的表保存为业务类型 |
| | | * @param btmTypeDTOList 页面传输对象 |
| | | * @return 执行结果 |
| | | */ |
| | | @PostMapping("/save-from-table/{domain}") |
| | | @ApiOperation(value = "从数据库中保存",notes = "从数据库中保存") |
| | | @ApiOperationSupport(order = 9) |
| | | public R saveFromTable(@RequestBody List<BtmTypeDTO> btmTypeDTOList,@PathVariable(value = "domain") String domain){ |
| | | // 数据库表不能重复 |
| | | Set<String> tableNames = btmTypeDTOList.stream().map(BtmTypeDTO::getTableName).filter(StringUtils::isNotBlank).collect(Collectors.toSet()); |
| | | long count = btmTypeService.count(Wrappers.<BtmType>query().lambda().in(BtmType::getTableName,tableNames)); |
| | | if (count > 0){ |
| | | return R.fail("所选表在业务类型中已存在"); |
| | | } |
| | | // 业务类型不能重复 |
| | | btmTypeDTOList = btmTypeDTOList.stream().peek(s -> { |
| | | String id; |
| | | String tableName = s.getTableName(); |
| | | if (tableName.contains(StringPool.UNDERSCORE)) { |
| | | List<String> strList = Arrays.asList(tableName.split(StringPool.UNDERSCORE)); |
| | | id = strList.get(strList.size() - 1); |
| | | } else { |
| | | id = tableName; |
| | | } |
| | | s.setId(id.toLowerCase()); |
| | | }).collect(Collectors.toList()); |
| | | List<String> btmTypeIdList = btmTypeDTOList.stream().map(BtmTypeDTO::getId).collect(Collectors.toList()); |
| | | |
| | | long countId = btmTypeService.count(Wrappers.<BtmType>query().lambda().in(BtmType::getId, btmTypeIdList)); |
| | | if (countId > 0){ |
| | | return R.fail("所选表与已存在业务类型冲突"); |
| | | } |
| | | return R.data(btmTypeService.saveFromTable(btmTypeDTOList,domain)); |
| | | } |
| | | |
| | | /** |
| | | * 获取默认属性 |
| | | * @param defaultAttrType |
| | | * @return |
| | | */ |
| | | @GetMapping("/getDefaultAttr") |
| | | @ApiOperation(value = "获取默认属性",notes = "获取默认属性") |
| | | @ApiOperationSupport(order = 10) |
| | | public R getDefaultAttr(String defaultAttrType){ |
| | | return R.data(this.btmTypeService.getDefaultAttr(defaultAttrType)); |
| | | } |
| | | |
| | | } |