mybatis association 的用法(完整版)

package com.tuling.tulingmall.domain;

import com.tuling.tulingmall.model.UmsMember;
import com.tuling.tulingmall.model.UmsMemberLevel;
import lombok.Data;

@Data
public class PortalMemberInfo extends UmsMember {
    private UmsMemberLevel umsMemberLevel;
}
package com.tuling.tulingmall.model;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;

public class UmsMember implements Serializable {
    private Long id;

    private Long memberLevelId;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "昵称")
    private String nickname;

    @ApiModelProperty(value = "手机号码")
    private String phone;

    @ApiModelProperty(value = "帐号启用状态:0->禁用;1->启用")
    private Integer status;

    @ApiModelProperty(value = "注册时间")
    private Date createTime;

    @ApiModelProperty(value = "头像")
    private String icon;

    @ApiModelProperty(value = "性别:0->未知;1->男;2->女")
    private Integer gender;

    @ApiModelProperty(value = "生日")
    private Date birthday;

    @ApiModelProperty(value = "所在城市")
    private String city;

    @ApiModelProperty(value = "职业")
    private String job;

    @ApiModelProperty(value = "个性签名")
    private String personalizedSignature;

    @ApiModelProperty(value = "用户来源")
    private Integer sourceType;

    @ApiModelProperty(value = "积分")
    private Integer integration;

    @ApiModelProperty(value = "成长值")
    private Integer growth;

    @ApiModelProperty(value = "剩余抽奖次数")
    private Integer luckeyCount;

    @ApiModelProperty(value = "历史积分数量")
    private Integer historyIntegration;

    private static final long serialVersionUID = 1L;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getMemberLevelId() {
        return memberLevelId;
    }

    public void setMemberLevelId(Long memberLevelId) {
        this.memberLevelId = memberLevelId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getPersonalizedSignature() {
        return personalizedSignature;
    }

    public void setPersonalizedSignature(String personalizedSignature) {
        this.personalizedSignature = personalizedSignature;
    }

    public Integer getSourceType() {
        return sourceType;
    }

    public void setSourceType(Integer sourceType) {
        this.sourceType = sourceType;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    public Integer getGrowth() {
        return growth;
    }

    public void setGrowth(Integer growth) {
        this.growth = growth;
    }

    public Integer getLuckeyCount() {
        return luckeyCount;
    }

    public void setLuckeyCount(Integer luckeyCount) {
        this.luckeyCount = luckeyCount;
    }

    public Integer getHistoryIntegration() {
        return historyIntegration;
    }

    public void setHistoryIntegration(Integer historyIntegration) {
        this.historyIntegration = historyIntegration;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", memberLevelId=").append(memberLevelId);
        sb.append(", username=").append(username);
        sb.append(", password=").append(password);
        sb.append(", nickname=").append(nickname);
        sb.append(", phone=").append(phone);
        sb.append(", status=").append(status);
        sb.append(", createTime=").append(createTime);
        sb.append(", icon=").append(icon);
        sb.append(", gender=").append(gender);
        sb.append(", birthday=").append(birthday);
        sb.append(", city=").append(city);
        sb.append(", job=").append(job);
        sb.append(", personalizedSignature=").append(personalizedSignature);
        sb.append(", sourceType=").append(sourceType);
        sb.append(", integration=").append(integration);
        sb.append(", growth=").append(growth);
        sb.append(", luckeyCount=").append(luckeyCount);
        sb.append(", historyIntegration=").append(historyIntegration);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
package com.tuling.tulingmall.model;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;

public class UmsMemberLevel implements Serializable {
    private Long id;

    private String name;

    private Integer growthPoint;

    @ApiModelProperty(value = "是否为默认等级:0->不是;1->是")
    private Integer defaultStatus;

    @ApiModelProperty(value = "免运费标准")
    private BigDecimal freeFreightPoint;

    @ApiModelProperty(value = "每次评价获取的成长值")
    private Integer commentGrowthPoint;

    @ApiModelProperty(value = "是否有免邮特权")
    private Integer priviledgeFreeFreight;

    @ApiModelProperty(value = "是否有签到特权")
    private Integer priviledgeSignIn;

    @ApiModelProperty(value = "是否有评论获奖励特权")
    private Integer priviledgeComment;

    @ApiModelProperty(value = "是否有专享活动特权")
    private Integer priviledgePromotion;

    @ApiModelProperty(value = "是否有会员价格特权")
    private Integer priviledgeMemberPrice;

    @ApiModelProperty(value = "是否有生日特权")
    private Integer priviledgeBirthday;

    private String note;

    private static final long serialVersionUID = 1L;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getGrowthPoint() {
        return growthPoint;
    }

    public void setGrowthPoint(Integer growthPoint) {
        this.growthPoint = growthPoint;
    }

    public Integer getDefaultStatus() {
        return defaultStatus;
    }

    public void setDefaultStatus(Integer defaultStatus) {
        this.defaultStatus = defaultStatus;
    }

    public BigDecimal getFreeFreightPoint() {
        return freeFreightPoint;
    }

    public void setFreeFreightPoint(BigDecimal freeFreightPoint) {
        this.freeFreightPoint = freeFreightPoint;
    }

    public Integer getCommentGrowthPoint() {
        return commentGrowthPoint;
    }

    public void setCommentGrowthPoint(Integer commentGrowthPoint) {
        this.commentGrowthPoint = commentGrowthPoint;
    }

    public Integer getPriviledgeFreeFreight() {
        return priviledgeFreeFreight;
    }

    public void setPriviledgeFreeFreight(Integer priviledgeFreeFreight) {
        this.priviledgeFreeFreight = priviledgeFreeFreight;
    }

    public Integer getPriviledgeSignIn() {
        return priviledgeSignIn;
    }

    public void setPriviledgeSignIn(Integer priviledgeSignIn) {
        this.priviledgeSignIn = priviledgeSignIn;
    }

    public Integer getPriviledgeComment() {
        return priviledgeComment;
    }

    public void setPriviledgeComment(Integer priviledgeComment) {
        this.priviledgeComment = priviledgeComment;
    }

    public Integer getPriviledgePromotion() {
        return priviledgePromotion;
    }

    public void setPriviledgePromotion(Integer priviledgePromotion) {
        this.priviledgePromotion = priviledgePromotion;
    }

    public Integer getPriviledgeMemberPrice() {
        return priviledgeMemberPrice;
    }

    public void setPriviledgeMemberPrice(Integer priviledgeMemberPrice) {
        this.priviledgeMemberPrice = priviledgeMemberPrice;
    }

    public Integer getPriviledgeBirthday() {
        return priviledgeBirthday;
    }

    public void setPriviledgeBirthday(Integer priviledgeBirthday) {
        this.priviledgeBirthday = priviledgeBirthday;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", growthPoint=").append(growthPoint);
        sb.append(", defaultStatus=").append(defaultStatus);
        sb.append(", freeFreightPoint=").append(freeFreightPoint);
        sb.append(", commentGrowthPoint=").append(commentGrowthPoint);
        sb.append(", priviledgeFreeFreight=").append(priviledgeFreeFreight);
        sb.append(", priviledgeSignIn=").append(priviledgeSignIn);
        sb.append(", priviledgeComment=").append(priviledgeComment);
        sb.append(", priviledgePromotion=").append(priviledgePromotion);
        sb.append(", priviledgeMemberPrice=").append(priviledgeMemberPrice);
        sb.append(", priviledgeBirthday=").append(priviledgeBirthday);
        sb.append(", note=").append(note);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
package com.tuling.tulingmall.controller;

import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.UmsMember;
import com.tuling.tulingmall.domain.PortalMemberInfo;
import com.tuling.tulingmall.service.UmsMemberCenterService;
import com.tuling.tulingmall.service.UmsMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "UmsMemberCenterController",description = "会员中心管理操作#杨过添加")
@RestController
@RequestMapping("/member/center")
public class UmsMemberCenterController {
    @Autowired
    private UmsMemberCenterService umsMemberCenterService;

    @Autowired
    private UmsMemberService umsMemberService;

   

    @ApiOperation(value = "获取会员详细信息包含会员等级信息#杨过添加",notes = "会员需要被拆分成微服务")
    @GetMapping("/getMemberInfo")
    public CommonResult<PortalMemberInfo> getMemberInfo(@RequestHeader("memberId") long memberId){
        /**
         * UmsMember:会员详细信息,但是不包含会员的等级信息,但是有memberLevelId字段,UmsMember表中存入memberLevel_Id
         * UmsMemberLevel:包含会员等级信息
         *
         * PortalMemberInfo extends UmsMember ,属性为UmsMemberLevel 这个对象
         * 要用到 mybatis 中的association  yi
         */
        return CommonResult.success(umsMemberCenterService.getMemberInfo(memberId));
    }

   
package com.tuling.tulingmall.service;


import com.tuling.tulingmall.domain.PortalMemberInfo;


public interface UmsMemberCenterService {

    /**
     * 查询会员信息
     * @param memberId
     * @return
     */
    PortalMemberInfo getMemberInfo(Long memberId);
}
package com.tuling.tulingmall.service.impl;


import com.tuling.tulingmall.dao.PortalMemberInfoDao;
import com.tuling.tulingmall.domain.PortalMemberInfo;
import com.tuling.tulingmall.service.UmsMemberCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UmsMemberCenterServiceImpl implements UmsMemberCenterService {

    @Autowired
    private PortalMemberInfoDao portalMemberInfoDao;

    /**
     * 查询会员信息
     * @param memberId
     * @return
     */
    @Override
    public PortalMemberInfo getMemberInfo(Long memberId) {
        return portalMemberInfoDao.getMemberInfo(memberId);
    }
}
package com.tuling.tulingmall.dao;


import com.tuling.tulingmall.domain.PortalMemberInfo;

public interface PortalMemberInfoDao {
    /**
     * 查询会员信息
     * @param memberId
     * @return
     */
    PortalMemberInfo getMemberInfo(Long memberId);
}
<?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.tuling.tulingmall.dao.PortalMemberInfoDao">
    <resultMap id="PortalMemberInfoMap" type="com.tuling.tulingmall.domain.PortalMemberInfo"
               extends="com.tuling.tulingmall.mapper.UmsMemberMapper.BaseResultMap">
        <association property="umsMemberLevel" resultMap="com.tuling.tulingmall.mapper.UmsMemberLevelMapper.BaseResultMap" columnPrefix="lv_">
        </association>
    </resultMap>
    <select id="getMemberInfo" resultMap="PortalMemberInfoMap">
        SELECT
            um.id,
            um.member_level_id,
            um.username,
            um.nickname,
            um.phone,
            um.status,
            um.create_time,
            um.icon,
            um.gender,
            um.birthday,
            um.city,
            um.job,
            um.personalized_signature,
            um.source_type,
            um.integration,
            um.growth,
            um.luckey_count,
            um.history_integration,
            lv.id lv_id,
            lv.name lv_name,
            lv.growth_point lv_growth_point,
            lv.default_status lv_default_status,
            lv.free_freight_point lv_free_freight_point,
            lv.comment_growth_point lv_comment_growth_point,
            lv.priviledge_free_freight lv_priviledge_free_freight,
            lv.priviledge_sign_in lv_priviledge_sign_in,
            lv.priviledge_comment lv_priviledge_comment,
            lv.priviledge_promotion lv_priviledge_promotion,
            lv.priviledge_member_price lv_priviledge_member_price,
            lv.priviledge_birthday lv_priviledge_birthday
        FROM
            tl_mall_user.ums_member um
        LEFT JOIN
            tl_mall_user.ums_member_level lv on lv.id = um.member_level_id
        WHERE um.id = #{memberId} AND um.status = 1
    </select>
</mapper>
UmsMemberLevelMapper.xml:

<?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.tuling.tulingmall.mapper.UmsMemberLevelMapper">
  <resultMap id="BaseResultMap" type="com.tuling.tulingmall.model.UmsMemberLevel">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="growth_point" jdbcType="INTEGER" property="growthPoint" />
    <result column="default_status" jdbcType="INTEGER" property="defaultStatus" />
    <result column="free_freight_point" jdbcType="DECIMAL" property="freeFreightPoint" />
    <result column="comment_growth_point" jdbcType="INTEGER" property="commentGrowthPoint" />
    <result column="priviledge_free_freight" jdbcType="INTEGER" property="priviledgeFreeFreight" />
    <result column="priviledge_sign_in" jdbcType="INTEGER" property="priviledgeSignIn" />
    <result column="priviledge_comment" jdbcType="INTEGER" property="priviledgeComment" />
    <result column="priviledge_promotion" jdbcType="INTEGER" property="priviledgePromotion" />
    <result column="priviledge_member_price" jdbcType="INTEGER" property="priviledgeMemberPrice" />
    <result column="priviledge_birthday" jdbcType="INTEGER" property="priviledgeBirthday" />
    <result column="note" jdbcType="VARCHAR" property="note" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" 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="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, name, growth_point, default_status, free_freight_point, comment_growth_point, 
    priviledge_free_freight, priviledge_sign_in, priviledge_comment, priviledge_promotion, 
    priviledge_member_price, priviledge_birthday, note
  </sql>
  <select id="selectByExample" parameterType="com.tuling.tulingmall.model.UmsMemberLevelExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from ums_member_level
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ums_member_level
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ums_member_level
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.tuling.tulingmall.model.UmsMemberLevelExample">
    delete from ums_member_level
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.tuling.tulingmall.model.UmsMemberLevel">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into ums_member_level (name, growth_point, default_status, 
      free_freight_point, comment_growth_point, priviledge_free_freight, 
      priviledge_sign_in, priviledge_comment, priviledge_promotion, 
      priviledge_member_price, priviledge_birthday, 
      note)
    values (#{name,jdbcType=VARCHAR}, #{growthPoint,jdbcType=INTEGER}, #{defaultStatus,jdbcType=INTEGER}, 
      #{freeFreightPoint,jdbcType=DECIMAL}, #{commentGrowthPoint,jdbcType=INTEGER}, #{priviledgeFreeFreight,jdbcType=INTEGER}, 
      #{priviledgeSignIn,jdbcType=INTEGER}, #{priviledgeComment,jdbcType=INTEGER}, #{priviledgePromotion,jdbcType=INTEGER}, 
      #{priviledgeMemberPrice,jdbcType=INTEGER}, #{priviledgeBirthday,jdbcType=INTEGER}, 
      #{note,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.tuling.tulingmall.model.UmsMemberLevel">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into ums_member_level
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        name,
      </if>
      <if test="growthPoint != null">
        growth_point,
      </if>
      <if test="defaultStatus != null">
        default_status,
      </if>
      <if test="freeFreightPoint != null">
        free_freight_point,
      </if>
      <if test="commentGrowthPoint != null">
        comment_growth_point,
      </if>
      <if test="priviledgeFreeFreight != null">
        priviledge_free_freight,
      </if>
      <if test="priviledgeSignIn != null">
        priviledge_sign_in,
      </if>
      <if test="priviledgeComment != null">
        priviledge_comment,
      </if>
      <if test="priviledgePromotion != null">
        priviledge_promotion,
      </if>
      <if test="priviledgeMemberPrice != null">
        priviledge_member_price,
      </if>
      <if test="priviledgeBirthday != null">
        priviledge_birthday,
      </if>
      <if test="note != null">
        note,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="growthPoint != null">
        #{growthPoint,jdbcType=INTEGER},
      </if>
      <if test="defaultStatus != null">
        #{defaultStatus,jdbcType=INTEGER},
      </if>
      <if test="freeFreightPoint != null">
        #{freeFreightPoint,jdbcType=DECIMAL},
      </if>
      <if test="commentGrowthPoint != null">
        #{commentGrowthPoint,jdbcType=INTEGER},
      </if>
      <if test="priviledgeFreeFreight != null">
        #{priviledgeFreeFreight,jdbcType=INTEGER},
      </if>
      <if test="priviledgeSignIn != null">
        #{priviledgeSignIn,jdbcType=INTEGER},
      </if>
      <if test="priviledgeComment != null">
        #{priviledgeComment,jdbcType=INTEGER},
      </if>
      <if test="priviledgePromotion != null">
        #{priviledgePromotion,jdbcType=INTEGER},
      </if>
      <if test="priviledgeMemberPrice != null">
        #{priviledgeMemberPrice,jdbcType=INTEGER},
      </if>
      <if test="priviledgeBirthday != null">
        #{priviledgeBirthday,jdbcType=INTEGER},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.tuling.tulingmall.model.UmsMemberLevelExample" resultType="java.lang.Long">
    select count(*) from ums_member_level
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update ums_member_level
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.growthPoint != null">
        growth_point = #{record.growthPoint,jdbcType=INTEGER},
      </if>
      <if test="record.defaultStatus != null">
        default_status = #{record.defaultStatus,jdbcType=INTEGER},
      </if>
      <if test="record.freeFreightPoint != null">
        free_freight_point = #{record.freeFreightPoint,jdbcType=DECIMAL},
      </if>
      <if test="record.commentGrowthPoint != null">
        comment_growth_point = #{record.commentGrowthPoint,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgeFreeFreight != null">
        priviledge_free_freight = #{record.priviledgeFreeFreight,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgeSignIn != null">
        priviledge_sign_in = #{record.priviledgeSignIn,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgeComment != null">
        priviledge_comment = #{record.priviledgeComment,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgePromotion != null">
        priviledge_promotion = #{record.priviledgePromotion,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgeMemberPrice != null">
        priviledge_member_price = #{record.priviledgeMemberPrice,jdbcType=INTEGER},
      </if>
      <if test="record.priviledgeBirthday != null">
        priviledge_birthday = #{record.priviledgeBirthday,jdbcType=INTEGER},
      </if>
      <if test="record.note != null">
        note = #{record.note,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update ums_member_level
    set id = #{record.id,jdbcType=BIGINT},
      name = #{record.name,jdbcType=VARCHAR},
      growth_point = #{record.growthPoint,jdbcType=INTEGER},
      default_status = #{record.defaultStatus,jdbcType=INTEGER},
      free_freight_point = #{record.freeFreightPoint,jdbcType=DECIMAL},
      comment_growth_point = #{record.commentGrowthPoint,jdbcType=INTEGER},
      priviledge_free_freight = #{record.priviledgeFreeFreight,jdbcType=INTEGER},
      priviledge_sign_in = #{record.priviledgeSignIn,jdbcType=INTEGER},
      priviledge_comment = #{record.priviledgeComment,jdbcType=INTEGER},
      priviledge_promotion = #{record.priviledgePromotion,jdbcType=INTEGER},
      priviledge_member_price = #{record.priviledgeMemberPrice,jdbcType=INTEGER},
      priviledge_birthday = #{record.priviledgeBirthday,jdbcType=INTEGER},
      note = #{record.note,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.tuling.tulingmall.model.UmsMemberLevel">
    update ums_member_level
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="growthPoint != null">
        growth_point = #{growthPoint,jdbcType=INTEGER},
      </if>
      <if test="defaultStatus != null">
        default_status = #{defaultStatus,jdbcType=INTEGER},
      </if>
      <if test="freeFreightPoint != null">
        free_freight_point = #{freeFreightPoint,jdbcType=DECIMAL},
      </if>
      <if test="commentGrowthPoint != null">
        comment_growth_point = #{commentGrowthPoint,jdbcType=INTEGER},
      </if>
      <if test="priviledgeFreeFreight != null">
        priviledge_free_freight = #{priviledgeFreeFreight,jdbcType=INTEGER},
      </if>
      <if test="priviledgeSignIn != null">
        priviledge_sign_in = #{priviledgeSignIn,jdbcType=INTEGER},
      </if>
      <if test="priviledgeComment != null">
        priviledge_comment = #{priviledgeComment,jdbcType=INTEGER},
      </if>
      <if test="priviledgePromotion != null">
        priviledge_promotion = #{priviledgePromotion,jdbcType=INTEGER},
      </if>
      <if test="priviledgeMemberPrice != null">
        priviledge_member_price = #{priviledgeMemberPrice,jdbcType=INTEGER},
      </if>
      <if test="priviledgeBirthday != null">
        priviledge_birthday = #{priviledgeBirthday,jdbcType=INTEGER},
      </if>
      <if test="note != null">
        note = #{note,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tuling.tulingmall.model.UmsMemberLevel">
    update ums_member_level
    set name = #{name,jdbcType=VARCHAR},
      growth_point = #{growthPoint,jdbcType=INTEGER},
      default_status = #{defaultStatus,jdbcType=INTEGER},
      free_freight_point = #{freeFreightPoint,jdbcType=DECIMAL},
      comment_growth_point = #{commentGrowthPoint,jdbcType=INTEGER},
      priviledge_free_freight = #{priviledgeFreeFreight,jdbcType=INTEGER},
      priviledge_sign_in = #{priviledgeSignIn,jdbcType=INTEGER},
      priviledge_comment = #{priviledgeComment,jdbcType=INTEGER},
      priviledge_promotion = #{priviledgePromotion,jdbcType=INTEGER},
      priviledge_member_price = #{priviledgeMemberPrice,jdbcType=INTEGER},
      priviledge_birthday = #{priviledgeBirthday,jdbcType=INTEGER},
      note = #{note,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>

 

-- auto-generated definition
create table ums_member
(
    id                     bigint auto_increment
        primary key,
    member_level_id        bigint                                   null,
    username               varchar(64)                              null comment '用户名',
    password               varchar(64)                              null comment '密码',
    nickname               varchar(64)                              not null comment '昵称',
    phone                  varchar(64)                              null comment '手机号码',
    status                 int                                      null comment '帐号启用状态:0->禁用;1->启用',
    create_time            datetime                                 null comment '注册时间',
    icon                   varchar(500)                             null comment '头像',
    gender                 int                                      null comment '性别:0->未知;1->男;2->女',
    birthday               date                                     null comment '生日',
    city                   varchar(64)                              null comment '所做城市',
    job                    varchar(100)                             null comment '职业',
    personalized_signature varchar(200)                             null comment '个性签名',
    source_type            int                                      null comment '用户来源',
    integration            int                                      null comment '积分',
    growth                 int                                      null comment '成长值',
    luckey_count           int                                      null comment '剩余抽奖次数',
    history_integration    int                                      null comment '历史积分数量',
    gmt_create             datetime(6) default CURRENT_TIMESTAMP(6) null,
    gmt_modified           datetime(6)                              null,
    constraint idx_phone
        unique (phone),
    constraint idx_username
        unique (username)
)
    comment '会员表' charset = utf8mb3;
-- auto-generated definition
create table ums_member_level
(
    id                      bigint auto_increment
        primary key,
    name                    varchar(100)                             null,
    growth_point            int                                      null,
    default_status          int                                      null comment '是否为默认等级:0->不是;1->是',
    free_freight_point      decimal(10, 2)                           null comment '免运费标准',
    comment_growth_point    int                                      null comment '每次评价获取的成长值',
    priviledge_free_freight int                                      null comment '是否有免邮特权',
    priviledge_sign_in      int                                      null comment '是否有签到特权',
    priviledge_comment      int                                      null comment '是否有评论获奖励特权',
    priviledge_promotion    int                                      null comment '是否有专享活动特权',
    priviledge_member_price int                                      null comment '是否有会员价格特权',
    priviledge_birthday     int                                      null comment '是否有生日特权',
    note                    varchar(200)                             null,
    gmt_create              datetime(6) default CURRENT_TIMESTAMP(6) null,
    gmt_modified            datetime(6)                              null
)
    comment '会员等级表' charset = utf8mb3;
INSERT INTO tl_mall_user.ums_member (id, member_level_id, username, password, nickname, phone, status, create_time, icon, gender, birthday, city, job, personalized_signature, source_type, integration, growth, luckey_count, history_integration, gmt_create, gmt_modified) VALUES (462245, null, 'roy', '$2a$10$eo6qnvKKq8cOkf7XkRFMwe29pA1YoE4tEbA5tK820JvkUu1ZIIOIW', 'roy', '123', 1, '2022-07-03 03:39:42', null, null, null, null, null, null, null, null, null, null, null, '2022-07-03 16:39:42.447505', null);

 

posted @ 2023-07-05 19:38  小啊菜鸡  阅读(841)  评论(0编辑  收藏  举报