package com.fdkankan.ucenter.controller;


import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fdkankan.ucenter.common.ResultData;
import com.fdkankan.ucenter.common.utils.AuthLicenseUtil;
import com.fdkankan.ucenter.util.DateUserUtil;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2022-11-22
 */
@RestController
@RequestMapping("/ucenter/authLicense")
public class AuthLicenseController {


    @GetMapping("/getAuthInfo")
    public ResultData getAuthInfo(){
        JSONObject jsonObject = AuthLicenseUtil.readLicense();
        JSONObject licenseInfo = jsonObject.getJSONObject("licenseInfo");
        JSONObject snInfo = licenseInfo.getJSONObject("snInfo");
        String endDate = snInfo.getStr("endDate");
        Date date = DateUserUtil.getDate(endDate);
        Long days = DateUserUtil.between(date,new Date());
        snInfo.set("expirationDays",days);
        return ResultData.ok(jsonObject);
    }

}

