package com.app.admin.framework.system.organization.log;

import com.app.admin.framework.system.organization.controller.SysOrganizationController;
import com.app.admin.framework.system.organization.view.SysOrganizationView;
import com.app.framework.core.log.intercept.LogInterceptSupport;
import com.app.framework.core.log.result.LogResult;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/**
 * 组织机构日志记录
 */
@Component
public class SysOrganizationLogIntercept extends LogInterceptSupport<SysOrganizationController> {

    public LogResult saveByEntity(HttpServletRequest request, SysOrganizationView entity){
        LogResult result = new LogResult();
        result.setOperType(entity.getId() == null ? "添加机构" : "修改机构");
        result.addColumn("name", "机构名称", entity.getName());
        return result;
    }

    public LogResult deleteById(HttpServletRequest request, Long oid) {
        LogResult result = new LogResult();
        result.setOperType("删除机构");
        result.addColumn("id", "机构ID", oid);
        return result;
    }

    public LogResult batchDelete(HttpServletRequest request, Long oids[]) {
        LogResult result = new LogResult();
        result.setOperType("删除机构");
        result.addColumn("id", "机构ID", Arrays.toString(oids));
        return result;
    }
}
