whyclxw
2025-01-20 364adf83c47366a5b01dfe005fd0eed11f9346e6
src/main/java/com/whyc/controller/UserInfController.java
@@ -6,6 +6,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@@ -87,4 +88,45 @@
        return service.updateUinf(uinf);
    }
    @GetMapping("searchUKeyToUName")
    @ApiOperation(value = "根据Ukey查询用户")
    public Response searchUKeyToUName(@RequestParam String ukeyId){
        UserInf userInf = service.getUserByUKeyId(ukeyId);
        Response response = new Response();
        if (userInf!=null){
            response.setII(1,true,userInf,"UKey有绑定用户");
        }else{
            response.set(1,false,"Ukey没有绑定用户");
        }
        return response;
    }
    @GetMapping("searchUNameToUKey")
    @ApiOperation(value = "根据用户名查绑定的Ukey")
    public Response searchUNameToUKey(@RequestParam String uname){
        UserInf userInf = service.getUserByUserName(uname);
        Response response = new Response();
        if (userInf!=null){
            if (StringUtils.isEmpty(userInf.getUkeyId())){
                response.set(-1,false,"该用户没有绑定Ukey");
            }else {
                response.setII(1,true,userInf,"该用户有绑定Ukey");
            }
        }else{
            response.set(0,false,"该用户不存在");
        }
        return response;
    }
    @PostMapping("bindUkey")
    @ApiOperation(value = "绑定uKey")
    public Response bindUkey(@RequestBody UserInf userInf){
        boolean b = service.bindUkey(userInf);
        if (b){
            return new Response().set(1,true,"绑定成功");
        }else {
            return new Response().set(1,false,"绑定失败");
        }
    }
}