All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.github.foxnic.web.system.controller.LicenceController Maven / Gradle / Ivy

There is a newer version: 1.7.1.RELEASE
Show newest version
package org.github.foxnic.web.system.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.foxnic.api.error.ErrorDesc;
import com.github.foxnic.api.swagger.InDoc;
import com.github.foxnic.api.transter.Result;
import com.github.foxnic.commons.encrypt.Base64Util;
import com.github.foxnic.springboot.Licence;
import com.github.foxnic.springboot.mvc.RequestParameter;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.github.foxnic.web.framework.licence.LicenceProxy;
import org.github.foxnic.web.proxy.system.LicenceServiceProxy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@InDoc
@Api(tags = "系统服务/许可证")
@ApiSort(0)
@RestController("SysLicenceController")
public class LicenceController {

    @ApiOperation(value = "导入许可证")
    @PostMapping(LicenceServiceProxy.IMPORT)
    public Result importLicence() {
        Long t=System.currentTimeMillis();
        String data= RequestParameter.get().getString("data");
        if(data==null) return ErrorDesc.failure();
        data= Base64Util.decode(data);
        LicenceProxy.LICENCE_DATA= data;
        while (LicenceProxy.LICENCE_DATA!=null) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {}
        }
        LicenceProxy.reset();
        t=5100-(System.currentTimeMillis()-t);
        try {
            Thread.sleep(t);
        } catch (InterruptedException e) {}

        return ErrorDesc.success();
    }

    /**
     * 获取许可证数据
     */
    @ApiOperation(value = "获取许可证信息")
    @PostMapping(LicenceServiceProxy.GET)
    public Result get() {
        Result result=new Result<>();
        result.success(true).data(LicenceProxy.getLicence());
        JSONObject json=LicenceProxy.getModuleConfig("hrm");
        return result;
    }

    /**
     * 获取许可证条目数据
     */
    @ApiOperation(value = "导入许可证条目信息")
    @PostMapping(LicenceServiceProxy.GET_LICENCE_ITEMS)
    public Result getLicenceItems() {
        Result result=new Result<>();
        result.success(true).data(JSONObject.parseObject(JSON.toJSONString(Licence.getItems())));
        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy