数据字段增删改查

master
Yueng 2024-08-23 21:32:58 +08:00
parent 1a073d19c5
commit 17fe0c5adf
11 changed files with 334 additions and 119 deletions

View File

@ -11,10 +11,11 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import java.util.Date; import java.util.Date;
import java.util.function.Supplier;
/** /**
* @Author * @Author
* @Packagecom.muyu.server.pojo * @Packagecom.muyu.server.pojo
* @Projectcloud-integration * @Projectcloud-integration
* @nameDataSourceList * @nameDataSourceList
* @Date2024/8/20 18:47 * @Date2024/8/20 18:47
@ -25,53 +26,51 @@ import java.util.Date;
@TableName(value = "data_source") @TableName(value = "data_source")
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
//核心数据库初始化 //
public class DataSourceInfo extends BaseEntity { public class DataSourceInfo extends BaseEntity {
/**
* /
*/
@TableId(value = "id",type = IdType.AUTO) @TableId(value = "id",type = IdType.AUTO)
private Integer id; private String id ;
/**
*
*/
private String name ; private String name ;
private String cardNo ;
/** private String descriot ;
* private String ctfTp ;
*/ private String ctfId ;
private String gender ; private String gender ;
private String birthday ;
/**
*
*/
private Date birthday;
/**
*
*/
private String address ; private String address ;
private String zip ;
/** private String dirty ;
* private String district1 ;
*/ private String district2 ;
private String district3 ;
private String district4 ;
private String district5 ;
private String district6 ;
private String firstNm ;
private String lastNm ;
private String duty ;
private String mobile ; private String mobile ;
private String tel ;
private String fax ;
private String eMail ;
private String nation ;
private String taste ;
private String education ;
private String company ;
private String cTel ;
private String cAddress ;
private String cZip ;
private String family ;
private String version ;
/** // public static DataSourceList updBuild(DataSourceList dataSourceList, Supplier<Long> idSupplier) {
* // return DataSourceList.builder()
*/ // .id(idSupplier.get())
private String idCard; // .name(dataSourceList.getName())
// .gender(dataSourceList.getGender())
/** // .
* // ;
*/ // }
private String email;
/**
*
*/
private String credit;
} }

View File

@ -3,12 +3,14 @@ package com.muyu.common.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Date; import java.util.Date;
import java.util.function.Supplier;
/** /**
* @Author * @Author
@ -22,7 +24,8 @@ import java.util.Date;
@TableName(value = "data_source") @TableName(value = "data_source")
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class DataSourceList { //核心数据库
public class DataSourceList extends BaseEntity {
/** /**
* / * /
@ -70,4 +73,5 @@ public class DataSourceList {
*/ */
private String credit; private String credit;
} }

View File

@ -1,61 +0,0 @@
package com.muyu.common.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author
* @Packagecom.muyu.common.domain
* @Projectcloud-integration
* @nameInitialData
* @Date2024/8/21 12:43
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("dashuju")
public class InitialData {
@TableId(value = "id",type = IdType.AUTO)
private String id ;
private String name ;
private String cardNo ;
private String descriot ;
private String ctfTp ;
private String ctfId ;
private String gender ;
private String birthday ;
private String address ;
private String zip ;
private String dirty ;
private String district1 ;
private String district2 ;
private String district3 ;
private String district4 ;
private String district5 ;
private String district6 ;
private String firstNm ;
private String lastNm ;
private String duty ;
private String mobile ;
private String tel ;
private String fax ;
private String eMail ;
private String nation ;
private String taste ;
private String education ;
private String company ;
private String cTel ;
private String cAddress ;
private String cZip ;
private String family ;
private String version ;
}

View File

