package com.zcloud.controller.aiwarnning;

import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.dsno3.register.QyRegisterMapper;
import com.zcloud.util.Base64Utils;
import com.zcloud.util.ReturnMap;
import com.zcloud.util.UuidUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author lin
 */
@Controller
@RequestMapping("/app/v1/")
public class AppVerificationController extends BaseController {

    @Resource
    private QyRegisterMapper qyRegisterMapper;

    @RequestMapping(value = "/getLoginImages")
    @ResponseBody
    public ReturnMap getLoginImages() throws Exception {
        PageData pageData = this.getPageData();
        String secretKey = pageData.getString("secretKey");
        PageData qyRegister = qyRegisterMapper.getInfoBySecretKey(secretKey);
        if (qyRegister == null) {
            // 没单独加配置哪么是2099年
            return ReturnMap.ok().put("data", Base64Utils.encode("https://qaaq.qhdsafety.com/assets/verification1.34be1707.jpg,2199-01-01".getBytes()));
        }
        // 单独加配置用配置好的
        String endDate = qyRegister.getString("endDate");
        return ReturnMap.ok().put("data", Base64Utils.encode(("https://qaaq.qhdsafety.com/assets/verification1.34be1707.jpg" + "," + endDate).getBytes()));
    }
}
