All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nxyfan.framework.auth.controller.AuthClientController Maven / Gradle / Ivy

There is a newer version: 1.5.6
Show newest version
package com.nxyfan.framework.auth.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nxyfan.framework.auth.core.annotation.SaClientCheckLogin;
import com.nxyfan.framework.core.enums.SaClientTypeEnum;
import com.nxyfan.framework.core.param.AuthAccountPasswordLoginParam;
import com.nxyfan.framework.core.param.AuthGetPhoneValidCodeParam;
import com.nxyfan.framework.core.param.AuthPhoneValidCodeLoginParam;
import com.nxyfan.framework.core.result.AuthPicValidCodeResult;
import com.nxyfan.framework.core.service.AuthService;
import com.nxyfan.framework.common.pojo.CommonResult;
import com.nxyfan.framework.core.pojo.SaBaseClientLoginUser;
import com.nxyfan.framework.core.util.StpClientUtil;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * C端登录控制器
 *
 * @author xuyuxiang
 * @date 2021/12/23 21:50
 */
@Api(tags = "C端登录控制器")
@ApiSupport(author = "Nxyfan Caoyang", order = 2)
@RestController
@Validated
public class AuthClientController {

    @Resource
    private AuthService authService;

    /**
     * C端获取图片验证码
     *
     * @author xuyuxiang
     * @date 2022/7/8 9:26
     **/
    @ApiOperationSupport(order = 1)
    @ApiOperation("C端获取图片验证码")
    @GetMapping("/auth/c/getPicCaptcha")
    public CommonResult getPicCaptcha() {
        return CommonResult.data(authService.getPicCaptcha(SaClientTypeEnum.C.getValue()));
    }

    /**
     * C端获取手机验证码
     *
     * @author xuyuxiang
     * @date 2022/7/8 9:26
     **/
    @ApiOperationSupport(order = 2)
    @ApiOperation("C端获取手机验证码")
    @GetMapping("/auth/c/getPhoneValidCode")
    public CommonResult getPhoneValidCode(@Valid AuthGetPhoneValidCodeParam authGetPhoneValidCodeParam) {
        return CommonResult.data(authService.getPhoneValidCode(authGetPhoneValidCodeParam, SaClientTypeEnum.C.getValue()));
    }

    /**
     * C端账号密码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 3)
    @ApiOperation("C端账号密码登录")
    @PostMapping("/auth/c/doLogin")
    public CommonResult doLogin(@RequestBody @Valid AuthAccountPasswordLoginParam authAccountPasswordLoginParam) {
        return CommonResult.data(authService.doLogin(authAccountPasswordLoginParam, SaClientTypeEnum.C.getValue()));
    }

    /**
     * C端手机验证码登录
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 4)
    @ApiOperation("C端手机验证码登录")
    @PostMapping("/auth/c/doLoginByPhone")
    public CommonResult doLoginByPhone(@RequestBody @Valid AuthPhoneValidCodeLoginParam authPhoneValidCodeLoginParam) {
        return CommonResult.data(authService.doLoginByPhone(authPhoneValidCodeLoginParam, SaClientTypeEnum.C.getValue()));
    }

    /**
     * C端退出
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 5)
    @ApiOperation("C端退出")
    @SaClientCheckLogin
    @GetMapping("/auth/c/doLogout")
    public CommonResult doLogout() {
        StpClientUtil.logout();
        return CommonResult.ok();
    }

    /**
     * C端获取用户信息
     *
     * @author xuyuxiang
     * @date 2021/10/15 13:12
     **/
    @ApiOperationSupport(order = 6)
    @ApiOperation("C端获取用户信息")
    @SaClientCheckLogin
    @GetMapping("/auth/c/getLoginUser")
    public CommonResult getLoginUser() {
        return CommonResult.data(authService.getClientLoginUser());
    }
    
    /**
     * 
     * Describe: C端微信公众号登录
     * Author: Administrator  
     * Create Time: 2024年4月21日 上午1:59:05   
     * @param openid
     * @return 结果
     */
    @ApiOperationSupport(order = 7)
    @ApiOperation("C端微信公众号登录")
    @GetMapping("/auth/c/doLoginByWeixinMp")
    public CommonResult doLoginByWeixinMp(@ApiParam(value = "微信用户标识", required = true) @NotBlank(message = "微信用户标识不能为空") @RequestParam String openid) {
        return CommonResult.data(this.authService.doLoginByWeixinMp(openid));
    }
}