feat:增加了字典包(增删改查)
parent
0215b0cb5e
commit
0c55e0126f
|
@ -0,0 +1,95 @@
|
|||
package com.zx.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.zx.domain.req.DictionaryData;
|
||||
import com.zx.service.Impl.DictionaryDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassDescription:
|
||||
* @JdkVersion: 17
|
||||
* @Author: zhangxu
|
||||
* @Created: 2024/4/25 14:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jdbc")
|
||||
public class DictionaryDataController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DictionaryData>> list(DictionaryData dictionaryData)
|
||||
{
|
||||
startPage();
|
||||
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出【请填写功能名称】列表
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DictionaryData dictionaryData)
|
||||
{
|
||||
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
|
||||
ExcelUtil<DictionaryData> util = new ExcelUtil<DictionaryData>(DictionaryData.class);
|
||||
util.exportExcel(response, list, "【请填写功能名称】数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(dictionaryDataService.selectDictionaryDataById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody DictionaryData dictionaryData)
|
||||
{
|
||||
return toAjax(dictionaryDataService.insertDictionaryData(dictionaryData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody DictionaryData dictionaryData)
|
||||
{
|
||||
return toAjax(dictionaryDataService.updateDictionaryData(dictionaryData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(dictionaryDataService.deleteDictionaryDataByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.zx.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @ClassDescription:
|
||||
* @JdkVersion: 17
|
||||
* @Author: zhangxu
|
||||
* @Created: 2024/4/25 14:13
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DictionaryData extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
* */
|
||||
private Long id;
|
||||
/**
|
||||
* 字典表id
|
||||
* */
|
||||
private Long dictionaryId;
|
||||
/**
|
||||
* 字典标签
|
||||
* */
|
||||
private String lable;
|
||||
/**
|
||||
* 字典值
|
||||
* */
|
||||
private String val;
|
||||
/**
|
||||
* 字典值
|
||||
* */
|
||||
private Boolean isEdit=false;
|
||||
/**
|
||||
* 重写toString方法
|
||||
* */
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("dictionaryId", getDictionaryId())
|
||||
.append("lable", getLable())
|
||||
.append("val", getVal())
|
||||
.append("isEdit", getIsEdit())
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ public interface DataAssetMapper {
|
|||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDataAssetById(Long id);
|
||||
public int deleteDataAssetById(Long[] id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
|
@ -65,4 +65,8 @@ public interface DataAssetMapper {
|
|||
|
||||
|
||||
List<DataAsset> selectDataAssetBatchId(@Param("longs") List<Long> longs);
|
||||
|
||||
|
||||
|
||||
List<DataAsset> getDataAssetList(@Param("ids") Long[] ids);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.zx.mapper;
|
||||
|
||||
import com.zx.domain.req.DictionaryData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassDescription:
|
||||
* @JdkVersion: 17
|
||||
* @Author: zhangxu
|
||||
* @Created: 2024/4/25 14:21
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictionaryDataMapper {
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public DictionaryData selectDictionaryDataById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param dictionaryData 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<DictionaryData> selectDictionaryDataList(DictionaryData dictionaryData);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param dictionaryData 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictionaryData(DictionaryData dictionaryData);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param dictionaryData 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictionaryData(DictionaryData dictionaryData);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryDataById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryDataByIds(Long[] ids);
|
||||
|
||||
List<DictionaryData> getDictionaryDataList(@Param("dictionaryIds") List<Long> dictionaryIds);
|
||||
|
||||
void deleteDictionaryData(@Param("dictionaryIds") List<Long> dictionaryIds);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ public interface KvtMapper {
|
|||
/**
|
||||
* 删除
|
||||
* */
|
||||
public int deleteJdbc(Long id);
|
||||
public int deleteJdbc(Long[] id);
|
||||
|
||||
/**
|
||||
* 批删
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package com.zx.service.Impl;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.zx.domain.req.DataAsset;
|
||||
import com.zx.domain.req.JdbcClass;
|
||||
import com.zx.mapper.DataAssetMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,6 +14,7 @@ import java.util.List;
|
|||
* @Author: zhangxu
|
||||
* @Created: 2024/4/23 14:40
|
||||
*/
|
||||
@Service
|
||||
public class DataAssetServiceImpl implements DataAssetService{
|
||||
|
||||
@Autowired
|
||||
|
@ -82,6 +82,11 @@ public class DataAssetServiceImpl implements DataAssetService{
|
|||
return dataAssetMapper.deleteDataAssetByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteDataAssetById(Long id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
|
@ -89,7 +94,7 @@ public class DataAssetServiceImpl implements DataAssetService{
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDataAssetById(Long id)
|
||||
public int deleteDataAssetById(Long[] id)
|
||||
{
|
||||
return dataAssetMapper.deleteDataAssetById(id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.zx.service.Impl;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.zx.domain.req.Dictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassDescription:
|
||||
* @JdkVersion: 17
|
||||
* @Author: zhangxu
|
||||
* @Created: 2024/4/25 14:23
|
||||
*/
|
||||
public interface DictionaryService {
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public Dictionary selectDictionaryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param dictionary 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<Dictionary> selectDictionaryList(Dictionary dictionary);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param dictionary 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDictionary(Dictionary dictionary);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param dictionary 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictionary(Dictionary dictionary);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictionaryById(Long id);
|
||||
|
||||
Result getDictionaryList(Long dataSourceId);
|
||||
|
||||
Result deleteDictionary(Long id);
|
||||
}
|
|
@ -41,6 +41,8 @@ public interface KvtService {
|
|||
* */
|
||||
public int deleteJdbc(Long id);
|
||||
|
||||
int deleteJdbc(Long[] id);
|
||||
|
||||
/**
|
||||
* 批删
|
||||
* */
|
||||
|
|
|
@ -44,6 +44,7 @@ public class KvtServiceImpl implements KvtService{
|
|||
|
||||
@Override
|
||||
public JdbcClass selectJdbcById(Long id) {
|
||||
|
||||
return kvtMapper.selectJdbcById(id);
|
||||
}
|
||||
|
||||
|
@ -71,10 +72,27 @@ public class KvtServiceImpl implements KvtService{
|
|||
}
|
||||
|
||||
@Override
|
||||
public int deleteJdbc(Long id) {
|
||||
public int deleteJdbc(Long[] id) {
|
||||
deleteChildren(id);
|
||||
return kvtMapper.deleteJdbc(id);
|
||||
}
|
||||
|
||||
|
||||
public void deleteChildren(Long[] id) {
|
||||
List<DataAsset> dataAssetList = dataAssetMapper.getDataAssetList(id);
|
||||
if (!dataAssetList.isEmpty()){
|
||||
List<Long> list = dataAssetList.stream().map(DataAsset::getId).toList();
|
||||
List<AssetModel> assetModelList = assetModelMapper.getAssetModelList(list);
|
||||
dataAssetMapper.deleteDataAssetById(dataAssetList.toArray(Long[]::new));
|
||||
if (!assetModelList.isEmpty()){
|
||||
List<Long> list1 = assetModelList.stream().map(AssetModel::getId).toList();
|
||||
assetModelMapper.deleteAssetModelByIds(list1.toArray(Long[]::new));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAllJdbc(Long[] ids) {
|
||||
return kvtMapper.deleteAllJdbc(ids);
|
||||
|
@ -474,6 +492,7 @@ public class KvtServiceImpl implements KvtService{
|
|||
|
||||
@Override
|
||||
public Result synchronousData(JdbcClass jdbcClass) {
|
||||
deleteChildren(new Long[]{jdbcClass.getId()});
|
||||
// 构造查询MySQL数据库中表信息的SQL语句
|
||||
String mysql = "SELECT TABLE_NAME t_name,TABLE_COMMENT table_comment,TABLE_ROWS table_rows,(SELECT count(*) FROM INFORMATION_SCHEMA.columns WHERE TABLE_SCHEMA = '"+jdbcClass.getDatabaseName()+"' and TABLE_NAME=t_name) fields FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='"+jdbcClass.getDatabaseName()+"'";
|
||||
|
||||
|
|
Loading…
Reference in New Issue