package com.zcxk.service;


import com.zcxk.dao.ParmSettingMapper;
import com.zcxk.entity.ParmSettingEntity;
import com.zcxk.model.LoginUser;
import com.zcxk.util.UserUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Arrays;

/**
 * 参数设置Service接口
 *
 * @author: WYY
 * @date 2021-05-11 10:30
 */
@Service
public class ParmSettingService extends ServiceImpl<ParmSettingMapper, ParmSettingEntity> {

    @Resource
    private ParmSettingMapper parmSettingMapper;

    /**
     * 查列表
     */
    public List<ParmSettingEntity> findList(ParmSettingEntity parmSettingEntity) {
        LoginUser currentUser = UserUtil.getCurrentUser();
        if(currentUser!=null) {
            parmSettingEntity.setTenantId(currentUser.getTenantId());
        }
        return parmSettingMapper.findList(parmSettingEntity);
    }

    /**
     * 批量删除
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean delParmSettingByIds(Long[] ids) {

        return this.removeByIds(Arrays.asList(ids));

    }

    /**
     * 单个删除
     */
    public boolean delParmSettingById(Long id) {


        return this.removeById(id);

    }

    /**
     * 保存
     */
    public boolean addParmSetting(ParmSettingEntity parmSetting) {
        if (this.save(parmSetting)) {
            return true;
        }
        return false;
    }

    /**
     * 修改根居ID
     */
    public boolean updateParmSettingById(ParmSettingEntity parmSetting) {

        if (this.updateById(parmSetting)) {
            return true;
        }
        return false;
    }

    /**
     * 根居ID获取对象
     */
    public ParmSettingEntity findParmSettingById(Long id) {
        return parmSettingMapper.findParmSettingById(id);
    }
}
