Authored by kun

add new files

... ... @@ -21,12 +21,14 @@
</properties>
<dependencies>
<dependency>
<groupId>com.yoho.ufo.model</groupId>
<artifactId>product-service-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
... ...
package com.yohobuy.ufo.dal.brand;
import com.yohobuy.ufo.model.brand.Brand;
import com.yohobuy.ufo.model.common.PageModel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author kun.wang
* @date 2018/09/11
*/
public interface BrandMapper {
/**
* 插入一条品牌记录
* @param brand
* @return
*/
int insertBrand(Brand brand);
/**
* 更新品牌状态
* @param id
* @param status
* @return
*/
int updateBrandStatus(@Param("id") Integer id, @Param("status") Integer status);
/**
* 更新一条品牌
* @param brand
* @return
*/
int updateBrand(@Param("brand") Brand brand);
/**
* 根据条件查询品牌记录总数
* @param brand
* @return
*/
int selectBrandCount(Brand brand);
/**
* 根据主键查询品牌信息
* @param id
* @return
*/
Brand selectOneById(Integer id);
/**
* 根据条件查询品牌分页信息
* @param brand
* @param pageModel
* @return
*/
List<Brand> getBrandPageList(@Param("brand") Brand brand, @Param("page")PageModel pageModel);
}
... ...
<?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.yohobuy.ufo.dal.brand.BrandMapper">
<resultMap id="brandMap" type="com.yohobuy.ufo.model.brand.Brand">
</resultMap>
<sql id="queryColumns">
id, brand_name, brand_name_en, brand_log, brand_search, status, create_time
</sql>
<insert id="insertBrand" parameterType="com.yohobuy.ufo.model.brand.Brand">
insert into brand(id, brand_name, brand_name_en, brand_log, brand_search, status, create_time, edit_time, edit_pid)
values (#{id}, #{brandName}, #{brandNameEn}, #{brandLogo}, #{brandSearch}, #{status}, #{createTime}, #{editTime}, #{editPid})
</insert>
<update id="updateBrandStatus">
update brand set status = #{status}, edit_time = #{editTime}, edit_pid = #{editPid} where id = #{id}
</update>
<update id="updateBrand">
update brand
<set>
<if test="brand.brandName != null and brand.brandName !=''">
brand_name = #{brand.brandName},
</if>
<if test="brand.brandNameEn != null and brand.brandNameEn != ''">
brand_name_en = #{brand.brandNameEn},
</if>
<if test="brand.brandLogo != null and brand.brandLogo != ''">
brand_log = #{brand.brandLogo},
</if>
<if test="brand.brandSearch != null and brand.brandSearch !=''">
brand_search = #{brand.brandSearch},
</if>
<if test="brand.status != null and brand.status != ''">
status = #{brand.status},
</if>
<if test="brand.createTime != null">
create_time = #{brand.createTime},
</if>
<if test="brand.editTime != null">
edit_time = #{brand.editTime},
</if>
<if test="brand.editPid != null">
edit_pid = #{brand.editPid}
</if>
</set>
where id = #{brand.id}
</update>
<select id="selectOneById" resultMap="brandMap">
select <include refid="queryColumns" />
from brand where id = #{id}
</select>
<select id="selectBrandCount" resultType="integer">
select count(*)
from brand
<where>
<if test="brand.brandName != null and brand.brandName != ''">
brand_name like concat('%', #{brand.brandName}, '%') or brand_name_en like concat('%', #{brand.brandName}, '%')
</if>
<if test="brand.status != null">
status = #{brand.status}
</if>
</where>
</select>
<select id="getBrandPageList" resultMap="brandMap">
select <include refid="queryColumns"/>
from brand
<where>
<if test="brand.brandName != null and brand.brandName != ''">
brand_name like concat('%', #{brand.brandName}, '%') or brand_name_en like concat('%', #{brand.brandName}, '%')
</if>
<if test="brand.status != null">
status = #{brand.status}
</if>
</where>
order by create_time desc
limit #{page.startIndex}, #{page.pageSize}
</select>
</mapper>
\ No newline at end of file
... ...