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.PlatomixDocumentCate;
import org.springblade.modules.system.entity.PlatomixTemplateCate;
import org.springblade.modules.system.mapper.PlatomixDocumentCateMapper;
import org.springblade.modules.system.mapper.PlatomixTemplateCateMapper;
import org.springblade.modules.system.service.PlatomixDocumentCateService;
import org.springblade.modules.system.service.PlatomixTemplateCateService;
import org.springframework.stereotype.Service;

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

/**
 *
 */
@Service
public class PlatomixDocumentCateServiceImpl extends ServiceImpl<PlatomixDocumentCateMapper, PlatomixDocumentCate>
        implements PlatomixDocumentCateService {

    @Override
    public Boolean customSave(PlatomixDocumentCate entity) {
        if(ObjectUtils.isEmpty(entity.getId())){
            entity.setUpdateUser(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<PlatomixDocumentCate> up = new UpdateWrapper<PlatomixDocumentCate>().lambda().eq(PlatomixDocumentCate::getId, entity.getId());
            return this.update(entity, up);
        }
    }

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




