【SpringBoot整合MybatisPlus基本的增删改查,保姆级教程】@TableField 是mybatisplus中的一个注解,后面会讲解到的 。基础实体类创建好了,接着我们把剩下的两个实体类也一同创建吧 。
5|2SysDictType实体类
package com.didiplus.modules.sys.domain;import com.didiplus.common.base.BaseDomain;import com.didiplus.common.base.ValidGroup;import io.swagger.annotations.ApiModel;import io.swagger.annotations.ApiModelProperty;import lombok.Data;import javax.validation.constraints.*;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/25 * Desc: 字典类型领域模型 */@Data@ApiModel(value = https://www.isolves.com/it/cxkf/jiagou/2022-05-05/"字典类型")public class SysDictType extends BaseDomain {/*** 标识*/@Null(groups = ValidGroup.Crud.Create.class)@NotNull(groups = ValidGroup.Crud.Update.class,message = "字典ID不能为空")@ApiModelProperty("ID")private String id;/*** 字典名称*/@NotBlank(message = "字典名称必填项")@ApiModelProperty(value = "字典名称",example = "用户ID")private String typeName;/*** 字典类型*/@NotBlank(message = "字典编码不能为空")@ApiModelProperty(value = "字典编码")private String typeCode;/*** 字典描述*/@ApiModelProperty(value = "字典描述")private String description;/*** 字典可用状态*/@NotBlank(message = "字典状态不能为空")@ApiModelProperty(value = "字典状态")private Boolean enable;}
5|3SysDictData实体类package com.didiplus.modules.sys.domain;import com.baomidou.mybatisplus.annotation.TableField;import com.didiplus.common.base.BaseDomain;import com.didiplus.common.base.ValidGroup;import io.swagger.annotations.ApiModelProperty;import lombok.Data;import javax.validation.constraints.NotBlank;import javax.validation.constraints.NotNull;import javax.validation.constraints.Null;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: 字典值领域模型 */@Datapublic class SysDictData extends BaseDomain {/*** id 编号*/@Null(groups = ValidGroup.Crud.Create.class)@NotNull(groups = ValidGroup.Crud.Update.class,message = "字典数据ID不能为空")@ApiModelProperty("ID")@TableField(value = https://www.isolves.com/it/cxkf/jiagou/2022-05-05/"data_id")private String dataId;/*** 字典显示*/@NotBlank(message = "字典数据名称必填项")@ApiModelProperty(value = "字典数据名称")private String dataLabel;/*** 字典值*/@NotBlank(message = "字典数据值不能为空")@ApiModelProperty(value = "字典数据值")private String dataValue;/*** 字典类型*/@ApiModelProperty(value = "字典编码")@NotBlank(message = "字典数据值不能为空")private String typeCode;/*** 是否为默认*/@ApiModelProperty(value = "字典编码")@NotBlank(message = "字典数据值不能为空")private String isDefault;/*** 是否启用*/@NotBlank(message = "字典状态不能为空")@ApiModelProperty(value = "字典数据状态")private Boolean enable;}
6|0创建DAO继承MybatisPlus增强接口为两个实体类中分别添加DAO继承MybatisPlus增强接口,这样就可以集成了增删改查的功能了 。6|1SysDictTypeMapper
package com.didiplus.modules.sys.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;import com.didiplus.modules.sys.domain.SysDictType;import org.Apache.ibatis.annotations.Mapper;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: 字典类型接口 */@Mapperpublic interface SysDictTypeMapper extends BaseMapper<SysDictType> {}
6|2SysDictDataMapperpackage com.didiplus.modules.sys.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;import com.didiplus.modules.sys.domain.SysDictData;import org.apache.ibatis.annotations.Mapper;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: 字典数据接口 */@Mapperpublic interface SysDictDataMapper extends BaseMapper<SysDictData> {}
7|0进一步封装到Service层7|1定义Service接口中的抽象方法SysDictDataServicepackage com.didiplus.modules.sys.service;import com.baomidou.mybatisplus.extension.service.IService;import com.didiplus.modules.sys.domain.SysDictData;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: */public interface SysDictDataService extends IService<SysDictData> {}
SysDictTypeServicepackage com.didiplus.modules.sys.service;import com.baomidou.mybatisplus.extension.service.IService;import com.didiplus.modules.sys.domain.SysDictType;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: */public interface SysDictTypeService extends IService<SysDictType> {}
7|2实现Service接口中的方法SysDictTypeServiceImplpackage com.didiplus.modules.sys.service.impl;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import com.didiplus.modules.sys.domain.SysDictType;import com.didiplus.modules.sys.mapper.SysDictTypeMapper;import com.didiplus.modules.sys.service.SysDictTypeService;import org.springframework.stereotype.Service;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: */@Servicepublic class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {}
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 一文讲清楚SpringBoot六种读取配置方式
- SpringBoot整合MybatisPlus数据自动填充
- springcloud 整合openFeign
- 玩转SpringBoot 跨域问题的 3 种方案
- SpringBoot内置Tomcat启动原理源码分析
- 国外服务器部署springboot 项目 出现时区问题
- 效率这不就提上来了嘛!SpringBoot+flowable快速实现工作流
- SpringBoot 如何使用同步锁
- MybatisPlus中实体类属性对应枚举类实现
- Springboot使用OkHttp实现微信支付API-V3签名、证书的管理和使用