package com.dcsoft.system.face.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.dcsoft.common.core.constant.CacheConstants;
import com.dcsoft.common.core.utils.StringUtils;
import com.dcsoft.common.redis.service.RedisService;
import com.dcsoft.system.face.domain.FaceStudent;
import com.dcsoft.system.face.service.HumanService;
import com.dcsoft.system.face.service.IIDaasService;
import com.dcsoft.system.utils.HttpUtil;
import com.dcsoft.system.utils.ImageToBase64Utils;
import com.dcsoft.system.utils.PictureUtils;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户管理 服务层处理
 *
 * @author xueyi
 */
@Service
public class HumanServiceImpl implements HumanService {



    //@Value("${human.url}")
    public String human;
    //** 资源映射路径 前缀 *//*
    //@Value("${human.token}")
    public String token;

    //@Value("${human.isable}")
    public Boolean isable;

    @Override
    public String syncFace(FaceStudent faceStudent) {
        String response="";
        if(isable){
            String url=human+"/v1/datacenter/human_face/api/sync";
            Map<String, Object> paramMap=new HashMap<>();
            paramMap.put("unionId",faceStudent.getStuId());
            MultipartFile file=PictureUtils.createMultipartFile(faceStudent.getImgs(),"face");
            paramMap.put("type",faceStudent.getSync());
            response=HttpUtil.syncFace(url,token, paramMap,file);
        }
        return response;
    }
}
