/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
 *
 */
package net.northking.cctp.scriptcase.db.impl;

import net.northking.cctp.scriptcase.db.dao.AtuGlobalVariableDao;
import net.northking.cctp.scriptcase.db.service.AtuGlobalVariableService;
import net.northking.cctp.scriptcase.db.entity.AtuGlobalVariable;

import net.northking.cctp.common.db.BasicDao;
import net.northking.cctp.common.db.PaginationService;

import net.northking.cctp.scriptcase.pub.variable.dto.VariableDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;


/**
 * 全局变量表
 *
 * <p>文件内容由代码生成器产生，请不要手动修改！ <br>
 * createdate:  2022-10-29 11:40:19  <br>
 *
 * @author: maven-cctp-plugin  <br>
 * @since: 1.0 <br>
 */
@Service
@ConditionalOnMissingBean(name = "AtuGlobalVariableServiceImpl")
public class AtuGlobalVariableServiceImpl extends PaginationService<AtuGlobalVariable> implements AtuGlobalVariableService {
    private static final Logger logger = LoggerFactory.getLogger(AtuGlobalVariableServiceImpl.class);

    private final AtuGlobalVariableDao atuGlobalVariableDao;

    public AtuGlobalVariableServiceImpl(AtuGlobalVariableDao atuGlobalVariableDao) {
        this.atuGlobalVariableDao = atuGlobalVariableDao;
    }

    public BasicDao<AtuGlobalVariable> getDao() {
        return atuGlobalVariableDao;
    }

    public AtuGlobalVariable createEntity() {
        return new AtuGlobalVariable();
    }

    @Override
    protected void beforeInsert(AtuGlobalVariable record) {

    }

    @Override
    protected void beforeUpdate(AtuGlobalVariable record) {

    }



    @Override
    public AtuGlobalVariable queryVariable(AtuGlobalVariable var) {
        var.setDelete(false);
        return this.atuGlobalVariableDao.queryVariable(var);
    }

    @Override
    public int updateGlobalValue(VariableDto update) {
        AtuGlobalVariable var = new AtuGlobalVariable();
        var.setProjectId(update.getProjectId());
        var.setName(update.getName());
        var.setDefaultValue(update.getValue());
        var.setDelete(false);
        var.setVariableType(false);
        return this.atuGlobalVariableDao.updateGlobalValue(var);
    }


}

