feat:增加了字典包(增删改查)

dev
zhang xu 2024-04-25 14:57:09 +08:00
parent 0215b0cb5e
commit 0c55e0126f
9 changed files with 326 additions and 6 deletions

View File

@ -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));
}
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -40,7 +40,7 @@ public interface KvtMapper {
/**
*
* */
public int deleteJdbc(Long id);
public int deleteJdbc(Long[] id);
/**
*

View File

@ -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);
}

View File

@ -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);
}

View File

@ -41,6 +41,8 @@ public interface KvtService {
* */
public int deleteJdbc(Long id);
int deleteJdbc(Long[] id);
/**
*
* */

View File

@ -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()+"'";