package com.engine.organization.service.impl;

import com.engine.core.impl.Service;
import com.engine.organization.annotation.Log;
import com.engine.organization.entity.LoggerContext;
import com.engine.organization.entity.po.Demo;
import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.mapper.DemoMapper;
import com.engine.organization.service.DemoService;
import com.engine.organization.util.HrmI18nUtil;
import com.engine.organization.util.LogAspect;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.MapperProxyFactory;
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocService;

import java.lang.reflect.Method;
import java.util.List;

/**
 * @Author weaver_cl
 * @description:
 * @Date 2022/4/27
 * @Version V1.0
 **/
@WeaIocService
public class DemoServiceImpl extends Service implements DemoService {



    @Override
    @Log(operateType = OperateTypeEnum.ADD,operateDesc = "测试自定义日志")
    public List<Demo> list(String name) {

        OrganizationAssert.notNull(name,HrmI18nUtil.getI18nLabel(34721,"参数不能为空") );
        List<Demo> demos = MapperProxyFactory.getProxy(DemoMapper.class).listAll();

        //操作日志记录
        Method method = new Object(){}.getClass().getEnclosingMethod();
        LoggerContext loggerContext = LoggerContext.builder().operatorId(user.getUID()).operatorName(user.getLastname()).build();
        LogAspect logAspect = new LogAspect(DemoServiceImpl.class,method,loggerContext);
        logAspect.start();

        return demos;
    }
}
