Showing
13 changed files
with
727 additions
and
0 deletions
| ... | ... | @@ -25,4 +25,18 @@ create table if not exists base_data_office ( |
| 25 | 25 | update_by varchar(32) not null comment '更新人', |
| 26 | 26 | create_time datetime default now() comment '创建时间', |
| 27 | 27 | update_time datetime default now() comment '更新时间' |
| 28 | +); | |
| 29 | + | |
| 30 | +create table if not exists base_data_type ( | |
| 31 | + id varchar(32) primary key comment 'ID', | |
| 32 | + code varchar(20) not null comment '编号', | |
| 33 | + name varchar(50) not null comment '名称', | |
| 34 | + description varchar(100) comment '描述', | |
| 35 | + type varchar(20) not null comment '类型:客户(CUSTOMER)', | |
| 36 | + create_by_id varchar(32) not null comment '创建人ID', | |
| 37 | + create_by varchar(32) not null comment '创建人', | |
| 38 | + update_by_id varchar(32) not null comment '更新人ID', | |
| 39 | + update_by varchar(32) not null comment '更新人', | |
| 40 | + create_time datetime default now() comment '创建时间', | |
| 41 | + update_time datetime default now() comment '更新时间' | |
| 28 | 42 | ); |
| \ No newline at end of file | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/type/GetTypeInfoBo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.bo.type; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 4 | +import com.lframework.xingyun.basedata.entity.TypeInfo; | |
| 5 | +import com.lframework.starter.common.constants.StringPool; | |
| 6 | +import com.lframework.starter.web.core.bo.BaseBo; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | +import io.swagger.annotations.ApiModelProperty; | |
| 9 | + | |
| 10 | +import lombok.Data; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * <p> | |
| 14 | + * 类型信息 GetBo | |
| 15 | + * </p> | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +@Data | |
| 19 | +public class GetTypeInfoBo extends BaseBo<TypeInfo> { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * ID | |
| 23 | + */ | |
| 24 | + @ApiModelProperty("ID") | |
| 25 | + private String id; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 编号 | |
| 29 | + */ | |
| 30 | + @ApiModelProperty("编号") | |
| 31 | + private String code; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 名称 | |
| 35 | + */ | |
| 36 | + @ApiModelProperty("名称") | |
| 37 | + private String name; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 类型 | |
| 41 | + */ | |
| 42 | + @ApiModelProperty("类型") | |
| 43 | + private String type; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 描述 | |
| 47 | + */ | |
| 48 | + @ApiModelProperty("描述") | |
| 49 | + private String description; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 创建人 | |
| 53 | + */ | |
| 54 | + @ApiModelProperty("创建人") | |
| 55 | + private String createBy; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 更新人 | |
| 59 | + */ | |
| 60 | + @ApiModelProperty("更新人") | |
| 61 | + private String updateBy; | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 创建时间 | |
| 65 | + */ | |
| 66 | + @ApiModelProperty("创建时间") | |
| 67 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | |
| 68 | + private LocalDateTime createTime; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 更新时间 | |
| 72 | + */ | |
| 73 | + @ApiModelProperty("更新时间") | |
| 74 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | |
| 75 | + private LocalDateTime updateTime; | |
| 76 | + | |
| 77 | + public GetTypeInfoBo() { | |
| 78 | + | |
| 79 | + } | |
| 80 | + | |
| 81 | + public GetTypeInfoBo(TypeInfo dto) { | |
| 82 | + super(dto); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public BaseBo<TypeInfo> convert(TypeInfo dto) { | |
| 87 | + return super.convert(dto); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + protected void afterInit(TypeInfo dto) { | |
| 92 | + if (dto.getType() != null) { | |
| 93 | + this.type = dto.getType().getCode(); | |
| 94 | + } | |
| 95 | + } | |
| 96 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/controller/TypeInfoController.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.controller; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | |
| 4 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | |
| 5 | +import com.lframework.xingyun.basedata.bo.type.GetTypeInfoBo; | |
| 6 | +import com.lframework.xingyun.basedata.vo.type.QueryTypeInfoVo; | |
| 7 | +import com.lframework.xingyun.basedata.service.type.TypeInfoService; | |
| 8 | +import com.lframework.xingyun.basedata.vo.type.CreateTypeInfoVo; | |
| 9 | +import com.lframework.xingyun.basedata.vo.type.UpdateTypeInfoVo; | |
| 10 | +import com.lframework.xingyun.basedata.entity.TypeInfo; | |
| 11 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 12 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 13 | +import com.lframework.starter.web.core.components.resp.InvokeResult; | |
| 14 | + | |
| 15 | +import javax.annotation.Resource; | |
| 16 | +import javax.validation.constraints.NotBlank; | |
| 17 | +import io.swagger.annotations.ApiImplicitParam; | |
| 18 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | |
| 19 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | |
| 20 | +import io.swagger.annotations.ApiOperation; | |
| 21 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 22 | +import io.swagger.annotations.Api; | |
| 23 | +import org.springframework.web.bind.annotation.DeleteMapping; | |
| 24 | +import org.springframework.validation.annotation.Validated; | |
| 25 | +import org.springframework.web.bind.annotation.*; | |
| 26 | + | |
| 27 | +import javax.validation.Valid; | |
| 28 | +import java.util.List; | |
| 29 | +import java.util.stream.Collectors; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * 类型信息 Controller | |
| 33 | + * | |
| 34 | + */ | |
| 35 | +@Api(tags = "类型信息") | |
| 36 | +@Validated | |
| 37 | +@RestController | |
| 38 | +@RequestMapping("/baseData/type") | |
| 39 | +public class TypeInfoController extends DefaultBaseController { | |
| 40 | + | |
| 41 | + | |
| 42 | + @Resource | |
| 43 | + private TypeInfoService typeInfoService; | |
| 44 | + | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 查询列表 | |
| 48 | + */ | |
| 49 | + @ApiOperation("查询列表") | |
| 50 | + @HasPermission({"base-data:type:query"}) | |
| 51 | + @GetMapping("/query") | |
| 52 | + public InvokeResult<PageResult<GetTypeInfoBo>> query(@Valid QueryTypeInfoVo vo) { | |
| 53 | + PageResult<TypeInfo> pageResult = typeInfoService.query(getPageIndex(vo), getPageSize(vo), vo); | |
| 54 | + List<TypeInfo> dataList = pageResult.getDatas(); | |
| 55 | + List<GetTypeInfoBo> results = null; | |
| 56 | + if (!CollectionUtil.isEmpty(dataList)) { | |
| 57 | + results = dataList.stream().map(GetTypeInfoBo::new).collect(Collectors.toList()); | |
| 58 | + } | |
| 59 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 根据ID查询 | |
| 64 | + */ | |
| 65 | + @ApiOperation("根据ID查询") | |
| 66 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | |
| 67 | + @HasPermission({"base-data:type:query"}) | |
| 68 | + @GetMapping | |
| 69 | + public InvokeResult<GetTypeInfoBo> get(@NotBlank(message = "id不能为空!") String id) { | |
| 70 | + TypeInfo data = typeInfoService.findById(id); | |
| 71 | + if (data == null) { | |
| 72 | + throw new DefaultClientException("类型信息不存在!"); | |
| 73 | + } | |
| 74 | + GetTypeInfoBo result = new GetTypeInfoBo(data); | |
| 75 | + | |
| 76 | + return InvokeResultBuilder.success(result); | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 新增 | |
| 81 | + */ | |
| 82 | + @ApiOperation("新增") | |
| 83 | + @HasPermission({"base-data:type:add"}) | |
| 84 | + @PostMapping | |
| 85 | + public InvokeResult<Void> create(@Valid CreateTypeInfoVo vo) { | |
| 86 | + typeInfoService.create(vo); | |
| 87 | + return InvokeResultBuilder.success(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 修改 | |
| 92 | + */ | |
| 93 | + @ApiOperation("修改") | |
| 94 | + @HasPermission({"type:type:modify"}) | |
| 95 | + @PutMapping | |
| 96 | + public InvokeResult<Void> update(@Valid UpdateTypeInfoVo vo) { | |
| 97 | + typeInfoService.update(vo); | |
| 98 | + return InvokeResultBuilder.success(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 根据ID删除 | |
| 103 | + */ | |
| 104 | + @ApiOperation("根据ID删除") | |
| 105 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | |
| 106 | + @HasPermission({"base-data:type:delete"}) | |
| 107 | + @DeleteMapping | |
| 108 | + public InvokeResult<Void> deleteById(@NotBlank(message = "id不能为空!") String id) { | |
| 109 | + typeInfoService.deleteById(id); | |
| 110 | + return InvokeResultBuilder.success(); | |
| 111 | + } | |
| 112 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.basedata.entity; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 4 | +import com.lframework.starter.web.core.dto.BaseDto; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | +import com.baomidou.mybatisplus.annotation.FieldFill; | |
| 8 | +import com.lframework.starter.web.core.entity.BaseEntity; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 10 | +import com.lframework.xingyun.basedata.enums.TypeEnums; | |
| 11 | +import lombok.Data; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * <p> | |
| 15 | + * 类型信息 | |
| 16 | + * </p> | |
| 17 | + * | |
| 18 | + */ | |
| 19 | +@Data | |
| 20 | +@TableName("base_data_type") | |
| 21 | +public class TypeInfo extends BaseEntity implements BaseDto { | |
| 22 | + | |
| 23 | + private static final long serialVersionUID = 1L; | |
| 24 | + | |
| 25 | + public static final String CACHE_NAME = "TypeInfo"; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * ID | |
| 29 | + */ | |
| 30 | + private String id; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 编号 | |
| 34 | + */ | |
| 35 | + private String code; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 名称 | |
| 39 | + */ | |
| 40 | + private String name; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 描述 | |
| 44 | + */ | |
| 45 | + private String description; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 类型 | |
| 49 | + * CUSTOMER:客户 | |
| 50 | + */ | |
| 51 | + private TypeEnums type; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 创建人ID | |
| 55 | + */ | |
| 56 | + @TableField(fill = FieldFill.INSERT) | |
| 57 | + private String createById; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 创建人 | |
| 61 | + */ | |
| 62 | + @TableField(fill = FieldFill.INSERT) | |
| 63 | + private String createBy; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 更新人ID | |
| 67 | + */ | |
| 68 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 69 | + private String updateById; | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 更新人 | |
| 73 | + */ | |
| 74 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 75 | + private String updateBy; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 创建时间 | |
| 79 | + */ | |
| 80 | + @TableField(fill = FieldFill.INSERT) | |
| 81 | + private LocalDateTime createTime; | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 更新时间 | |
| 85 | + */ | |
| 86 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 87 | + private LocalDateTime updateTime; | |
| 88 | + | |
| 89 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.basedata.enums; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.EnumValue; | |
| 4 | +import com.lframework.starter.web.core.enums.BaseEnum; | |
| 5 | + | |
| 6 | +public enum TypeEnums implements BaseEnum<String> { | |
| 7 | + | |
| 8 | + PRO("CUSTOMER", "客户"); | |
| 9 | + | |
| 10 | + @EnumValue | |
| 11 | + private final String code; | |
| 12 | + | |
| 13 | + private final String desc; | |
| 14 | + | |
| 15 | + TypeEnums(String code, String desc) { | |
| 16 | + this.code = code; | |
| 17 | + this.desc = desc; | |
| 18 | + } | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public String getCode() { | |
| 22 | + return this.code; | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public String getDesc() { | |
| 27 | + return this.desc; | |
| 28 | + } | |
| 29 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/type/TypeInfoServiceImpl.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.impl.type; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 5 | +import com.github.pagehelper.PageInfo; | |
| 6 | +import com.lframework.xingyun.basedata.entity.TypeInfo; | |
| 7 | +import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 10 | +import com.lframework.xingyun.basedata.enums.TypeEnums; | |
| 11 | +import com.lframework.starter.web.core.utils.OpLogUtil; | |
| 12 | +import com.lframework.starter.common.utils.StringUtil; | |
| 13 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | |
| 14 | +import com.lframework.starter.web.core.utils.EnumUtil; | |
| 15 | +import com.lframework.starter.web.core.utils.IdUtil; | |
| 16 | +import com.lframework.starter.common.utils.ObjectUtil; | |
| 17 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | |
| 18 | +import com.lframework.starter.web.core.utils.PageHelperUtil; | |
| 19 | +import com.lframework.starter.common.utils.Assert; | |
| 20 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | |
| 21 | +import com.lframework.xingyun.basedata.mappers.TypeInfoMapper; | |
| 22 | +import com.lframework.xingyun.basedata.service.type.TypeInfoService; | |
| 23 | +import com.lframework.xingyun.basedata.vo.type.CreateTypeInfoVo; | |
| 24 | +import com.lframework.xingyun.basedata.vo.type.QueryTypeInfoVo; | |
| 25 | +import com.lframework.xingyun.basedata.vo.type.UpdateTypeInfoVo; | |
| 26 | +import org.springframework.cache.annotation.Cacheable; | |
| 27 | +import org.springframework.stereotype.Service; | |
| 28 | +import org.springframework.transaction.annotation.Transactional; | |
| 29 | + | |
| 30 | +import java.util.List; | |
| 31 | + | |
| 32 | +@Service | |
| 33 | +public class TypeInfoServiceImpl extends BaseMpServiceImpl<TypeInfoMapper, TypeInfo> implements TypeInfoService { | |
| 34 | + | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 分页查询 | |
| 38 | + * | |
| 39 | + * @param pageIndex 分页页码 | |
| 40 | + * @param pageSize 分页大小 | |
| 41 | + * @param vo 查询条件 | |
| 42 | + * @return PageResult<TypeInfo> | |
| 43 | + */ | |
| 44 | + @Override | |
| 45 | + public PageResult<TypeInfo> query(Integer pageIndex, Integer pageSize, QueryTypeInfoVo vo) { | |
| 46 | + Assert.greaterThanZero(pageIndex); | |
| 47 | + Assert.greaterThanZero(pageSize); | |
| 48 | + PageHelperUtil.startPage(pageIndex, pageSize); | |
| 49 | + List<TypeInfo> dataList = this.query(vo); | |
| 50 | + | |
| 51 | + return PageResultUtil.convert(new PageInfo<>(dataList)); | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 查询列表 | |
| 56 | + * | |
| 57 | + * @param vo 查询条件 | |
| 58 | + * @return List<TypeInfo> | |
| 59 | + */ | |
| 60 | + @Override | |
| 61 | + public List<TypeInfo> query(QueryTypeInfoVo vo) { | |
| 62 | + return getBaseMapper().query(vo); | |
| 63 | + } | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 根据主键ID查询 | |
| 67 | + * | |
| 68 | + * @param id 主键ID | |
| 69 | + * @return TypeInfo | |
| 70 | + */ | |
| 71 | + @Cacheable(value = TypeInfo.CACHE_NAME, key = "@cacheVariables.tenantId() + #id", unless = "#result == null") | |
| 72 | + @Override | |
| 73 | + public TypeInfo findById(String id) { | |
| 74 | + return getBaseMapper().selectById(id); | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 新增 | |
| 79 | + * | |
| 80 | + * @param vo 数据实体 | |
| 81 | + * @return String | |
| 82 | + */ | |
| 83 | + @OpLog(type = OtherOpLogType.class, name = "新增类型信息,ID:{}", params = {"#id"}) | |
| 84 | + @Transactional(rollbackFor = Exception.class) | |
| 85 | + @Override | |
| 86 | + public String create(CreateTypeInfoVo vo) { | |
| 87 | + TypeInfo data = new TypeInfo(); | |
| 88 | + data.setId(IdUtil.getId()); | |
| 89 | + data.setCode(vo.getCode()); | |
| 90 | + data.setName(vo.getName()); | |
| 91 | + data.setType(EnumUtil.getByCode(TypeEnums.class, vo.getType())); | |
| 92 | + if (!StringUtil.isBlank(vo.getDescription())) { | |
| 93 | + data.setDescription(vo.getDescription()); | |
| 94 | + } | |
| 95 | + getBaseMapper().insert(data); | |
| 96 | + | |
| 97 | + OpLogUtil.setVariable("id", data.getId()); | |
| 98 | + OpLogUtil.setExtra(vo); | |
| 99 | + return data.getId(); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 修改 | |
| 104 | + * | |
| 105 | + * @param vo 数据实体 | |
| 106 | + */ | |
| 107 | + @OpLog(type = OtherOpLogType.class, name = "修改类型信息,ID:{}", params = {"#id"}) | |
| 108 | + @Transactional(rollbackFor = Exception.class) | |
| 109 | + @Override | |
| 110 | + public void update(UpdateTypeInfoVo vo) { | |
| 111 | + TypeInfo data = getBaseMapper().selectById(vo.getId()); | |
| 112 | + if (ObjectUtil.isNull(data)) { | |
| 113 | + throw new DefaultClientException("类型信息不存在!"); | |
| 114 | + } | |
| 115 | + LambdaUpdateWrapper<TypeInfo> updateWrapper = Wrappers.lambdaUpdate(TypeInfo.class) | |
| 116 | + .set(TypeInfo::getCode, data.getCode()) | |
| 117 | + .set(TypeInfo::getName, vo.getName()) | |
| 118 | + .set(TypeInfo::getType, data.getType()) | |
| 119 | + .set(TypeInfo::getDescription, StringUtil.isBlank(vo.getDescription()) ? null : vo.getDescription()) | |
| 120 | + .eq(TypeInfo::getId, vo.getId()); | |
| 121 | + getBaseMapper().update(updateWrapper); | |
| 122 | + | |
| 123 | + OpLogUtil.setVariable("id", data.getId()); | |
| 124 | + OpLogUtil.setExtra(vo); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * 根据主键ID删除 | |
| 129 | + * | |
| 130 | + * @param id 主键ID | |
| 131 | + */ | |
| 132 | + @OpLog(type = OtherOpLogType.class, name = "删除类型信息,ID:{}", params = {"#id"}) | |
| 133 | + @Transactional(rollbackFor = Exception.class) | |
| 134 | + @Override | |
| 135 | + public void deleteById(String id) { | |
| 136 | + getBaseMapper().deleteById(id); | |
| 137 | + } | |
| 138 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/mappers/TypeInfoMapper.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.mappers; | |
| 2 | + | |
| 3 | +import com.lframework.xingyun.basedata.entity.TypeInfo; | |
| 4 | +import com.lframework.starter.web.core.mapper.BaseMapper; | |
| 5 | +import com.lframework.xingyun.basedata.vo.type.QueryTypeInfoVo; | |
| 6 | +import org.apache.ibatis.annotations.Param; | |
| 7 | + | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * <p> | |
| 12 | + * 类型信息 Mapper 接口 | |
| 13 | + * </p> | |
| 14 | + * | |
| 15 | + */ | |
| 16 | +public interface TypeInfoMapper extends BaseMapper<TypeInfo> { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 查询列表 | |
| 20 | + * @param vo | |
| 21 | + * @return | |
| 22 | + */ | |
| 23 | + List<TypeInfo> query(@Param("vo") QueryTypeInfoVo vo); | |
| 24 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/service/type/TypeInfoService.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.service.type; | |
| 2 | + | |
| 3 | +import com.lframework.xingyun.basedata.vo.type.CreateTypeInfoVo; | |
| 4 | +import com.lframework.xingyun.basedata.vo.type.QueryTypeInfoVo; | |
| 5 | +import com.lframework.xingyun.basedata.vo.type.UpdateTypeInfoVo; | |
| 6 | +import com.lframework.xingyun.basedata.entity.TypeInfo; | |
| 7 | +import com.lframework.starter.web.core.service.BaseMpService; | |
| 8 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 类型信息 Service | |
| 13 | + */ | |
| 14 | +public interface TypeInfoService extends BaseMpService<TypeInfo> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 分页查询 | |
| 18 | + * | |
| 19 | + * @return PageResult<TypeInfo> | |
| 20 | + */ | |
| 21 | + PageResult<TypeInfo> query(Integer pageIndex, Integer pageSize, QueryTypeInfoVo vo); | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 查询列表 | |
| 25 | + * | |
| 26 | + * @param vo 查询条件 | |
| 27 | + * @return List<TypeInfo> | |
| 28 | + */ | |
| 29 | + List<TypeInfo> query(QueryTypeInfoVo vo); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 根据ID查询 | |
| 33 | + * | |
| 34 | + * @param id 主键ID | |
| 35 | + * @return TypeInfo | |
| 36 | + */ | |
| 37 | + TypeInfo findById(String id); | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 创建 | |
| 41 | + * | |
| 42 | + * @param vo 数据实体 | |
| 43 | + * @return String | |
| 44 | + */ | |
| 45 | + String create(CreateTypeInfoVo vo); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 修改 | |
| 49 | + * | |
| 50 | + * @param vo 数据实体 | |
| 51 | + */ | |
| 52 | + void update(UpdateTypeInfoVo vo); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 根据主键ID删除 | |
| 56 | + * | |
| 57 | + * @param id 主键ID | |
| 58 | + */ | |
| 59 | + void deleteById(String id); | |
| 60 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/vo/type/CreateTypeInfoVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.vo.type; | |
| 2 | + | |
| 3 | +import com.lframework.starter.web.core.components.validation.IsEnum; | |
| 4 | +import javax.validation.constraints.NotBlank; | |
| 5 | +import com.lframework.xingyun.basedata.enums.TypeEnums; | |
| 6 | +import com.lframework.starter.web.core.vo.BaseVo; | |
| 7 | +import io.swagger.annotations.ApiModelProperty; | |
| 8 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | |
| 9 | +import org.hibernate.validator.constraints.Length; | |
| 10 | +import java.io.Serializable; | |
| 11 | +import lombok.Data; | |
| 12 | + | |
| 13 | +@Data | |
| 14 | +public class CreateTypeInfoVo implements BaseVo, Serializable { | |
| 15 | + | |
| 16 | + private static final long serialVersionUID = 1L; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 编号 | |
| 20 | + */ | |
| 21 | + @ApiModelProperty(value = "编号", required = true) | |
| 22 | + @NotBlank(message = "请输入编号!") | |
| 23 | + @Length(message = "编号最多允许20个字符!") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 名称 | |
| 28 | + */ | |
| 29 | + @ApiModelProperty(value = "名称", required = true) | |
| 30 | + @NotBlank(message = "请输入名称!") | |
| 31 | + @Length(message = "名称最多允许50个字符!") | |
| 32 | + private String name; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 类型 | |
| 36 | + */ | |
| 37 | + @ApiModelProperty(value = "类型", required = true) | |
| 38 | + @NotBlank(message = "请选择类型!") | |
| 39 | + @IsEnum(message = "请选择类型!", enumClass = TypeEnums.class) | |
| 40 | + @TypeMismatch(message = "类型格式有误!") | |
| 41 | + private String type; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 描述 | |
| 45 | + */ | |
| 46 | + @ApiModelProperty("描述") | |
| 47 | + @Length(message = "描述最多允许100个字符!") | |
| 48 | + private String description; | |
| 49 | + | |
| 50 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/vo/type/QueryTypeInfoVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.vo.type; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import com.lframework.starter.web.core.vo.PageVo; | |
| 5 | +import com.lframework.starter.web.core.vo.BaseVo; | |
| 6 | +import io.swagger.annotations.ApiModelProperty; | |
| 7 | +import java.io.Serializable; | |
| 8 | + | |
| 9 | +@Data | |
| 10 | +public class QueryTypeInfoVo extends PageVo implements BaseVo, Serializable { | |
| 11 | + | |
| 12 | + private static final long serialVersionUID = 1L; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 编号 | |
| 16 | + */ | |
| 17 | + @ApiModelProperty("编号") | |
| 18 | + private String code; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 名称 | |
| 22 | + */ | |
| 23 | + @ApiModelProperty("名称") | |
| 24 | + private String name; | |
| 25 | + | |
| 26 | +} | ... | ... |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/vo/type/UpdateTypeInfoVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.vo.type; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import javax.validation.constraints.NotBlank; | |
| 5 | +import com.lframework.starter.web.core.vo.BaseVo; | |
| 6 | +import io.swagger.annotations.ApiModelProperty; | |
| 7 | +import org.hibernate.validator.constraints.Length; | |
| 8 | +import java.io.Serializable; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +public class UpdateTypeInfoVo implements BaseVo, Serializable { | |
| 12 | + | |
| 13 | + private static final long serialVersionUID = 1L; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * ID | |
| 17 | + */ | |
| 18 | + @ApiModelProperty(value = "ID", required = true) | |
| 19 | + @NotBlank(message = "id不能为空!") | |
| 20 | + private String id; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 名称 | |
| 24 | + */ | |
| 25 | + @ApiModelProperty(value = "名称", required = true) | |
| 26 | + @NotBlank(message = "请输入名称!") | |
| 27 | + @Length(message = "名称最多允许50个字符!") | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 描述 | |
| 32 | + */ | |
| 33 | + @ApiModelProperty("描述") | |
| 34 | + @Length(message = "描述最多允许100个字符!") | |
| 35 | + private String description; | |
| 36 | + | |
| 37 | +} | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.lframework.xingyun.basedata.mappers.TypeInfoMapper"> | |
| 4 | + | |
| 5 | + <resultMap id="TypeInfo" type="com.lframework.xingyun.basedata.entity.TypeInfo"> | |
| 6 | + <id column="id" property="id"/> | |
| 7 | + <result column="code" property="code"/> | |
| 8 | + <result column="name" property="name"/> | |
| 9 | + <result column="description" property="description"/> | |
| 10 | + <result column="type" property="type"/> | |
| 11 | + <result column="create_by_id" property="createById"/> | |
| 12 | + <result column="create_by" property="createBy"/> | |
| 13 | + <result column="update_by_id" property="updateById"/> | |
| 14 | + <result column="update_by" property="updateBy"/> | |
| 15 | + <result column="create_time" property="createTime"/> | |
| 16 | + <result column="update_time" property="updateTime"/> | |
| 17 | + </resultMap> | |
| 18 | + | |
| 19 | + <sql id="TypeInfo_sql"> | |
| 20 | + SELECT | |
| 21 | + tb.id, | |
| 22 | + tb.code, | |
| 23 | + tb.name, | |
| 24 | + tb.description, | |
| 25 | + tb.type, | |
| 26 | + tb.create_by_id, | |
| 27 | + tb.create_by, | |
| 28 | + tb.update_by_id, | |
| 29 | + tb.update_by, | |
| 30 | + tb.create_time, | |
| 31 | + tb.update_time | |
| 32 | + FROM base_data_type AS tb | |
| 33 | + </sql> | |
| 34 | + | |
| 35 | + <select id="query" resultMap="TypeInfo"> | |
| 36 | + <include refid="TypeInfo_sql"/> | |
| 37 | + <where> | |
| 38 | + <if test="vo.code != null and vo.code != ''"> | |
| 39 | + AND tb.code LIKE CONCAT('%', #{vo.code}, '%') | |
| 40 | + </if> | |
| 41 | + <if test="vo.name != null and vo.name != ''"> | |
| 42 | + AND tb.name LIKE CONCAT('%', #{vo.name}, '%') | |
| 43 | + </if> | |
| 44 | + </where> | |
| 45 | + </select> | |
| 46 | +</mapper> | ... | ... |