Commit 0c57ff2f by lijinqi

完成客户端获取appid和secret的接口

parent fd2d3871
package com.luhu.computility.module.apihub.controller.app.appcredential;
import com.luhu.computility.framework.apilog.core.annotation.ApiAccessLog;
import com.luhu.computility.framework.common.pojo.CommonResult;
import com.luhu.computility.framework.common.pojo.PageParam;
import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.common.util.object.BeanUtils;
import com.luhu.computility.framework.excel.core.util.ExcelUtils;
import com.luhu.computility.framework.security.core.util.SecurityFrameworkUtils;
import com.luhu.computility.module.apihub.controller.app.appcredential.vo.AppAppCredentialRespVO;
import com.luhu.computility.module.apihub.dal.dataobject.appcredential.AppCredentialDO;
import com.luhu.computility.module.apihub.service.appcredential.AppCredentialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static com.luhu.computility.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.luhu.computility.framework.common.pojo.CommonResult.success;
@Tag(name = "用户端 - 用户密钥信息")
@RestController
@RequestMapping("/apihub/app-credential")
@Validated
public class AppAppCredentialController {
@Resource
private AppCredentialService appCredentialService;
@GetMapping("/get")
@Operation(summary = "获得用户密钥信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<AppAppCredentialRespVO> getAppCredential() {
AppCredentialDO appCredential = appCredentialService.selectOneByUserId(SecurityFrameworkUtils.getLoginUserId());
return success(BeanUtils.toBean(appCredential, AppAppCredentialRespVO.class));
}
}
\ No newline at end of file
package com.luhu.computility.module.apihub.controller.app.appcredential.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "用户端 - 用户密钥信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class AppAppCredentialRespVO {
@Schema(description = "应用ID,唯一", requiredMode = Schema.RequiredMode.REQUIRED, example = "23068")
@ExcelProperty("应用ID,唯一")
private String appId;
@Schema(description = "AES加密后的应用密钥", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("AES加密后的应用密钥")
private String appSecret;
}
\ No newline at end of file
......@@ -36,6 +36,12 @@ public interface AppCredentialMapper extends BaseMapperX<AppCredentialDO> {
}
default AppCredentialDO selectOneByUserId(Long userId) {
return selectOne(new LambdaQueryWrapperX<AppCredentialDO>()
.eqIfPresent(AppCredentialDO::getUserId, userId));
}
default AppCredentialRespDTO selectOpenByAppId(String appId) {
AppCredentialDO appCredentialDO = selectOne(new LambdaQueryWrapperX<AppCredentialDO>()
.eqIfPresent(AppCredentialDO::getAppId, appId));
......
......@@ -61,11 +61,18 @@ public interface AppCredentialService {
/**
* 获得用户密钥信息
* 根据appId获得用户密钥信息
*
* @param appId 编号
* @return 用户密钥信息
*/
AppCredentialDO getAppSecretByAppid(String appId);
/**
* 获得用户密钥信息
*
* @param userId 编号
* @return 用户密钥信息
*/
AppCredentialDO selectOneByUserId(Long userId);
}
\ No newline at end of file
......@@ -85,5 +85,10 @@ public class AppCredentialServiceImpl implements AppCredentialService {
}
@Override
public AppCredentialDO selectOneByUserId(Long userId) {
return appCredentialMapper.selectOneByUserId(userId);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment