/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ifish.mapper;

import com.ifish.bean.Tbl_Live_Room;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;

/**
 *
 * @author Administrator
 */
public class Tbl_Live_Room_MapperSql {

    /**
     * 修改直播间信息
     *
     * @param live_Room
     * @return
     */
    public String updateLiveRoom(@Param("live") Tbl_Live_Room live_Room) {
        StringBuilder sb = new StringBuilder();

        sb.append("UPDATE TBL_LIVE_ROOM SET ");

        if (StringUtils.isNotBlank(live_Room.getCameraId())) {
            sb.append("camera_id = #{live.cameraId}, ");
        }
        if (StringUtils.isNotBlank(live_Room.getRoomDesc())) {
            sb.append("room_desc = #{live.roomDesc}, ");
        }
        if (StringUtils.isNotBlank(live_Room.getRoomImg())) {
            sb.append("room_img = #{live.roomImg}, ");
        }
        if (StringUtils.isNotBlank(live_Room.getRoomName())) {
            sb.append("room_name = #{live.roomName}, ");
        }
        if (StringUtils.isNotBlank(live_Room.getRoomStatus())) {
            sb.append("room_status = #{live.roomStatus}, ");
        }
        if (live_Room.getPopularityValue() != null && live_Room.getPopularityValue() >= 0) {
            sb.append("popularity_value = #{live.popularityValue}, ");
        }
        if (live_Room.getZanNum() != null && live_Room.getZanNum() >= 0) {
            sb.append("zanNum = #{live.zanNum}, ");
        }
        if (sb.lastIndexOf(",") == sb.length() - 2) {
            sb.deleteCharAt(sb.length() - 2);
        }
        sb.append(" WHERE room_id=#{live.roomId} ");

        return sb.toString();
    }

}
