直接上代码
看一看就懂了
第一步 实体类,自动生成的不用动
package com.excellent.archimedes.pojo; public class MedicineCareIllness { /** */ private Long id; /** 疾病编码 */ private String illnessCode; /** 疾病名称 */ private String illnessName; /** 对症药编码 */ private String medicineCode; /** 对症药名 */ private String medicineName; /** 使用方法(用法用量) */ private String instruction; /** 缩写编码 */ private String abbreviation; /** 疾病症状 */ private String illnessFeature; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getIllnessCode() { return illnessCode; } public void setIllnessCode(String illnessCode) { this.illnessCode = illnessCode == null ? null : illnessCode.trim(); } public String getIllnessName() { return illnessName; } public void setIllnessName(String illnessName) { this.illnessName = illnessName == null ? null : illnessName.trim(); } public String getMedicineCode() { return medicineCode; } public void setMedicineCode(String medicineCode) { this.medicineCode = medicineCode == null ? null : medicineCode.trim(); } public String getMedicineName() { return medicineName; } public void setMedicineName(String medicineName) { this.medicineName = medicineName == null ? null : medicineName.trim(); } public String getInstruction() { return instruction; } public void setInstruction(String instruction) { this.instruction = instruction == null ? null : instruction.trim(); } public String getAbbreviation() { return abbreviation; } public void setAbbreviation(String abbreviation) { this.abbreviation = abbreviation == null ? null : abbreviation.trim(); } public String getIllnessFeature() { return illnessFeature; } public void setIllnessFeature(String illnessFeature) { this.illnessFeature = illnessFeature == null ? null : illnessFeature.trim(); } }
第二步
自动生成的Example类中要稍加修改,Mapper.xml中也要稍加修改(标红部分)
package com.excellent.archimedes.pojo; import java.util.ArrayList; import java.util.List; public class MedicineCareIllnessExample { protected String orderByClause; protected boolean distinct; protected List<Criteria> oredCriteria; protected String limitClause; public MedicineCareIllnessExample() { oredCriteria = new ArrayList<Criteria>(); } public void setOrderByClause(String orderByClause) { this.orderByClause = orderByClause; } public String getOrderByClause() { return orderByClause; } public String getLimitClause() { return limitClause; } public void setLimitClause(String limitClause) { this.limitClause = limitClause; } public void setDistinct(boolean distinct) { this.distinct = distinct; } public boolean isDistinct() { return distinct; } public List<Criteria> getOredCriteria() { return oredCriteria; } public void or(Criteria criteria) { oredCriteria.add(criteria); } public Criteria or() { Criteria criteria = createCriteriaInternal(); oredCriteria.add(criteria); return criteria; } public Criteria createCriteria() { Criteria criteria = createCriteriaInternal(); if (oredCriteria.size() == 0) { oredCriteria.add(criteria); } return criteria; } protected Criteria createCriteriaInternal() { Criteria criteria = new Criteria(); return criteria; } public void clear() { oredCriteria.clear(); orderByClause = null; distinct = false; } protected abstract static class GeneratedCriteria { protected List<Criterion> criteria; protected GeneratedCriteria() { super(); criteria = new ArrayList<Criterion>(); } public boolean isValid() { return criteria.size() > 0; } public List<Criterion> getAllCriteria() { return criteria; } public List<Criterion> getCriteria() { return criteria; } protected void addCriterion(String condition) { if (condition == null) { throw new RuntimeException("Value for condition cannot be null"); } criteria.add(new Criterion(condition)); } protected void addCriterion(String condition, Object value, String property) { if (value == null) { throw new RuntimeException("Value for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value)); } protected void addCriterion(String condition, Object value1, Object value2, String property) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + property + " cannot be null"); } criteria.add(new Criterion(condition, value1, value2)); } public Criteria andIdIsNull() { addCriterion("id is null"); return (Criteria) this; } public Criteria andIdIsNotNull() { addCriterion("id is not null"); return (Criteria) this; } public Criteria andIdEqualTo(Long value) { addCriterion("id =", value, "id"); return (Criteria) this; } public Criteria andIdNotEqualTo(Long value) { addCriterion("id <>", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThan(Long value) { addCriterion("id >", value, "id"); return (Criteria) this; } public Criteria andIdGreaterThanOrEqualTo(Long value) { addCriterion("id >=", value, "id"); return (Criteria) this; } public Criteria andIdLessThan(Long value) { addCriterion("id <", value, "id"); return (Criteria) this; } public Criteria andIdLessThanOrEqualTo(Long value) { addCriterion("id <=", value, "id"); return (Criteria) this; } public Criteria andIdIn(List<Long> values) { addCriterion("id in", values, "id"); return (Criteria) this; } public Criteria andIdNotIn(List<Long> values) { addCriterion("id not in", values, "id"); return (Criteria) this; } public Criteria andIdBetween(Long value1, Long value2) { addCriterion("id between", value1, value2, "id"); return (Criteria) this; } public Criteria andIdNotBetween(Long value1, Long value2) { addCriterion("id not between", value1, value2, "id"); return (Criteria) this; } public Criteria andIllnessCodeIsNull() { addCriterion("illness_code is null"); return (Criteria) this; } public Criteria andIllnessCodeIsNotNull() { addCriterion("illness_code is not null"); return (Criteria) this; } public Criteria andIllnessCodeEqualTo(String value) { addCriterion("illness_code =", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeNotEqualTo(String value) { addCriterion("illness_code <>", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeGreaterThan(String value) { addCriterion("illness_code >", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeGreaterThanOrEqualTo(String value) { addCriterion("illness_code >=", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeLessThan(String value) { addCriterion("illness_code <", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeLessThanOrEqualTo(String value) { addCriterion("illness_code <=", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeLike(String value) { addCriterion("illness_code like", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeNotLike(String value) { addCriterion("illness_code not like", value, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeIn(List<String> values) { addCriterion("illness_code in", values, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeNotIn(List<String> values) { addCriterion("illness_code not in", values, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeBetween(String value1, String value2) { addCriterion("illness_code between", value1, value2, "illnessCode"); return (Criteria) this; } public Criteria andIllnessCodeNotBetween(String value1, String value2) { addCriterion("illness_code not between", value1, value2, "illnessCode"); return (Criteria) this; } public Criteria andIllnessNameIsNull() { addCriterion("illness_name is null"); return (Criteria) this; } public Criteria andIllnessNameIsNotNull() { addCriterion("illness_name is not null"); return (Criteria) this; } public Criteria andIllnessNameEqualTo(String value) { addCriterion("illness_name =", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameNotEqualTo(String value) { addCriterion("illness_name <>", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameGreaterThan(String value) { addCriterion("illness_name >", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameGreaterThanOrEqualTo(String value) { addCriterion("illness_name >=", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameLessThan(String value) { addCriterion("illness_name <", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameLessThanOrEqualTo(String value) { addCriterion("illness_name <=", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameLike(String value) { addCriterion("illness_name like", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameNotLike(String value) { addCriterion("illness_name not like", value, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameIn(List<String> values) { addCriterion("illness_name in", values, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameNotIn(List<String> values) { addCriterion("illness_name not in", values, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameBetween(String value1, String value2) { addCriterion("illness_name between", value1, value2, "illnessName"); return (Criteria) this; } public Criteria andIllnessNameNotBetween(String value1, String value2) { addCriterion("illness_name not between", value1, value2, "illnessName"); return (Criteria) this; } public Criteria andMedicineCodeIsNull() { addCriterion("medicine_code is null"); return (Criteria) this; } public Criteria andMedicineCodeIsNotNull() { addCriterion("medicine_code is not null"); return (Criteria) this; } public Criteria andMedicineCodeEqualTo(String value) { addCriterion("medicine_code =", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeNotEqualTo(String value) { addCriterion("medicine_code <>", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeGreaterThan(String value) { addCriterion("medicine_code >", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeGreaterThanOrEqualTo(String value) { addCriterion("medicine_code >=", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeLessThan(String value) { addCriterion("medicine_code <", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeLessThanOrEqualTo(String value) { addCriterion("medicine_code <=", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeLike(String value) { addCriterion("medicine_code like", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeNotLike(String value) { addCriterion("medicine_code not like", value, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeIn(List<String> values) { addCriterion("medicine_code in", values, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeNotIn(List<String> values) { addCriterion("medicine_code not in", values, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeBetween(String value1, String value2) { addCriterion("medicine_code between", value1, value2, "medicineCode"); return (Criteria) this; } public Criteria andMedicineCodeNotBetween(String value1, String value2) { addCriterion("medicine_code not between", value1, value2, "medicineCode"); return (Criteria) this; } public Criteria andMedicineNameIsNull() { addCriterion("medicine_name is null"); return (Criteria) this; } public Criteria andMedicineNameIsNotNull() { addCriterion("medicine_name is not null"); return (Criteria) this; } public Criteria andMedicineNameEqualTo(String value) { addCriterion("medicine_name =", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameNotEqualTo(String value) { addCriterion("medicine_name <>", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameGreaterThan(String value) { addCriterion("medicine_name >", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameGreaterThanOrEqualTo(String value) { addCriterion("medicine_name >=", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameLessThan(String value) { addCriterion("medicine_name <", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameLessThanOrEqualTo(String value) { addCriterion("medicine_name <=", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameLike(String value) { addCriterion("medicine_name like", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameNotLike(String value) { addCriterion("medicine_name not like", value, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameIn(List<String> values) { addCriterion("medicine_name in", values, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameNotIn(List<String> values) { addCriterion("medicine_name not in", values, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameBetween(String value1, String value2) { addCriterion("medicine_name between", value1, value2, "medicineName"); return (Criteria) this; } public Criteria andMedicineNameNotBetween(String value1, String value2) { addCriterion("medicine_name not between", value1, value2, "medicineName"); return (Criteria) this; } public Criteria andInstructionIsNull() { addCriterion("instruction is null"); return (Criteria) this; } public Criteria andInstructionIsNotNull() { addCriterion("instruction is not null"); return (Criteria) this; } public Criteria andInstructionEqualTo(String value) { addCriterion("instruction =", value, "instruction"); return (Criteria) this; } public Criteria andInstructionNotEqualTo(String value) { addCriterion("instruction <>", value, "instruction"); return (Criteria) this; } public Criteria andInstructionGreaterThan(String value) { addCriterion("instruction >", value, "instruction"); return (Criteria) this; } public Criteria andInstructionGreaterThanOrEqualTo(String value) { addCriterion("instruction >=", value, "instruction"); return (Criteria) this; } public Criteria andInstructionLessThan(String value) { addCriterion("instruction <", value, "instruction"); return (Criteria) this; } public Criteria andInstructionLessThanOrEqualTo(String value) { addCriterion("instruction <=", value, "instruction"); return (Criteria) this; } public Criteria andInstructionLike(String value) { addCriterion("instruction like", value, "instruction"); return (Criteria) this; } public Criteria andInstructionNotLike(String value) { addCriterion("instruction not like", value, "instruction"); return (Criteria) this; } public Criteria andInstructionIn(List<String> values) { addCriterion("instruction in", values, "instruction"); return (Criteria) this; } public Criteria andInstructionNotIn(List<String> values) { addCriterion("instruction not in", values, "instruction"); return (Criteria) this; } public Criteria andInstructionBetween(String value1, String value2) { addCriterion("instruction between", value1, value2, "instruction"); return (Criteria) this; } public Criteria andInstructionNotBetween(String value1, String value2) { addCriterion("instruction not between", value1, value2, "instruction"); return (Criteria) this; } public Criteria andAbbreviationIsNull() { addCriterion("abbreviation is null"); return (Criteria) this; } public Criteria andAbbreviationIsNotNull() { addCriterion("abbreviation is not null"); return (Criteria) this; } public Criteria andAbbreviationEqualTo(String value) { addCriterion("abbreviation =", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationNotEqualTo(String value) { addCriterion("abbreviation <>", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationGreaterThan(String value) { addCriterion("abbreviation >", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationGreaterThanOrEqualTo(String value) { addCriterion("abbreviation >=", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationLessThan(String value) { addCriterion("abbreviation <", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationLessThanOrEqualTo(String value) { addCriterion("abbreviation <=", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationLike(String value) { addCriterion("abbreviation like", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationNotLike(String value) { addCriterion("abbreviation not like", value, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationIn(List<String> values) { addCriterion("abbreviation in", values, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationNotIn(List<String> values) { addCriterion("abbreviation not in", values, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationBetween(String value1, String value2) { addCriterion("abbreviation between", value1, value2, "abbreviation"); return (Criteria) this; } public Criteria andAbbreviationNotBetween(String value1, String value2) { addCriterion("abbreviation not between", value1, value2, "abbreviation"); return (Criteria) this; } public Criteria andIllnessFeatureIsNull() { addCriterion("illness_feature is null"); return (Criteria) this; } public Criteria andIllnessFeatureIsNotNull() { addCriterion("illness_feature is not null"); return (Criteria) this; } public Criteria andIllnessFeatureEqualTo(String value) { addCriterion("illness_feature =", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureNotEqualTo(String value) { addCriterion("illness_feature <>", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureGreaterThan(String value) { addCriterion("illness_feature >", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureGreaterThanOrEqualTo(String value) { addCriterion("illness_feature >=", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureLessThan(String value) { addCriterion("illness_feature <", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureLessThanOrEqualTo(String value) { addCriterion("illness_feature <=", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureLike(String value) { addCriterion("illness_feature like", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureNotLike(String value) { addCriterion("illness_feature not like", value, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureIn(List<String> values) { addCriterion("illness_feature in", values, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureNotIn(List<String> values) { addCriterion("illness_feature not in", values, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureBetween(String value1, String value2) { addCriterion("illness_feature between", value1, value2, "illnessFeature"); return (Criteria) this; } public Criteria andIllnessFeatureNotBetween(String value1, String value2) { addCriterion("illness_feature not between", value1, value2, "illnessFeature"); return (Criteria) this; } } public static class Criteria extends GeneratedCriteria { protected Criteria() { super(); } } public static class Criterion { private String condition; private Object value; private Object secondValue; private boolean noValue; private boolean singleValue; private boolean betweenValue; private boolean listValue; private String typeHandler; public String getCondition() { return condition; } public Object getValue() { return value; } public Object getSecondValue() { return secondValue; } public boolean isNoValue() { return noValue; } public boolean isSingleValue() { return singleValue; } public boolean isBetweenValue() { return betweenValue; } public boolean isListValue() { return listValue; } public String getTypeHandler() { return typeHandler; } protected Criterion(String condition) { super(); this.condition = condition; this.typeHandler = null; this.noValue = true; } protected Criterion(String condition, Object value, String typeHandler) { super(); this.condition = condition; this.value = value; this.typeHandler = typeHandler; if (value instanceof List<?>) { this.listValue = true; } else { this.singleValue = true; } } protected Criterion(String condition, Object value) { this(condition, value, null); } protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { super(); this.condition = condition; this.value = value; this.secondValue = secondValue; this.typeHandler = typeHandler; this.betweenValue = true; } protected Criterion(String condition, Object value, Object secondValue) { this(condition, value, secondValue, null); } } }
——————————————————————————————————
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.excellent.archimedes.dao.MedicineCareIllnessMapper" >
<resultMap id="BaseResultMap" type="com.excellent.archimedes.pojo.MedicineCareIllness" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="illness_code" property="illnessCode" jdbcType="VARCHAR" />
<result column="illness_name" property="illnessName" jdbcType="VARCHAR" />
<result column="medicine_code" property="medicineCode" jdbcType="VARCHAR" />
<result column="medicine_name" property="medicineName" jdbcType="VARCHAR" />
<result column="instruction" property="instruction" jdbcType="VARCHAR" />
<result column="abbreviation" property="abbreviation" jdbcType="VARCHAR" />
<result column="illness_feature" property="illnessFeature" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
id, illness_code, illness_name, medicine_code, medicine_name, instruction, abbreviation,
illness_feature
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.excellent.archimedes.pojo.MedicineCareIllnessExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from medicine_care_illness
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
<if test="limitClause != null" >
limit ${limitClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from medicine_care_illness
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from medicine_care_illness
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.excellent.archimedes.pojo.MedicineCareIllnessExample" >
delete from medicine_care_illness
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.excellent.archimedes.pojo.MedicineCareIllness" useGeneratedKeys="true" keyProperty="id" >
insert into medicine_care_illness (illness_code, illness_name, medicine_code,
medicine_name, instruction, abbreviation,
illness_feature)
values (#{illnessCode,jdbcType=VARCHAR}, #{illnessName,jdbcType=VARCHAR}, #{medicineCode,jdbcType=VARCHAR},
#{medicineName,jdbcType=VARCHAR}, #{instruction,jdbcType=VARCHAR}, #{abbreviation,jdbcType=VARCHAR},
#{illnessFeature,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.excellent.archimedes.pojo.MedicineCareIllness" useGeneratedKeys="true" keyProperty="id" >
insert into medicine_care_illness
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="illnessCode != null" >
illness_code,
</if>
<if test="illnessName != null" >
illness_name,
</if>
<if test="medicineCode != null" >
medicine_code,
</if>
<if test="medicineName != null" >
medicine_name,
</if>
<if test="instruction != null" >
instruction,
</if>
<if test="abbreviation != null" >
abbreviation,
</if>
<if test="illnessFeature != null" >
illness_feature,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="illnessCode != null" >
#{illnessCode,jdbcType=VARCHAR},
</if>
<if test="illnessName != null" >
#{illnessName,jdbcType=VARCHAR},
</if>
<if test="medicineCode != null" >
#{medicineCode,jdbcType=VARCHAR},
</if>
<if test="medicineName != null" >
#{medicineName,jdbcType=VARCHAR},
</if>
<if test="instruction != null" >
#{instruction,jdbcType=VARCHAR},
</if>
<if test="abbreviation != null" >
#{abbreviation,jdbcType=VARCHAR},
</if>
<if test="illnessFeature != null" >
#{illnessFeature,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.excellent.archimedes.pojo.MedicineCareIllnessExample" resultType="java.lang.Integer" >
select count(*) from medicine_care_illness
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update medicine_care_illness
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.illnessCode != null" >
illness_code = #{record.illnessCode,jdbcType=VARCHAR},
</if>
<if test="record.illnessName != null" >
illness_name = #{record.illnessName,jdbcType=VARCHAR},
</if>
<if test="record.medicineCode != null" >
medicine_code = #{record.medicineCode,jdbcType=VARCHAR},
</if>
<if test="record.medicineName != null" >
medicine_name = #{record.medicineName,jdbcType=VARCHAR},
</if>
<if test="record.instruction != null" >
instruction = #{record.instruction,jdbcType=VARCHAR},
</if>
<if test="record.abbreviation != null" >
abbreviation = #{record.abbreviation,jdbcType=VARCHAR},
</if>
<if test="record.illnessFeature != null" >
illness_feature = #{record.illnessFeature,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update medicine_care_illness
set id = #{record.id,jdbcType=BIGINT},
illness_code = #{record.illnessCode,jdbcType=VARCHAR},
illness_name = #{record.illnessName,jdbcType=VARCHAR},
medicine_code = #{record.medicineCode,jdbcType=VARCHAR},
medicine_name = #{record.medicineName,jdbcType=VARCHAR},
instruction = #{record.instruction,jdbcType=VARCHAR},
abbreviation = #{record.abbreviation,jdbcType=VARCHAR},
illness_feature = #{record.illnessFeature,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.excellent.archimedes.pojo.MedicineCareIllness" >
update medicine_care_illness
<set >
<if test="illnessCode != null" >
illness_code = #{illnessCode,jdbcType=VARCHAR},
</if>
<if test="illnessName != null" >
illness_name = #{illnessName,jdbcType=VARCHAR},
</if>
<if test="medicineCode != null" >
medicine_code = #{medicineCode,jdbcType=VARCHAR},
</if>
<if test="medicineName != null" >
medicine_name = #{medicineName,jdbcType=VARCHAR},
</if>
<if test="instruction != null" >
instruction = #{instruction,jdbcType=VARCHAR},
</if>
<if test="abbreviation != null" >
abbreviation = #{abbreviation,jdbcType=VARCHAR},
</if>
<if test="illnessFeature != null" >
illness_feature = #{illnessFeature,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.excellent.archimedes.pojo.MedicineCareIllness" >
update medicine_care_illness
set illness_code = #{illnessCode,jdbcType=VARCHAR},
illness_name = #{illnessName,jdbcType=VARCHAR},
medicine_code = #{medicineCode,jdbcType=VARCHAR},
medicine_name = #{medicineName,jdbcType=VARCHAR},
instruction = #{instruction,jdbcType=VARCHAR},
abbreviation = #{abbreviation,jdbcType=VARCHAR},
illness_feature = #{illnessFeature,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
——————————————————
自动生成的Mapper类不用动
package com.excellent.archimedes.dao; import com.excellent.archimedes.pojo.MedicineCareIllness; import com.excellent.archimedes.pojo.MedicineCareIllnessExample; import org.apache.ibatis.annotations.Param; import java.util.List; public interface MedicineCareIllnessMapper { int countByExample(MedicineCareIllnessExample example); int deleteByExample(MedicineCareIllnessExample example); int deleteByPrimaryKey(Long id); int insert(MedicineCareIllness record); int insertSelective(MedicineCareIllness record); List<MedicineCareIllness> selectByExample(MedicineCareIllnessExample example); MedicineCareIllness selectByPrimaryKey(Long id); int updateByExampleSelective(@Param("record") MedicineCareIllness record, @Param("example") MedicineCareIllnessExample example); int updateByExample(@Param("record") MedicineCareIllness record, @Param("example") MedicineCareIllnessExample example); int updateByPrimaryKeySelective(MedicineCareIllness record); int updateByPrimaryKey(MedicineCareIllness record); }
——————————————————————————————
业务service类要根据具体情况来书写
package com.excellent.archimedes.service; import com.excellent.archimedes.dao.MedicineCareIllnessMapper; import com.excellent.archimedes.pojo.MedicineCareIllness; import com.excellent.archimedes.pojo.MedicineCareIllnessExample; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author zhaoyong * @Date 2022/9/30 * @Description */ @Service("treatmentService") @Scope("singleton") public class TreatmentServiceImpl implements TreatmentService { @Autowired MedicineCareIllnessMapper medicineCareIllnessMapper; @Override public List<MedicineCareIllness> getCareByEntity(MedicineCareIllness medicineCareIllness) { MedicineCareIllnessExample medicineCareIllnessExample = new MedicineCareIllnessExample(); MedicineCareIllnessExample.Criteria criteria = medicineCareIllnessExample.createCriteria(); if (null != medicineCareIllness) { if (StringUtils.isNotBlank(medicineCareIllness.getAbbreviation())) { criteria.andAbbreviationEqualTo(medicineCareIllness.getAbbreviation()); } if (StringUtils.isNotBlank(medicineCareIllness.getIllnessName())) { criteria.andIllnessNameLike("%" + medicineCareIllness.getIllnessName() + "%"); } if (StringUtils.isNotBlank(medicineCareIllness.getMedicineName())) { criteria.andMedicineNameLike("%" + medicineCareIllness.getMedicineName() + "%"); } } return medicineCareIllnessMapper.selectByExample(medicineCareIllnessExample); } @Override public Map<String, Object> getCarePageByEntity(MedicineCareIllness medicineCareIllness, Integer pageNum, Integer pageSize, Integer totalCount) { Map<String, Object> resultPage = new HashMap<String, Object>(); MedicineCareIllnessExample medicineCareIllnessExample = new MedicineCareIllnessExample(); MedicineCareIllnessExample.Criteria criteria = medicineCareIllnessExample.createCriteria(); if (null != medicineCareIllness) { if (StringUtils.isNotBlank(medicineCareIllness.getAbbreviation())) { criteria.andAbbreviationEqualTo(medicineCareIllness.getAbbreviation()); } if (StringUtils.isNotBlank(medicineCareIllness.getIllnessName())) { criteria.andIllnessNameLike("%" + medicineCareIllness.getIllnessName() + "%"); } if (StringUtils.isNotBlank(medicineCareIllness.getMedicineName())) { criteria.andMedicineNameLike("%" + medicineCareIllness.getMedicineName() + "%"); } } if (null == totalCount) {//容错机制 totalCount = medicineCareIllnessMapper.countByExample(medicineCareIllnessExample);//查询本条件下总共有多少条记录数 } Integer pageSum = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;//求总页数 if (pageNum.compareTo(Integer.valueOf(0)) == 0) { medicineCareIllnessExample.setLimitClause(pageSize.toString()); } if (Integer.valueOf(0).compareTo(pageNum) < 0 && pageNum.compareTo(pageSum) <= 0) { String startIndex = String.valueOf(pageNum * pageSize); medicineCareIllnessExample.setLimitClause(startIndex + "," + pageSize.toString()); } List<MedicineCareIllness> resultList = medicineCareIllnessMapper.selectByExample(medicineCareIllnessExample); resultPage.put("resultList", resultList);//查询回来的当前页数据 resultPage.put("pageNum", pageNum);//当前页码 resultPage.put("pageSize", pageSize);//每页几条 resultPage.put("pageSum", pageSum);//总页数 resultPage.put("totalCount", totalCount);//该条件下的总记录数 return resultPage; } @Override public Integer getTotalContByEntity(MedicineCareIllness medicineCareIllness) { MedicineCareIllnessExample medicineCareIllnessExample = new MedicineCareIllnessExample(); MedicineCareIllnessExample.Criteria criteria = medicineCareIllnessExample.createCriteria(); if (null != medicineCareIllness) { if (StringUtils.isNotBlank(medicineCareIllness.getAbbreviation())) { criteria.andAbbreviationEqualTo(medicineCareIllness.getAbbreviation()); } if (StringUtils.isNotBlank(medicineCareIllness.getIllnessName())) { criteria.andIllnessNameLike("%" + medicineCareIllness.getIllnessName() + "%"); } if (StringUtils.isNotBlank(medicineCareIllness.getMedicineName())) { criteria.andMedicineNameLike("%" + medicineCareIllness.getMedicineName() + "%"); } } Integer totalCount = medicineCareIllnessMapper.countByExample(medicineCareIllnessExample);//查询本条件下总共有多少条记录数 return totalCount; } @Override public int insertMedicineCare(MedicineCareIllness medicineCareIllness) { return medicineCareIllnessMapper.insert(medicineCareIllness); } @Override public int deleteMedicineCareBy(Long id) { return medicineCareIllnessMapper.deleteByPrimaryKey(id); } @Override public int updateMedicineCare(MedicineCareIllness medicineCareIllness) { return medicineCareIllnessMapper.updateByPrimaryKey(medicineCareIllness); } @Override public MedicineCareIllness getMedicineCareById(Long id) { return medicineCareIllnessMapper.selectByPrimaryKey(id); } }