package cn.iocoder.yudao.module.identity.controller.app.code;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.identity.controller.admin.code.vo.CodeRespVO;
import cn.iocoder.yudao.module.identity.convert.code.CodeConvert;
import cn.iocoder.yudao.module.identity.service.code.CodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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.annotation.security.PermitAll;

@Api(tags = "APP移动端 - 标识码")
@RestController
@RequestMapping("/identity/identity-code")
@Validated
public class CodeAppController {

    @Resource
    private CodeService codeService;

    @GetMapping("/get")
    @PermitAll
    @ApiOperation("获得标识码信息")
    @ApiImplicitParam(name = "identityCode", value = "二维码内容", required = true, example = "7ozO78BcWlp1AwChcd", dataTypeClass = String.class)
    // @OperateLog(enable = false) // 避免 Post 请求被记录操作日志
    public CommonResult<CodeRespVO> getByCode(@RequestParam("identityCode") String identityCode) {
        return CommonResult.success(CodeConvert.INSTANCE.convert(codeService.getCodeForApp(identityCode)));
    }
}
