发表于: 2018-10-13 22:40:32

1 487


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

今天主要编写相应的接口代码:

Banner图的mybatis Mapperxml:

<?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.iceneet.opreation.dao.BannerMapper" >
 <resultMap id="BaseResultMap" type="com.iceneet.opreation.entity.Banner" >
   <id column="id" property="id" jdbcType="BIGINT" />
   <result column="serial_id" property="serialId" jdbcType="VARCHAR" />
   <result column="title" property="title" jdbcType="VARCHAR" />
   <result column="thumnail" property="thumnail" jdbcType="VARCHAR" />
   <result column="url" property="url" jdbcType="VARCHAR" />
   <result column="interval_time" property="intervalTime" jdbcType="TINYINT" />
   <result column="status" property="status" jdbcType="BIT" />
   <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
   <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
   <result column="created_at" property="createdAt" jdbcType="BIGINT" />
   <result column="updated_at" property="updatedAt" jdbcType="BIGINT" />
 </resultMap>
 <sql id="Base_Column_List" >
   id, serial_id, title, thumnail, url, interval_time, status, created_by, updated_by,
created_at, updated_at
</sql>
 <sql id="Base_Select_Column">
   id,
serial_id,
title,
thumnail,
url,
interval_time,
status,
created_by,
updated_by,
created_at,
updated_at
</sql>
 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
   select
<include refid="Base_Column_List" />
   from banner
where id = #{id,jdbcType=BIGINT}
</select>
 <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
   delete from banner
