package org.sky.develop.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.sky.core.tool.constant.KdConstant;
import org.sky.develop.mapper.CodeSettingMapper;
import org.sky.develop.pojo.entity.CodeSetting;
import org.sky.develop.service.ICodeSettingService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 代码生成器配置表 服务实现类
 *
 */
@Service
public class CodeSettingServiceImpl extends ServiceImpl<CodeSettingMapper, CodeSetting> implements ICodeSettingService {
	@Override
	@Transactional(rollbackFor = Exception.class)
	public boolean enable(Long id) {
		// 先禁用
		boolean temp1 = this.update(Wrappers.<CodeSetting>update().lambda().set(CodeSetting::getStatus, KdConstant.DB_STATUS_1));
		// 在启用
		boolean temp2 = this.update(Wrappers.<CodeSetting>update().lambda().set(CodeSetting::getStatus, KdConstant.DB_STATUS_2).eq(CodeSetting::getId, id));
		return temp1 && temp2;
	}
}
