package org.springblade.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.system.entity.PlatomixTemplate;
import org.springblade.modules.system.entity.PlatomixTemplateCate;
import org.springblade.modules.system.mapper.PlatomixTemplateMapper;
import org.springblade.modules.system.service.PlatomixTemplateService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 *
 */
@Service
public class PlatomixTemplateServiceImpl extends ServiceImpl<PlatomixTemplateMapper, PlatomixTemplate>
        implements PlatomixTemplateService {

    @Override
    public Boolean customSave(PlatomixTemplate entity) {
        if(ObjectUtils.isEmpty(entity.getId())){
            entity.setCreateUser(AuthUtil.getUserName());
            entity.setCreateId(AuthUtil.getUserId()+"");
            entity.setCreateTime(new Date());
            entity.setUpdateUser(AuthUtil.getUserName());
            entity.setUpdateId(AuthUtil.getUserId()+"");
            entity.setUpdateTime(new Date());
            entity.setTenantId(AuthUtil.getTenantId());
            return this.save(entity);
        }else{
            entity.setUpdateUser(AuthUtil.getUserName());
            entity.setUpdateId(AuthUtil.getUserId()+"");
            entity.setUpdateTime(new Date());
            LambdaUpdateWrapper<PlatomixTemplate> up = new UpdateWrapper<PlatomixTemplate>().lambda().eq(PlatomixTemplate::getId, entity.getId());
            return this.update(entity, up);
        }
    }

    @Override
    public Boolean customRemove(List<Long> idList) {
        return  this.removeBatchByIds(idList);
    }


}




