Search in sources :

Example 1 with AllowAnonymous

use of com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous in project Corgi by kevinYin.

the class WelcomeController method login.

/**
 * 登录接口,sso登录时回调
 * @param request
 * @param response
 * @param account
 * @param password
 * @return
 */
@RequestMapping("/login.do")
@MenuResource("授权登录")
@AllowAnonymous
@ResponseBody
public RestResult login(HttpServletRequest request, HttpServletResponse response, String account, String password) {
    ParameterUtil.assertNotBlank(account, "账户不能为空");
    ParameterUtil.assertNotBlank(password, "密码不能为空");
    AdminAccount adminAccount = adminAccountService.getByAccount(account);
    if (adminAccount == null) {
        return new RestResult(ApiCode.FAILURE, "账号不存在");
    }
    if (!Objects.equals(encoder.encode(password), adminAccount.getPassword())) {
        return new RestResult(ApiCode.FAILURE, "账号密码不正确");
    }
    AdminLoginUser loginUser = new AdminLoginUser();
    loginUser.setAccountId(adminAccount.getUid());
    loginUser.setAppId(AppConstants.APP_ID_DEFAULT);
    AdminContext.saveToCookie(response, loginUser);
    logger.info("登录成功 | uid: {}", adminAccount.getUid());
    return new RestResult(ApiCode.SUCCESS, "");
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) AdminLoginUser(com.ibeiliao.deployment.admin.context.AdminLoginUser) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) AllowAnonymous(com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with AllowAnonymous

use of com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous in project Corgi by kevinYin.

the class CompileLogController method getCompileLog.

@RequestMapping("getCompileLog")
@AllowAnonymous
@ResponseBody
public CompileLogVO getCompileLog(int historyId, int offset) {
    CompileLogVO logVO = new CompileLogVO();
    logVO.setOffset(offset);
    String key = RedisLogKey.getModuleCompileKey(historyId);
    Long count = redis.llen(key);
    // logger.info("编译日志,总数:{}, 当前偏移量:{}", count, offset);
    if (offset == count) {
        return logVO;
    }
    if (count > 0) {
        List<String> logs = redis.lrange(key, offset, count);
        logVO.setLogs(logs);
        logVO.setOffset(count.intValue());
        return logVO;
    }
    return logVO;
}
Also used : CompileLogVO(com.ibeiliao.deployment.admin.vo.deploy.CompileLogVO) AllowAnonymous(com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AllowAnonymous (com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 RestResult (com.ibeiliao.deployment.admin.common.RestResult)1 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 CompileLogVO (com.ibeiliao.deployment.admin.vo.deploy.CompileLogVO)1