package com.steerinfo.baseinfo.meterbasesystemmessage.service.impl;

import com.steerinfo.baseinfo.meterbaseunitdirect.model.MeterBaseUnitDirect;
import com.steerinfo.framework.mapper.IBaseMapper;
import com.steerinfo.framework.service.impl.BaseServiceImpl;
import com.steerinfo.baseinfo.meterbasesystemmessage.model.MeterBaseSystemMessage;
import com.steerinfo.baseinfo.meterbasesystemmessage.mapper.MeterBaseSystemMessageMapper;
import com.steerinfo.baseinfo.meterbasesystemmessage.service.IMeterBaseSystemMessageService;
import com.steerinfo.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.math.BigDecimal;

/**
 * MeterBaseSystemMessage服务实现：
 * @author generator
 * @version 1.0-SNAPSHORT 2022-02-25 04:07
 * 类描述
 * 修订历史：
 * 日期：2022-02-25
 * 作者：generator
 * 参考：
 * 描述：MeterBaseSystemMessage服务实现
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@Service(value = "meterBaseSystemMessageService")
public class MeterBaseSystemMessageServiceImpl extends BaseServiceImpl<MeterBaseSystemMessage, String> implements IMeterBaseSystemMessageService {

    @Autowired
    private MeterBaseSystemMessageMapper meterBaseSystemMessageMapper;

    @Override
    protected IBaseMapper<MeterBaseSystemMessage, String> getMapper() {
        return meterBaseSystemMessageMapper;
    }

    @Override
    public String checkandadd(MeterBaseSystemMessage model) {
        if (StringUtils.isEmpty(model.getSystemMessageName())) {
            return "公告名称不能为空";
        }
        if (StringUtils.isEmpty(model.getSystemMessageContent())){
            return "公告内容不能为空";
        }
        String no = meterBaseSystemMessageMapper.GetNewID();
        model.setSystemMessageNo(new SimpleDateFormat("yyyyMMdd").format(new Date()) + no);
        model.setCreateTime(new Date());
        model.setVaildFlag("1");//有效
        meterBaseSystemMessageMapper.insert(model);
        return "";
    }
}
