package com.zcloud.basic.info.app;


import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.framework.utils.CaptchaUtils;
import com.zcloud.basic.info.api.ProblemFeedbackServiceI;
import com.zcloud.basic.info.api.UserServiceI;
import com.zcloud.basic.info.dto.*;
import com.zcloud.basic.info.dto.clientobject.*;
import com.zcloud.gbscommon.translateaop.TranslateField;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * web-adapter
 *
 * @Author zhangyue
 * @Date 2025-11-04 14:07:33
 */
@Api(tags = "APP端用户")
@RequestMapping("/${application.gateway}/appuser")
@RestController
@AllArgsConstructor
public class AppUserController {
    private final UserServiceI userService;
    private final ProblemFeedbackServiceI problemFeedbackService;

//    @ApiOperation("验证手机号是否已注册")
//    @PostMapping("/verifyPhone")
//    public Response verifyPhone(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
//        return userService.verifyPhone(cmd);
//    }

    @ApiOperation("发送验证码")
    @PostMapping("/sendPhoneCode")
    public Response sendPhoneCode(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
        return userService.sendPhoneCode(cmd);
    }


    @ApiOperation("密码找回")
    @PostMapping("/passwordRecover")
    public SingleResponse<UserCO> passwordRecover(@Validated @RequestBody AppUserRegisterCmd cmd) {
        return userService.passwordRecover(cmd);
    }

    @ApiOperation("注册用户")
    @PostMapping("/register")
    public SingleResponse<UserCO> register(@Validated @RequestBody AppUserRegisterCmd cmd) {
        return userService.register(cmd);
    }


    @ApiOperation("完善个人信息(不包括企业,部门,岗位)")
    @PostMapping("/perfectUserInfo")
    public SingleResponse<UserCO> perfectUserInfo(@Validated @RequestBody AppUserInfoCmd cmd) {
        return userService.perfectUserInfo(cmd);
    }

    @ApiOperation("上传人脸识别图片")
    @PostMapping("/updateUserFaceUrl")
    public Response updateUserFaceUrl(@Validated @RequestBody UserUpdateFaceUrlCmd cmd){
        userService.updateUserFaceUrl(cmd);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("扫码入职")
    @PostMapping("/onboarding")
    public Response onboarding(@Validated @RequestBody AppUserOnboardingCmd cmd){
        userService.onboarding(cmd);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("问题反馈")
    @PostMapping("/problemFeedback")
    public SingleResponse<ProblemFeedbackCO> problemFeedback(@Validated @RequestBody ProblemFeedbackAddCmd cmd) {
        return problemFeedbackService.add(cmd);
    }

    @ApiOperation("用户离职申请")
    @PostMapping("/appUserResignation")
    public Response appUserResignation(@Validated @RequestBody AppUserResignationCmd appUserResignationCmd){
        userService.appUserResignation(appUserResignationCmd);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改密码")
    @PostMapping("/updatePassword")
    public Response updatePassword(@Validated @RequestBody AppUserUpdatePassWordCmd cmd){
        return SingleResponse.of(userService.updatePasswordFromApp(cmd));
    }

//    @ApiOperation("校验是否还有入职信息")
//    @PostMapping("/checkOnboarding")
//    public Response checkOnboarding(@Validated @RequestBody AppUserLogOutCmd cmd){
//        userService.checkOnboarding(cmd);
//        return SingleResponse.buildSuccess();
//    }

    @ApiOperation("注销")
    @PostMapping("/logOut")
    public Response logOut(@Validated @RequestBody AppUserLogOutCmd cmd){
        userService.logOut(cmd);
        return SingleResponse.buildSuccess();
    }
    @ApiOperation("app游客登录")
    @PostMapping("/login")
    public SingleResponse<UserLoginCO> login(@Validated @RequestBody UserAppLoginCmd cmd) {
        return SingleResponse.of(userService.login(cmd));
    }
    @ApiOperation("app获取用户在职企业-轮询")
    @PostMapping("/getUserCorpByPhone")
    public SingleResponse<UserLoginCO> getUserCorpByPhone(@Validated @RequestBody UserAppPhoneCmd cmd) {
        return SingleResponse.of(userService.getUserCorpByPhone(cmd));
    }
    @ApiOperation("app获取用户在职企业")
    @PostMapping("/getUserCorpList/{id}")
    public MultiResponse<UserCorpInfoCO> getUserCorpList(@PathVariable("id") Long id) {
        return MultiResponse.of(userService.getUserCorpList(id));
    }
    @ApiOperation("app获取图形验证码")
    @PostMapping("/generateCaptcha")
    public Response generateCaptcha() {
        return SingleResponse.of(userService.generateCaptcha());
    }
}

