package com.ssj.service.kmt.dto.exercise;

import com.alibaba.fastjson.JSONArray;
import com.ssj.bean.kmt.kmt.dto.KmtSysUserAuthDto;
import com.ssj.bean.kmt.kmtsys.domain.KmtSysUser;
import com.ssj.framework.core.util.PropertiesUtil;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @Author: chchen
 * @Description
 * @Date Create in 18:58 2019/12/9
 * @Modified By
 */
public class ExerciseUserInfoDto implements Serializable {
    private static final long serialVersionUID = 1L;

    public ExerciseUserInfoDto(){}

    public ExerciseUserInfoDto(KmtSysUser user){

        String value = PropertiesUtil.getValue("KMT_SYS_USER_AUTH");
        if (StringUtils.isNotBlank(value)){
            List<KmtSysUserAuthDto> kmtSysUserAuthDtoList = JSONArray.parseArray(value, KmtSysUserAuthDto.class);
            for (KmtSysUserAuthDto kmtSysUserAuthDto : kmtSysUserAuthDtoList){
                if (kmtSysUserAuthDto.getType().equals(user.getType())){
                    this.type = Integer.parseInt(kmtSysUserAuthDto.getDealType());
                }
            }
        }
        this.loginName = user.getLoginName();
        this.name = user.getName();
    }

    private String loginName;

    private String name;

    private int type;

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }
}