@ -1,15 +1,15 @@
package com.muyu.common.domain; package com.muyu.common.domain;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.enums.SysPayType;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data; import java.util.function.Supplier;
import lombok.NoArgsConstructor;
/** /**
* @Authoryang * @Authoryang
* @Packagecom.muyu.common.domain * @Packagecom.muyu.common.domain
* @Projectcloud-property * @Projectcloud-property
* @nameTableField * @nameTableField
* @Date2024/8/23 11:39 * @Date2024/8/23 11:39
@ -21,11 +21,64 @@ import lombok.NoArgsConstructor;
@TableName("TableField") @TableName("TableField")
public class TableField extends BaseEntity { public class TableField extends BaseEntity {
private String fieId; private Long fieId;
private String type; private String type;
private String collation; private String collation;
private String Null; private String Null;
private String key; private String key;
private String comment; private String comment;
public static TableField customerBuild(TableField tableField, Supplier<TableField> function) {
return TableField.builder()
.fieId(tableField.getFieId())
.type(tableField.getType())
.collation(tableField.getCollation())
.Null(tableField.getNull())
.key(tableField.getKey())
.comment(tableField.getComment())
.build();
}
/**
* spring
* @param req
* @return
*/
public static TableField addBuild(TableField req) {
return TableField.builder()
.type(req.getType())
.collation(req.getCollation())
.Null(req.getNull())
.key(req.getKey())
.comment(req.getComment())
.build();
}
/**
* spring
* @param req
* @return
*/
public static TableField updBuild(TableField req, Supplier<Long> idSupplier) {
return TableField.builder()
.fieId(idSupplier.get())
.type(req.getType())
.collation(req.getCollation())
.Null(req.getNull())
.key(req.getKey())
.comment(req.getComment())
.build();
}
public TableField buildTableField() {
return TableField.builder()
.fieId(this.getFieId())
.type(this.getType())
.collation(this.getCollation())
.Null(this.getNull())
.key(this.getKey())
.comment(this.getComment())
.build();
}
} }

View File

@ -7,13 +7,11 @@ import com.muyu.common.domain.TableField;
import com.muyu.server.service.DataSourceService; import com.muyu.server.service.DataSourceService;
import com.muyu.server.service.TableFieldService; import com.muyu.server.service.TableFieldService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -35,13 +33,22 @@ public class DataSourceController {
private final TableFieldService tableFieldService; private final TableFieldService tableFieldService;
/**
*
* @param connect
* @return
*/
@PostMapping("/extractData") @PostMapping("/extractData")
@Operation(summary = "抽取数据",description = "从数据源中抽取数据") @Operation(summary = "抽取数据",description = "从数据源中抽取数据")
public Result<List<DataSourceList>> extractData(@RequestBody Connect connect){ public Result<List<DataSourceList>> extractData(@RequestBody Connect connect){
return Result.success(dataSourceService.extractData(connect),"您的数据已成功获取"); return Result.success(dataSourceService.extractData(connect),"您的数据已成功获取");
} }
/**
*
* @param connect
* @return
*/
@PostMapping("/tableField") @PostMapping("/tableField")
@Operation(summary = "抽取结构",description = "从数据源中抽取结构") @Operation(summary = "抽取结构",description = "从数据源中抽取结构")
public Result<String> extractTableField(@RequestBody Connect connect){ public Result<String> extractTableField(@RequestBody Connect connect){
@ -55,4 +62,20 @@ public class DataSourceController {
return Result.success(null,"您的数据已成功获取"); return Result.success(null,"您的数据已成功获取");
} }
// /**
// * 修改结构
// * @param id 实体类
// * @return 修改结果
// */
// @PutMapping("/update/{id}")
// @Operation(summary = "数据源信息修改",description = "通过ID修改数据源中修改数据")
// public Result<String> update(
// @Schema(title = "元数据Id",type = "Long",defaultValue = "1",description = "修改元数据信息需要依据的唯一条件")
// @PathVariable("id") Long id,
// @RequestBody DataSourceList dataSourceList){
//
// dataSourceService.updateById(DataSourceList.updBuild(dataSourceList,()->id));
// return Result.success(null,"您的数据已成功获取");
// }
} }

View File

@ -0,0 +1,83 @@
package com.muyu.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.domain.TableField;
import com.muyu.server.service.TableFieldService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Authoryang
* @Packagecom.muyu.server.controller
* @Projectcloud-property
* @nameTableFieldController
* @Date2024/8/23 19:56
*/
@RestController
@RequestMapping("/tableField")
@Tag(name = "抽取数据字段",description = "从数据源抽取数据字段")
@AllArgsConstructor
public class TableFieldController {
private final TableFieldService tableFieldService;
/**
*
* @param tableField
* @return
*/
@RequestMapping(path = "/list" ,method = RequestMethod.POST)
@Operation(summary = "抽取数据字段",description = "所有数据字段列表请求参数")
public Result<List<TableField>> selectList(
@Validated @RequestBody TableField tableField){
return Result.success(
tableFieldService.selectList(tableField)
);
}
/**
*
* @param tableField
* @return
*/
@PostMapping("/add")
@Operation(summary = "数据字段添加",description = "添加数据字段信息,添加成功之后才可以使用数据字段")
public Result<String> save(@Validated @RequestBody TableField tableField){
tableFieldService.save(TableField.addBuild(tableField));
return Result.success(null,"操作成功");
}
/**
*
* @param tableField
* @return
*/
@PutMapping("/update/{fieId}")
@Operation(summary = "数据字段修改",description = "通过ID修改数据字段信息")
public Result<String> update(
@Schema(title = "数据字段ID",type = "Long",defaultValue = "1",description = "修改数据字段信息需要依据的唯一条件")
@PathVariable("fieId") Long fieId,
@RequestBody @Validated TableField tableField){
tableFieldService.updateById(TableField.updBuild(tableField,()->fieId));
return Result.success(null,"操作成功");
}
/**
*
* @param orderCustomerId
* @return
*/
@DeleteMapping("/delete/{fieId}")
@Operation(summary = "客户信息删除",description = "通过ID删除客户信息")
public Result<String> delete(@PathVariable("fieId") Long orderCustomerId){
tableFieldService.removeById(orderCustomerId);
return Result.success(null,"操作成功");
}
}

