package com.steerinfo.ems.tcm0324.service.impl;

import com.steerinfo.ems.tcm0324.mapper.TCm0324Mapper;
import com.steerinfo.ems.tcm0324.model.TCm0324;
import com.steerinfo.ems.tcm0324.service.ITCm0324Service;
import com.steerinfo.framework.mapper.IBaseMapper;
import com.steerinfo.framework.model.ICreatePO;
import com.steerinfo.framework.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * TCm0324服务实现：
 * @author generator
 * @version 1.0-SNAPSHORT 2019-10-28 09:32
 * 类描述
 * 修订历史：
 * 日期：2019-10-28
 * 作者：generator
 * 参考：
 * 描述：TCm0324服务实现
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@Service(value = "tCm0324Service")
public class TCm0324ServiceImpl extends BaseServiceImpl<TCm0324, String> implements ITCm0324Service {

    @Autowired
    private TCm0324Mapper tCm0324Mapper;

    @Override
    protected IBaseMapper<TCm0324, String> getMapper() {
        return tCm0324Mapper;
    }

    @Override
    public TCm0324 add(TCm0324 t) {
        if (t instanceof ICreatePO) {
            this.setCreate((ICreatePO)t);
        }
        this.getMapper().insert(t);
        return t;
    }

    public TCm0324 updatelimit(TCm0324 model){
        tCm0324Mapper.updatelimit(model);
        tCm0324Mapper.update0315limit(model);
        return tCm0324Mapper.selectByPrimaryKey(model.getRecordid());
    }

    @Override
    public int batchAdd(List<TCm0324> list) {
        list.stream().forEach((t) -> {
            if (t instanceof ICreatePO) {
                this.setCreate((ICreatePO)t);
            }
        });
        return this.getMapper().batchInsert(list);
    }
}
