package com.huatek.busi.dao;

import com.huatek.busi.entity.BusiOfflineGisBrand;
import com.huatek.busi.entity.BusiOfflineSwitchgearBrand;
import com.huatek.frame.base.util.Constants;
import com.huatek.torch.sql.dao.impl.BaseDao;
import com.huatek.torch.util.uuid.Uuid;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;

/**
 * 开关柜标牌信息表 Dao
 *
 * @author walker_wang
 * @date Jul 4, 2019 1:50:06 PM
 */
@Repository
public class BusiOfflineSwitchgearBrandDao extends BaseDao<BusiOfflineSwitchgearBrand, String> {

    public int saveOrUpdate(BusiOfflineSwitchgearBrand busiOfflineSwitchgearBrand) {
        if(StringUtils.isEmpty(busiOfflineSwitchgearBrand.getId())) {
            busiOfflineSwitchgearBrand.setId(Uuid.getUUID());
            return this.add(busiOfflineSwitchgearBrand);
        }
        return this.updateLocal(busiOfflineSwitchgearBrand);
    }

    public int insert(BusiOfflineSwitchgearBrand busiOfflineSwitchgearBrand){
        busiOfflineSwitchgearBrand.setId(Uuid.getUUID());
        busiOfflineSwitchgearBrand.setCreateTime(LocalDateTime.now());
        busiOfflineSwitchgearBrand.setStatus(Constants.DEFAULT_YES);
        return this.add(busiOfflineSwitchgearBrand);
    }
}

