feat: 新增字典功能
commit
cc8b05ebfb
|
@ -10,7 +10,7 @@ import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatabaseTableInformation
|
* DatabaseTableInformation 数据库信息表
|
||||||
*
|
*
|
||||||
* @author DeKangLiu
|
* @author DeKangLiu
|
||||||
* on 2024/4/23
|
* on 2024/4/23
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestList
|
* TestList 资产结构接收
|
||||||
*
|
*
|
||||||
* @author DeKangLiu
|
* @author DeKangLiu
|
||||||
* on 2024/4/24
|
* on 2024/4/24
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.muyu.data.source.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据表
|
||||||
|
*
|
||||||
|
* @ClassName sysDictData
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 15:51
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_dict_data")
|
||||||
|
public class SysDictDataTable extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 字典排序
|
||||||
|
*/
|
||||||
|
private Integer dictSort;
|
||||||
|
/**
|
||||||
|
* 字典标签
|
||||||
|
*/
|
||||||
|
private String dictLabel;
|
||||||
|
/**
|
||||||
|
* 字典键值
|
||||||
|
*/
|
||||||
|
private String dictValue;
|
||||||
|
/**
|
||||||
|
* 字典类型
|
||||||
|
*/
|
||||||
|
private String dictType;
|
||||||
|
/**
|
||||||
|
* 是否默认(Y是 N否)
|
||||||
|
*/
|
||||||
|
private char isDefault;
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private char status;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.data.source.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型表
|
||||||
|
*
|
||||||
|
* @ClassName SysDictionary
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 15:56
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_dictionary")
|
||||||
|
public class SysDictionary extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典组件
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 字典名称
|
||||||
|
*/
|
||||||
|
private String dictName;
|
||||||
|
/**
|
||||||
|
* 字典类型
|
||||||
|
*/
|
||||||
|
private String dictType;
|
||||||
|
/**
|
||||||
|
* 状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 数据库名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
//字典数据集合
|
||||||
|
private List<SysDictDataTable> sysDictDataTableList;
|
||||||
|
}
|
|
@ -161,4 +161,6 @@ public class DataSourceController extends BaseController {
|
||||||
public Result<List<DatabaseTableInformation>> quantity(){
|
public Result<List<DatabaseTableInformation>> quantity(){
|
||||||
return dataSourceService.quantity();
|
return dataSourceService.quantity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.data.source.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DatabaseTable;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
import com.muyu.data.source.service.DatabaseTableService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库表对象 Controller层
|
||||||
|
*
|
||||||
|
* @ClassName DatabaseTableController
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/2 19:21
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/databaseTable")
|
||||||
|
public class DatabaseTableController {
|
||||||
|
@Autowired
|
||||||
|
private DatabaseTableService databaseTableService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改添加字典
|
||||||
|
* @param databaseTable
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/modification")
|
||||||
|
public Result<String> modification(@RequestBody DatabaseTable databaseTable){
|
||||||
|
return databaseTableService.modification(databaseTable);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.data.source.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
import com.muyu.data.source.service.SysDictDataTableService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据的Controller层
|
||||||
|
*
|
||||||
|
* @ClassName SysDictDataController
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 15:59
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(tags = "字典数据")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/data")
|
||||||
|
public class SysDictDataTableController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysDictDataTableService sysDictDataTableService;
|
||||||
|
|
||||||
|
//添加字典数据
|
||||||
|
@PostMapping("/sysDictDataTableAdd")
|
||||||
|
public Result<String> sysDictDataTableAdd(@RequestBody SysDictDataTable sysDictDataTable){
|
||||||
|
return sysDictDataTableService.sysDictDataTableAdd(sysDictDataTable);
|
||||||
|
}
|
||||||
|
//删除字典数据
|
||||||
|
@PostMapping("/sysDictDataTableDelete")
|
||||||
|
public Result<String> sysDictDataTableDelete(@RequestParam("id") Long id){
|
||||||
|
return sysDictDataTableService.sysDictDataTableDelete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改字典数据
|
||||||
|
@PostMapping("/sysDictDataTableUpdate")
|
||||||
|
public Result<String> sysDictDataTableUpdate(@RequestBody SysDictDataTable sysDictDataTable){
|
||||||
|
return sysDictDataTableService.sysDictDataTableUpdate(sysDictDataTable);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.data.source.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.data.source.domain.SysDictionary;
|
||||||
|
import com.muyu.data.source.service.SysDictionaryService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Controller层
|
||||||
|
*
|
||||||
|
* @ClassName SysDictionaryController
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 16:08
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(tags = "字典类型")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dictionary")
|
||||||
|
public class SysDictionaryController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysDictionaryService sysDictionaryService;
|
||||||
|
|
||||||
|
//查询出所有数据
|
||||||
|
@PostMapping("/dictionaryList")
|
||||||
|
public Result<List<SysDictionary>> dictionaryList(@RequestParam("databaseName") String databaseName){
|
||||||
|
return sysDictionaryService.dictionaryList(databaseName);
|
||||||
|
}
|
||||||
|
//添加字典类型
|
||||||
|
@PostMapping("/dictionaryAdd")
|
||||||
|
public Result<String> dictionaryAdd(@RequestBody SysDictionary sysDictionary){
|
||||||
|
return sysDictionaryService.dictionaryAdd(sysDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除类型 以及下面类型相同数据
|
||||||
|
@PostMapping("/dictionaryDelete")
|
||||||
|
public Result<String> dictionaryDelete(@RequestParam("dictType") String dictType){
|
||||||
|
return sysDictionaryService.dictionaryDelete(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改字典类型
|
||||||
|
@PostMapping("/dictionaryUpdate")
|
||||||
|
public Result<String> dictionaryUpdate(@RequestBody SysDictionary sysDictionary){
|
||||||
|
return sysDictionaryService.dictionaryUpdate(sysDictionary);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.muyu.data.source.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.data.source.domain.DatabaseTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DatabaseTable Mapper层接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: DatabaseTableMapper
|
||||||
|
* @createTime: 2024/5/2 19:27
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface DatabaseTableMapper extends BaseMapper<DatabaseTable> {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.data.source.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据Mapper接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: SysDictDataTableMapper
|
||||||
|
* @createTime: 2024/4/29 16:06
|
||||||
|
*/
|
||||||
|
public interface SysDictDataTableMapper extends BaseMapper<SysDictDataTable> {
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.data.source.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.data.source.domain.SysDictionary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Mapper接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: SysDictionaryMapper
|
||||||
|
* @createTime: 2024/4/29 16:14
|
||||||
|
*/
|
||||||
|
public interface SysDictionaryMapper extends BaseMapper<SysDictionary> {
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.data.source.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DatabaseTable;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DatabaseTable Service层接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: DatabaseTableService
|
||||||
|
* @createTime: 2024/5/2 19:25
|
||||||
|
*/
|
||||||
|
public interface DatabaseTableService extends IService<DatabaseTable> {
|
||||||
|
Result<String> modification(DatabaseTable databaseTable);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.data.source.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据表的 Service层
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @createTime: 2024/4/29 16:01
|
||||||
|
*/
|
||||||
|
public interface SysDictDataTableService extends IService<SysDictDataTable> {
|
||||||
|
Result<String> sysDictDataTableAdd(SysDictDataTable sysDictDataTable);
|
||||||
|
|
||||||
|
Result<String> sysDictDataTableDelete(Long id);
|
||||||
|
|
||||||
|
Result<String> sysDictDataTableUpdate(SysDictDataTable sysDictDataTable);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.data.source.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.SysDictionary;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型Service接口
|
||||||
|
*
|
||||||
|
* @author AnNan.Wang
|
||||||
|
* @ClassName: SysDictionaryService
|
||||||
|
* @createTime: 2024/4/29 16:11
|
||||||
|
*/
|
||||||
|
public interface SysDictionaryService extends IService<SysDictionary> {
|
||||||
|
Result<List<SysDictionary>> dictionaryList(String databaseName);
|
||||||
|
|
||||||
|
|
||||||
|
Result<String> dictionaryAdd(SysDictionary sysDictionary);
|
||||||
|
|
||||||
|
Result<String> dictionaryDelete(String dictType);
|
||||||
|
|
||||||
|
Result<String> dictionaryUpdate(SysDictionary sysDictionary);
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.data.source.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.DatabaseTable;
|
||||||
|
import com.muyu.data.source.mapper.DatabaseTableMapper;
|
||||||
|
import com.muyu.data.source.service.DatabaseTableService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DatabaseTable Impl层业务实现类
|
||||||
|
*
|
||||||
|
* @ClassName DatabaseTableServiceImpl
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/2 19:26
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DatabaseTableServiceImpl extends ServiceImpl<DatabaseTableMapper, DatabaseTable>
|
||||||
|
implements DatabaseTableService{
|
||||||
|
@Autowired
|
||||||
|
private DatabaseTableMapper databaseTableMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> modification(DatabaseTable databaseTable) {
|
||||||
|
return Result.success(
|
||||||
|
databaseTableMapper.updateById(
|
||||||
|
DatabaseTable.builder()
|
||||||
|
.id(databaseTable.getId())
|
||||||
|
.tableName(databaseTable.getTableName())
|
||||||
|
.name(databaseTable.getName())
|
||||||
|
.comment(databaseTable.getComment())
|
||||||
|
.isPrimaryKey(databaseTable.getIsPrimaryKey())
|
||||||
|
.type(databaseTable.getType())
|
||||||
|
.detailType(databaseTable.getDetailType())
|
||||||
|
.length(databaseTable.getLength())
|
||||||
|
.decimalPlaces(databaseTable.getDecimalPlaces())
|
||||||
|
.isNull(databaseTable.getIsNull())
|
||||||
|
.defaultValue(databaseTable.getDefaultValue())
|
||||||
|
.isDict(databaseTable.getIsDict())
|
||||||
|
.dictKey(databaseTable.getDictKey())
|
||||||
|
.databaseName(databaseTable.getDatabaseName())
|
||||||
|
.build()
|
||||||
|
)>0?"修改成功":"修改失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.muyu.data.source.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
import com.muyu.data.source.mapper.SysDictDataTableMapper;
|
||||||
|
import com.muyu.data.source.service.SysDictDataTableService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据的Impl 实现层
|
||||||
|
*
|
||||||
|
* @ClassName SysDictDataTableServiceImpl
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 16:05
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysDictDataTableServiceImpl extends ServiceImpl<SysDictDataTableMapper, SysDictDataTable>
|
||||||
|
implements SysDictDataTableService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDictDataTableMapper sysDictDataTableMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> sysDictDataTableAdd(SysDictDataTable sysDictDataTable) {
|
||||||
|
return Result.success(
|
||||||
|
sysDictDataTableMapper.insert(
|
||||||
|
SysDictDataTable.builder()
|
||||||
|
.dictLabel(sysDictDataTable.getDictLabel())
|
||||||
|
.dictValue(sysDictDataTable.getDictValue())
|
||||||
|
.dictType(sysDictDataTable.getDictType())
|
||||||
|
.remark(sysDictDataTable.getRemark())
|
||||||
|
.isDefault('N')
|
||||||
|
.status('0')
|
||||||
|
.build()
|
||||||
|
)>0?"添加成功":"添加失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> sysDictDataTableDelete(Long id) {
|
||||||
|
return Result.success(
|
||||||
|
sysDictDataTableMapper.deleteById(id)>0?"删除成功":"删除失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> sysDictDataTableUpdate(SysDictDataTable sysDictDataTable) {
|
||||||
|
return Result.success(
|
||||||
|
sysDictDataTableMapper.updateById(
|
||||||
|
SysDictDataTable.builder()
|
||||||
|
.id(sysDictDataTable.getId())
|
||||||
|
.dictLabel(sysDictDataTable.getDictLabel())
|
||||||
|
.dictValue(sysDictDataTable.getDictValue())
|
||||||
|
.remark(sysDictDataTable.getRemark())
|
||||||
|
.build()
|
||||||
|
)>0?"修改成功":"修改失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.muyu.data.source.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.source.domain.SysDictDataTable;
|
||||||
|
import com.muyu.data.source.domain.SysDictionary;
|
||||||
|
import com.muyu.data.source.mapper.SysDictDataTableMapper;
|
||||||
|
import com.muyu.data.source.mapper.SysDictionaryMapper;
|
||||||
|
import com.muyu.data.source.service.SysDictionaryService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型业务实现层
|
||||||
|
*
|
||||||
|
* @ClassName SysDictionaryServiceImpl
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/4/29 16:12
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysDictionaryServiceImpl extends ServiceImpl<SysDictionaryMapper, SysDictionary> implements SysDictionaryService {
|
||||||
|
@Autowired
|
||||||
|
private SysDictionaryMapper sysDictionaryMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDictDataTableMapper sysDictDataTableMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<SysDictionary>> dictionaryList(String databaseName) {
|
||||||
|
|
||||||
|
List<SysDictionary> dictionaryList = sysDictionaryMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysDictionary>(){{
|
||||||
|
eq(SysDictionary::getTableName, databaseName);
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
|
||||||
|
List<SysDictionary> arrayList = new ArrayList<>();
|
||||||
|
for (SysDictionary sysDictionary : dictionaryList) {
|
||||||
|
List<SysDictDataTable> sysDictDataTableList = sysDictDataTableMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysDictDataTable>() {{
|
||||||
|
eq(SysDictDataTable::getDictType, sysDictionary.getDictType());
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
|
||||||
|
arrayList.add(
|
||||||
|
SysDictionary.builder()
|
||||||
|
.id(sysDictionary.getId())
|
||||||
|
.dictName(sysDictionary.getDictName())
|
||||||
|
.dictType(sysDictionary.getDictType())
|
||||||
|
.status(sysDictionary.getStatus())
|
||||||
|
.sysDictDataTableList(sysDictDataTableList)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(arrayList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> dictionaryAdd(SysDictionary sysDictionary) {
|
||||||
|
return Result.success(
|
||||||
|
sysDictionaryMapper.insert(
|
||||||
|
SysDictionary.builder()
|
||||||
|
.dictName(sysDictionary.getDictName())
|
||||||
|
.dictType(sysDictionary.getDictType())
|
||||||
|
.remark(sysDictionary.getRemark())
|
||||||
|
.tableName(sysDictionary.getTableName())
|
||||||
|
.build()
|
||||||
|
)>0?"添加成功":"添加失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> dictionaryDelete(String dictType) {
|
||||||
|
List<SysDictionary> sysDictionaries = sysDictionaryMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysDictionary>() {{
|
||||||
|
eq(SysDictionary::getDictType, dictType);
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
for (SysDictionary sysDictionary : sysDictionaries) {
|
||||||
|
List<SysDictDataTable> sysDictDataTableList = sysDictDataTableMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<SysDictDataTable>() {{
|
||||||
|
eq(SysDictDataTable::getDictType, sysDictionary.getDictType());
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
if (sysDictDataTableList.size()>0) {
|
||||||
|
int i = sysDictionaryMapper.deleteById(sysDictionary.getId());
|
||||||
|
int i1 = sysDictDataTableMapper.deleteBatchIds(sysDictDataTableList);
|
||||||
|
if (i>0 && i1>0) {
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}else {
|
||||||
|
return Result.error("删除失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int i = sysDictionaryMapper.deleteById(sysDictionary.getId());
|
||||||
|
if (i>0) {
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}else {
|
||||||
|
return Result.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> dictionaryUpdate(SysDictionary sysDictionary) {
|
||||||
|
return Result.success(
|
||||||
|
sysDictionaryMapper.updateById(
|
||||||
|
SysDictionary.builder()
|
||||||
|
.id(sysDictionary.getId())
|
||||||
|
.dictName(sysDictionary.getDictName())
|
||||||
|
.dictType(sysDictionary.getDictType())
|
||||||
|
.remark(sysDictionary.getRemark())
|
||||||
|
.build()
|
||||||
|
)>0?"修改成功":"修改失败"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -97,16 +97,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`data_management`.`database_table`
|
`data_management`.`database_table`
|
||||||
(
|
(
|
||||||
`tableName`,
|
`table_name`,
|
||||||
`name`,
|
`name`,
|
||||||
`comment`,
|
`comment`,
|
||||||
`isPrimaryKey`,
|
`is_primary_key`,
|
||||||
`type`,
|
`type`,
|
||||||
`detailType`,
|
`detail_kype`,
|
||||||
`length`,
|
`length`,
|
||||||
`decimalPlaces`,
|
`decimal_places`,
|
||||||
`isNull`,
|
`is_null`,
|
||||||
`defaultValue`,
|
`default_value`,
|
||||||
`database_name`)
|
`database_name`)
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="databaseTables" item="databaseTable" separator=",">
|
<foreach collection="databaseTables" item="databaseTable" separator=",">
|
||||||
|
@ -177,12 +177,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
from
|
from
|
||||||
database_table
|
database_table
|
||||||
where
|
where
|
||||||
`tableName`=#{name}
|
`table_name`=#{name}
|
||||||
and
|
and
|
||||||
`database_name`=#{databaseName}
|
`database_name`=#{databaseName}
|
||||||
</select>
|
</select>
|
||||||
<select id="database" resultType="com.muyu.data.source.domain.model.DatabaseTableModel">
|
<select id="database" resultType="com.muyu.data.source.domain.model.DatabaseTableModel">
|
||||||
select * from database_table where tableName=#{name}
|
select * from database_table where table_name=#{name}
|
||||||
</select>
|
</select>
|
||||||
<select id="table" resultType="com.muyu.data.source.domain.DatabaseTableInformation">
|
<select id="table" resultType="com.muyu.data.source.domain.DatabaseTableInformation">
|
||||||
select * from database_table_information where database_name=#{databaseName}
|
select * from database_table_information where database_name=#{databaseName}
|
||||||
|
|
Loading…
Reference in New Issue