Authored by kun

add new files

@@ -21,12 +21,14 @@ @@ -21,12 +21,14 @@
21 </properties> 21 </properties>
22 22
23 23
24 -  
25 <dependencies> 24 <dependencies>
26 - 25 + <dependency>
  26 + <groupId>com.yoho.ufo.model</groupId>
  27 + <artifactId>product-service-model</artifactId>
  28 + <version>${project.version}</version>
  29 + </dependency>
27 30
28 </dependencies> 31 </dependencies>
29 32
30 33
31 -  
32 </project> 34 </project>
  1 +package com.yohobuy.ufo.dal.brand;
  2 +
  3 +import com.yohobuy.ufo.model.brand.Brand;
  4 +import com.yohobuy.ufo.model.common.PageModel;
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @author kun.wang
  11 + * @date 2018/09/11
  12 + */
  13 +public interface BrandMapper {
  14 +
  15 + /**
  16 + * 插入一条品牌记录
  17 + * @param brand
  18 + * @return
  19 + */
  20 + int insertBrand(Brand brand);
  21 +
  22 + /**
  23 + * 更新品牌状态
  24 + * @param id
  25 + * @param status
  26 + * @return
  27 + */
  28 + int updateBrandStatus(@Param("id") Integer id, @Param("status") Integer status);
  29 +
  30 + /**
  31 + * 更新一条品牌
  32 + * @param brand
  33 + * @return
  34 + */
  35 + int updateBrand(@Param("brand") Brand brand);
  36 +
  37 + /**
  38 + * 根据条件查询品牌记录总数
  39 + * @param brand
  40 + * @return
  41 + */
  42 + int selectBrandCount(Brand brand);
  43 +
  44 + /**
  45 + * 根据主键查询品牌信息
  46 + * @param id
  47 + * @return
  48 + */
  49 + Brand selectOneById(Integer id);
  50 +
  51 + /**
  52 + * 根据条件查询品牌分页信息
  53 + * @param brand
  54 + * @param pageModel
  55 + * @return
  56 + */
  57 + List<Brand> getBrandPageList(@Param("brand") Brand brand, @Param("page")PageModel pageModel);
  58 +}
  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.yohobuy.ufo.dal.brand.BrandMapper">
  4 +
  5 + <resultMap id="brandMap" type="com.yohobuy.ufo.model.brand.Brand">
  6 + </resultMap>
  7 +
  8 + <sql id="queryColumns">
  9 + id, brand_name, brand_name_en, brand_log, brand_search, status, create_time
  10 + </sql>
  11 +
  12 + <insert id="insertBrand" parameterType="com.yohobuy.ufo.model.brand.Brand">
  13 + insert into brand(id, brand_name, brand_name_en, brand_log, brand_search, status, create_time, edit_time, edit_pid)
  14 + values (#{id}, #{brandName}, #{brandNameEn}, #{brandLogo}, #{brandSearch}, #{status}, #{createTime}, #{editTime}, #{editPid})
  15 + </insert>
  16 +
  17 + <update id="updateBrandStatus">
  18 + update brand set status = #{status}, edit_time = #{editTime}, edit_pid = #{editPid} where id = #{id}
  19 + </update>
  20 +
  21 + <update id="updateBrand">
  22 + update brand
  23 + <set>
  24 + <if test="brand.brandName != null and brand.brandName !=''">
  25 + brand_name = #{brand.brandName},
  26 + </if>
  27 + <if test="brand.brandNameEn != null and brand.brandNameEn != ''">
  28 + brand_name_en = #{brand.brandNameEn},
  29 + </if>
  30 + <if test="brand.brandLogo != null and brand.brandLogo != ''">
  31 + brand_log = #{brand.brandLogo},
  32 + </if>
  33 + <if test="brand.brandSearch != null and brand.brandSearch !=''">
  34 + brand_search = #{brand.brandSearch},
  35 + </if>
  36 + <if test="brand.status != null and brand.status != ''">
  37 + status = #{brand.status},
  38 + </if>
  39 + <if test="brand.createTime != null">
  40 + create_time = #{brand.createTime},
  41 + </if>
  42 + <if test="brand.editTime != null">
  43 + edit_time = #{brand.editTime},
  44 + </if>
  45 + <if test="brand.editPid != null">
  46 + edit_pid = #{brand.editPid}
  47 + </if>
  48 + </set>
  49 + where id = #{brand.id}
  50 + </update>
  51 +
  52 + <select id="selectOneById" resultMap="brandMap">
  53 + select <include refid="queryColumns" />
  54 + from brand where id = #{id}
  55 + </select>
  56 +
  57 +
  58 + <select id="selectBrandCount" resultType="integer">
  59 + select count(*)
  60 + from brand
  61 + <where>
  62 + <if test="brand.brandName != null and brand.brandName != ''">
  63 + brand_name like concat('%', #{brand.brandName}, '%') or brand_name_en like concat('%', #{brand.brandName}, '%')
  64 + </if>
  65 + <if test="brand.status != null">
  66 + status = #{brand.status}
  67 + </if>
  68 + </where>
  69 + </select>
  70 +
  71 + <select id="getBrandPageList" resultMap="brandMap">
  72 + select <include refid="queryColumns"/>
  73 + from brand
  74 + <where>
  75 + <if test="brand.brandName != null and brand.brandName != ''">
  76 + brand_name like concat('%', #{brand.brandName}, '%') or brand_name_en like concat('%', #{brand.brandName}, '%')
  77 + </if>
  78 + <if test="brand.status != null">
  79 + status = #{brand.status}
  80 + </if>
  81 + </where>
  82 + order by create_time desc
  83 + limit #{page.startIndex}, #{page.pageSize}
  84 + </select>
  85 +
  86 +</mapper>