View File

@ -0,0 +1,17 @@
package com.muyu.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.domain.TableField;
import jdk.jfr.MemoryAddress;
import org.apache.ibatis.annotations.Mapper;
/**
* @Authoryang
* @Packagecom.muyu.server.mapper
* @Projectcloud-property
* @nameTableFieldMapperlimt
* @Date2024/8/23 20:18
*/
@Mapper
public interface TableFieldMapperlimt extends BaseMapper<TableField> {
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.domain.TableField; import com.muyu.common.domain.TableField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* @Authoryang * @Authoryang
@ -13,4 +14,10 @@ import java.util.ArrayList;
* @Date2024/8/23 14:00 * @Date2024/8/23 14:00
*/ */
public interface TableFieldService extends IService<TableField> { public interface TableFieldService extends IService<TableField> {
/**
*
* @param tableField
* @return
*/
List<TableField> selectList(TableField tableField);
} }

View File

@ -0,0 +1,24 @@
package com.muyu.server.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.domain.TableField;
import java.util.List;
import java.util.Optional;
/**
* @Authoryang
* @Packagecom.muyu.server.service
* @Projectcloud-property
* @nameTableFieldServicelimt
* @Date2024/8/23 20:16
*/
public interface TableFieldServicelimt extends IService<TableField> {
/**
* code
* @param fieId code
* @param limit
* @return
*/
List<TableField> selectOrderPayByAppCodeAndLimit(String fieId, int limit);
}

View File

@ -1,12 +1,16 @@
package com.muyu.server.service.impl; package com.muyu.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.TableField; import com.muyu.common.domain.TableField;
import com.muyu.server.mapper.TableFieldMapper; import com.muyu.server.mapper.TableFieldMapper;
import com.muyu.server.service.TableFieldService; import com.muyu.server.service.TableFieldService;
import com.muyu.server.service.TableFieldServicelimt;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.List;
/** /**
* @Authoryang * @Authoryang
@ -20,4 +24,31 @@ public class TableFieldServiceImpl
extends ServiceImpl<TableFieldMapper,TableField> extends ServiceImpl<TableFieldMapper,TableField>
implements TableFieldService { implements TableFieldService {
@Autowired
private TableFieldServicelimt tableFieldServicelimt;
/**
*
* @param tableField
* @return
*/
@Override
public List<TableField> selectList(TableField tableField) {
LambdaQueryWrapper<TableField> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(
StringUtils.isNotEmpty(tableField.getType()),
TableField::getType,tableField.getType()
);
List<TableField> tableFieldList = this.list(queryWrapper);
return tableFieldList.stream()
.map(orderPaytableField -> TableField.customerBuild(
orderPaytableField,
() -> (TableField) tableFieldServicelimt.selectOrderPayByAppCodeAndLimit(orderPaytableField.getFieId(),5)
.stream()
.map(TableField::buildTableField)
.toList()
)
)
.toList();
}
} }

View File

@ -0,0 +1,35 @@
package com.muyu.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.TableField;
import com.muyu.server.mapper.TableFieldMapperlimt;
import com.muyu.server.service.TableFieldServicelimt;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Authoryang
* @Packagecom.muyu.server.service.impl
* @Projectcloud-property
* @nameTableFieldServicelimtImpl
* @Date2024/8/23 20:17
*/
@Service
public class TableFieldServicelimtImpl
extends ServiceImpl<TableFieldMapperlimt, TableField>
implements TableFieldServicelimt {
@Override
public List<TableField> selectOrderPayByAppCodeAndLimit(String fieId, int limit) {
LambdaQueryWrapper<TableField> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
objectLambdaQueryWrapper.eq(TableField::getFieId, fieId);
objectLambdaQueryWrapper.orderBy(true,false,TableField::getFieId);
objectLambdaQueryWrapper.last("limit "+limit);
return this.list(objectLambdaQueryWrapper);
}
}