package com.fdkankan.ucenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fdkankan.ucenter.entity.UcenterSystem;
import com.fdkankan.ucenter.mapper.IUcenterSystemMapper;
import com.fdkankan.ucenter.service.IUcenterSystemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-07-09
 */
@Service
public class UcenterSystemServiceImpl extends ServiceImpl<IUcenterSystemMapper, UcenterSystem> implements IUcenterSystemService {

    @Override
    public UcenterSystem getByLang(String lang) {
        LambdaQueryWrapper<UcenterSystem> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UcenterSystem::getLang,lang);
        return this.getOne(wrapper);
    }

    @Override
    public void saveByLang(UcenterSystem param) {
        UcenterSystem ucenterSystem = getByLang(param.getLang());
        if(ucenterSystem != null){
            param.setId(ucenterSystem.getId());
        }
        this.saveOrUpdate(param);
    }
}
