Structure增删改查
parent
b7cc7ebf46
commit
ae09371cef
|
@ -0,0 +1,91 @@
|
|||
package com.muyu.common.domian;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.domian.resp.StructureResp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value ="structure",autoResultMap = true) //数据库表相关
|
||||
public class Structure extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 表id */
|
||||
@Excel(name = "表id")
|
||||
private Long tableId;
|
||||
|
||||
/** 字段名称 */
|
||||
@Excel(name = "字段名称")
|
||||
private String columnName;
|
||||
|
||||
/** 字段注释 */
|
||||
@Excel(name = "字段注释")
|
||||
private String columnRemark;
|
||||
|
||||
/** 是否主键 'Y'是主键 'N'不是主键 */
|
||||
@Excel(name = "是否主键 'Y'是主键 'N'不是主键")
|
||||
private String isPrimary;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String columnType;
|
||||
|
||||
/** 映射类型 */
|
||||
@Excel(name = "映射类型")
|
||||
private String javaType;
|
||||
|
||||
/** 字段长度 */
|
||||
@Excel(name = "字段长度")
|
||||
private String columnLength;
|
||||
|
||||
/** 小数位数 */
|
||||
@Excel(name = "小数位数")
|
||||
private String columnDecimals;
|
||||
|
||||
/** 是否为空 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否为空 'Y'是 'N'不是")
|
||||
private String isNull;
|
||||
|
||||
/** 默认值 */
|
||||
@Excel(name = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/** 是否字典 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否字典 'Y'是 'N'不是")
|
||||
private String isDictionary;
|
||||
|
||||
/** 映射字典 */
|
||||
@Excel(name = "映射字典")
|
||||
private String dictionaryTable;
|
||||
|
||||
public static StructureResp toBuild(Structure structure,String tableAsName){
|
||||
return StructureResp.builder()
|
||||
.id(structure.id)
|
||||
.tableId(structure.tableId)
|
||||
.columnRemark(structure.columnRemark)
|
||||
.columnName(structure.columnName)
|
||||
.columnType(structure.columnType)
|
||||
.isPrimary(structure.isPrimary)
|
||||
.tableAsName(tableAsName+"_"+structure.columnName)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.common.domian.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StructureReq {
|
||||
|
||||
/**
|
||||
* 表id
|
||||
*/
|
||||
private Long tableId;
|
||||
/**
|
||||
* 表别名
|
||||
*/
|
||||
private String tableAsName;
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.common.domian.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StructureResp {
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 表id */
|
||||
@Excel(name = "表id")
|
||||
private Long tableId;
|
||||
|
||||
/** 字段名称 */
|
||||
@Excel(name = "字段名称")
|
||||
private String columnName;
|
||||
|
||||
/** 字段注释 */
|
||||
@Excel(name = "字段注释")
|
||||
private String columnRemark;
|
||||
|
||||
/** 是否主键 'Y'是主键 'N'不是主键 */
|
||||
@Excel(name = "是否主键 'Y'是主键 'N'不是主键")
|
||||
private String isPrimary;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableAsName;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.task.server.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import com.muyu.common.domian.Structure;
|
||||
import com.muyu.common.domian.resp.StructureResp;
|
||||
import com.muyu.task.server.service.StructureService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("structure")
|
||||
public class StructureController {
|
||||
|
||||
@Autowired
|
||||
private StructureService structureService;
|
||||
|
||||
@PostMapping("/findByTableId")
|
||||
public Result findByTableId(@RequestParam("tableId") Long tableId,@RequestParam("tableAsName") String tableAsName) {
|
||||
LambdaQueryWrapper<Structure> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Structure::getTableId, tableId);
|
||||
List<Structure> list = structureService.list(wrapper);
|
||||
return Result.success(list.stream().map(structure -> Structure.toBuild(structure, tableAsName)).toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.task.server.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.domian.Structure;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface StructureMapper extends BaseMapper<Structure> {
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.muyu.task.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.domian.Structure;
|
||||
|
||||
|
||||
public interface StructureService extends IService<Structure> {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.muyu.task.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.domian.Structure;
|
||||
import com.muyu.task.server.mapper.StructureMapper;
|
||||
import com.muyu.task.server.service.StructureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure> implements StructureService {
|
||||
}
|
Loading…
Reference in New Issue