#
Junjie
2024-08-01 2ff08d144935938b91af4e725577882976ef4627
zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java
@@ -7,15 +7,11 @@
import com.zy.asrs.common.domain.entity.Parameter;
import com.zy.asrs.common.domain.enums.HtmlNavIconType;
import com.zy.asrs.common.domain.enums.LoginSystemType;
import com.zy.asrs.common.properties.OSinfo;
import com.zy.asrs.common.properties.SystemProperties;
import com.zy.asrs.common.sys.entity.*;
import com.zy.asrs.common.sys.service.*;
import com.zy.asrs.common.utils.RandomValidateCodeUtil;
import com.zy.asrs.framework.annotations.ManagerAuth;
import com.zy.asrs.framework.common.AesUtils;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.exception.CoolException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +42,8 @@
    private RoleResourceService roleResourceService;
    @Autowired
    private HostService hostService;
    @Autowired
    private ConfigService configService;
    @RequestMapping("/login.action")
    @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录")
@@ -337,48 +335,18 @@
        return R.ok(resources);
    }
    @GetMapping(value = "/system/activation/auth")
    public R activation() {
        if (SystemProperties.SYSTEM_ACTIVATION) {
            String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
            String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
            if (null == timeStr) {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
                return R.error();
            }
            Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
            if (new Date().getTime() < exprTime.getTime()) {
                return R.ok().add(DateUtils.convert(exprTime));
            } else {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
                return R.error();
            }
        } else {
            return R.error();
        }
    }
    @RequestMapping("/loginInformation")
    public R getLoginPageInformation() {
        Config loginLogo = configService.selectByCode("loginLogo");
        Config loginCopyrightText = configService.selectByCode("loginCopyrightText");
        Config loginCopyrightImg1 = configService.selectByCode("loginCopyrightImg1");
    @PostMapping(value = "/system/secret/auth")
    @ManagerAuth
    public R systemSecret(@RequestParam(value = "secret") String secret) {
        if (Cools.isEmpty(secret)) {
            return R.error("请输入激活码");
        }
        // 验证激活码
        String timeStr = AesUtils.decrypt(secret, SystemProperties.SALT);
        if (null == timeStr) {
            return R.error("激活码错误");
        }
        Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
        if (new Date().getTime() >= exprTime.getTime()) {
            return R.error("激活码已失效");
        }
        boolean result = SystemProperties.saveActivationCode(OSinfo.getOSname().getActivationCodePath(), secret);
        if (!result) {
            return R.error("激活失败");
        }
        SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE;
        return R.ok("激活成功,有效期至"+DateUtils.convert(exprTime));
        HashMap<String, Object> map = new HashMap<>();
        map.put("loginLogo", loginLogo.getValue());
        map.put("loginCopyrightText", loginCopyrightText.getValue());
        map.put("loginCopyrightImg1", loginCopyrightImg1.getStatus() == 1 ? loginCopyrightImg1.getValue() : "");
        return R.ok().add(map);
    }
}