where id = #{id,jdbcType=BIGINT}
</delete>
 <insert id="insert" parameterType="com.iceneet.opreation.entity.Banner" >
   insert into banner (id, serial_id, title,
thumnail, url, interval_time,
status, created_by, updated_by,
created_at, updated_at)
values (#{id,jdbcType=BIGINT}, #{serialId,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
#{thumnail,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{intervalTime,jdbcType=TINYINT},
#{status,jdbcType=BIT}, #{createdBy,jdbcType=VARCHAR}, #{updatedBy,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT})
</insert>
 <insert id="insertSelective" parameterType="com.iceneet.opreation.entity.Banner" >
   insert into banner
<trim prefix="(" suffix=")" suffixOverrides="," >
     <if test="id != null" >
       id,
</if>
     <if test="serialId != null" >
       serial_id,
</if>
     <if test="title != null" >
       title,
</if>
     <if test="thumnail != null" >
       thumnail,
</if>
     <if test="url != null" >
       url,
</if>
     <if test="intervalTime != null" >
       interval_time,
</if>
     <if test="status != null" >
       status,
</if>
     <if test="createdBy != null" >
       created_by,
</if>
     <if test="updatedBy != null" >
       updated_by,
</if>
     <if test="createdAt != null" >
       created_at,
</if>
     <if test="updatedAt != null" >
       updated_at,
</if>
   </trim>
   <trim prefix="values (" suffix=")" suffixOverrides="," >
     <if test="id != null" >
       #{id,jdbcType=BIGINT},
</if>
     <if test="serialId != null" >
       #{serialId,jdbcType=VARCHAR},
</if>
     <if test="title != null" >
       #{title,jdbcType=VARCHAR},
</if>
     <if test="thumnail != null" >
       #{thumnail,jdbcType=VARCHAR},
</if>
     <if test="url != null" >
       #{url,jdbcType=VARCHAR},
</if>
     <if test="intervalTime != null" >
       #{intervalTime,jdbcType=TINYINT},
</if>
     <if test="status != null" >
       #{status,jdbcType=BIT},
</if>
     <if test="createdBy != null" >
       #{createdBy,jdbcType=VARCHAR},
</if>
     <if test="updatedBy != null" >
       #{updatedBy,jdbcType=VARCHAR},
</if>
     <if test="createdAt != null" >
       #{createdAt,jdbcType=BIGINT},
</if>
     <if test="updatedAt != null" >
       #{updatedAt,jdbcType=BIGINT},
</if>
   </trim>
 </insert>
 <update id="updateByPrimaryKeySelective" parameterType="com.iceneet.opreation.entity.Banner" >
   update banner
<set >
     <if test="serialId != null" >
       serial_id = #{serialId,jdbcType=VARCHAR},
</if>
     <if test="title != null" >
       title = #{title,jdbcType=VARCHAR},
</if>
     <if test="thumnail != null" >
       thumnail = #{thumnail,jdbcType=VARCHAR},
</if>
     <if test="url != null" >
       url = #{url,jdbcType=VARCHAR},
</if>
     <if test="intervalTime != null" >
       interval_time = #{intervalTime,jdbcType=TINYINT},
</if>
     <if test="status != null" >
       status = #{status,jdbcType=BIT},
</if>
     <if test="createdBy != null" >
       created_by = #{createdBy,jdbcType=VARCHAR},
</if>
     <if test="updatedBy != null" >
       updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
     <if test="createdAt != null" >
       created_at = #{createdAt,jdbcType=BIGINT},
</if>
     <if test="updatedAt != null" >
       updated_at = #{updatedAt,jdbcType=BIGINT},
</if>
   </set>
   where id = #{id,jdbcType=BIGINT}
</update>
 <update id="updateByPrimaryKey" parameterType="com.iceneet.opreation.entity.Banner" >
   update banner
set serial_id = #{serialId,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
thumnail = #{thumnail,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
interval_time = #{intervalTime,jdbcType=TINYINT},
status = #{status,jdbcType=BIT},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_by = #{updatedBy,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>


 <!--getbanners  首页获取banners -->
 <select id="getBanners" resultMap="BaseResultMap">
   SELECT
<include refid="Base_Select_Column"/>
   FROM
banner
</select>
 
 <select id="selectChoosenBanner" resultMap="BaseResultMap" parameterType="com.iceneet.opreation.entity.Banner">
   SELECT
<include refid="Base_Select_Column"/>
   FROM
banner
<where>
     <if test="serialId != null">
       serial_id like "%"#{serialId}"%"
</if>
     <if test="title != null">
       and title like "%"#{title}"%"
</if>
     <if test="createdBy != null">
       and created_by like "%"#{createdBy}"%"
</if>
     <if test="updatedBy != null">
       and updated_by like "%"#{updatedBy}"%"
</if>
   </where>
 </select>
</mapper>

dao:

public interface BannerMapper {
int deleteByPrimaryKey(Long id);

   int insert(Banner record);

   int insertSelective(Banner record);

   Banner selectByPrimaryKey(Long id);

   int updateByPrimaryKeySelective(Banner record);

   int updateByPrimaryKey(Banner record);

   List<Banner> getBanners();

   List<Banner> selectChoosenBanner(Banner banner);
}
@Service
public class BannerServiceimpl implements BannerService{

@Autowired
   BannerMapper bannerMapper;

   private static int pageSize = 10;

   @Override
   public List<Banner> getBanners(int pageNum){
PageHelper.startPage(pageNum,pageSize);
       List<Banner> bannerList = bannerMapper.getBanners();
       return bannerList;
   }

public int addBanner(long userId,String title,String thumnail,int intervalTime,String url){
Banner banner = new Banner();
       banner.setTitle(title);
       banner.setIntervalTime(intervalTime);
       banner.setUrl(url);
       banner.setThumnail(thumnail);
       return bannerMapper.insertSelective(banner);
   }

public List<Banner> getChoosenBanner(){
return bannerMapper.getBanners();
   }

public int EditBanner(Banner banner){
return bannerMapper.updateByPrimaryKeySelective(banner);
   }

public int deletBanner(long banner_id){

return bannerMapper.deleteByPrimaryKey(banner_id);
   }

public int ChangeStatus(){
return 0;
   }

其他接口都类似,都是一些增删改查的操作。

明天计划的事情:(一定要写非常细致的内容) 
遇到的问题:(遇到什么困难,怎么解决的) 
收获:(通过今天的学习,学到了什么知识)


返回列表 返回列表
评论

    分享到