数据字段增删改查
parent
1a073d19c5
commit
17fe0c5adf
|
@ -11,10 +11,11 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.muyu.server.pojo
|
||||
* @Package:com.muyu.server.pojo 数据源数据库初始化
|
||||
* @Project:cloud-integration
|
||||
* @name:DataSourceList
|
||||
* @Date:2024/8/20 18:47
|
||||
|
@ -25,53 +26,51 @@ import java.util.Date;
|
|||
@TableName(value = "data_source")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
//核心数据库初始化
|
||||
//
|
||||
public class DataSourceInfo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键/编号
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private String id ;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name ;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String cardNo ;
|
||||
private String descriot ;
|
||||
private String ctfTp ;
|
||||
private String ctfId ;
|
||||
private String gender ;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
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 ;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 征信状态
|
||||
*/
|
||||
private String credit;
|
||||
|
||||
// public static DataSourceList updBuild(DataSourceList dataSourceList, Supplier<Long> idSupplier) {
|
||||
// return DataSourceList.builder()
|
||||
// .id(idSupplier.get())
|
||||
// .name(dataSourceList.getName())
|
||||
// .gender(dataSourceList.getGender())
|
||||
// .
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@ package com.muyu.common.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 lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
|
@ -22,7 +24,8 @@ import java.util.Date;
|
|||
@TableName(value = "data_source")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceList {
|
||||
//核心数据库
|
||||
public class DataSourceList extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键/编号
|
||||
|
@ -70,4 +73,5 @@ public class DataSourceList {
|
|||
*/
|
||||
private String credit;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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:蓬叁
|
||||
* @Package:com.muyu.common.domain
|
||||
* @Project:cloud-integration
|
||||
* @name:InitialData
|
||||
* @Date:2024/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 ;
|
||||
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package com.muyu.common.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.enums.SysPayType;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.domain
|
||||
* @Package:com.muyu.common.domain 元数据字段查询表
|
||||
* @Project:cloud-property
|
||||
* @name:TableField
|
||||
* @Date:2024/8/23 11:39
|
||||
|
@ -21,11 +21,64 @@ import lombok.NoArgsConstructor;
|
|||
@TableName("TableField")
|
||||
public class TableField extends BaseEntity {
|
||||
|
||||
private String fieId;
|
||||
private Long fieId;
|
||||
private String type;
|
||||
private String collation;
|
||||
private String Null;
|
||||
private String key;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@ import com.muyu.common.domain.TableField;
|
|||
import com.muyu.server.service.DataSourceService;
|
||||
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.util.CollectionUtils;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -35,13 +33,22 @@ public class DataSourceController {
|
|||
|
||||
private final TableFieldService tableFieldService;
|
||||
|
||||
|
||||
/**
|
||||
* 抽取数据列表
|
||||
* @param connect 数据实体类
|
||||
* @return 返回试图
|
||||
*/
|
||||
@PostMapping("/extractData")
|
||||
@Operation(summary = "抽取数据",description = "从数据源中抽取数据")
|
||||
public Result<List<DataSourceList>> extractData(@RequestBody Connect connect){
|
||||
return Result.success(dataSourceService.extractData(connect),"您的数据已成功获取");
|
||||
}
|
||||
|
||||
/**
|
||||
* 抽取结构
|
||||
* @param connect 实体类
|
||||
* @return 返回试图
|
||||
*/
|
||||
@PostMapping("/tableField")
|
||||
@Operation(summary = "抽取结构",description = "从数据源中抽取结构")
|
||||
public Result<String> extractTableField(@RequestBody Connect connect){
|
||||
|
@ -55,4 +62,20 @@ public class DataSourceController {
|
|||
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,"您的数据已成功获取");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.server.controller
|
||||
* @Project:cloud-property
|
||||
* @name:TableFieldController
|
||||
* @Date:2024/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,"操作成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.server.mapper
|
||||
* @Project:cloud-property
|
||||
* @name:TableFieldMapperlimt
|
||||
* @Date:2024/8/23 20:18
|
||||
*/
|
||||
@Mapper
|
||||
public interface TableFieldMapperlimt extends BaseMapper<TableField> {
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.muyu.common.domain.TableField;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
|
@ -13,4 +14,10 @@ import java.util.ArrayList;
|
|||
* @Date:2024/8/23 14:00
|
||||
*/
|
||||
public interface TableFieldService extends IService<TableField> {
|
||||
/**
|
||||
* 查询所有数据字段
|
||||
* @param tableField 所有数据字段列表请求参数
|
||||
* @return 数据字段列表
|
||||
*/
|
||||
List<TableField> selectList(TableField tableField);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.server.service
|
||||
* @Project:cloud-property
|
||||
* @name:TableFieldServicelimt
|
||||
* @Date:2024/8/23 20:16
|
||||
*/
|
||||
public interface TableFieldServicelimt extends IService<TableField> {
|
||||
/**
|
||||
* 根据客户code和分页限制,查询结果
|
||||
* @param fieId 客户code
|
||||
* @param limit 分页限制
|
||||
* @return 支付结果记录
|
||||
*/
|
||||
List<TableField> selectOrderPayByAppCodeAndLimit(String fieId, int limit);
|
||||
}
|
|
@ -1,12 +1,16 @@
|
|||
package com.muyu.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.domain.TableField;
|
||||
import com.muyu.server.mapper.TableFieldMapper;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
|
@ -20,4 +24,31 @@ public class TableFieldServiceImpl
|
|||
extends ServiceImpl<TableFieldMapper,TableField>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.server.service.impl
|
||||
* @Project:cloud-property
|
||||
* @name:TableFieldServicelimtImpl
|
||||
* @Date:2024/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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue