package com.doumee.cloud.web;
|
|
import com.doumee.api.BaseController;
|
import com.doumee.config.annotation.LoginNoRequired;
|
import com.doumee.core.annotation.pr.PreventRepeat;
|
import com.doumee.core.constants.ResponseStatus;
|
import com.doumee.core.exception.BusinessException;
|
import com.doumee.core.model.ApiResponse;
|
import com.doumee.core.model.LoginUserInfo;
|
import com.doumee.core.utils.Constants;
|
import com.doumee.dao.system.dto.LoginPhoneDTO;
|
import com.doumee.service.business.YwCustomerH5AuthService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
@Api(tags = "【公众号】商户登录")
|
@RestController
|
@LoginNoRequired
|
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX + "/web/customer")
|
public class YwCustomerWebController extends BaseController {
|
|
@Autowired
|
private YwCustomerH5AuthService ywCustomerH5AuthService;
|
|
@PreventRepeat
|
@ApiOperation("商户短信验证码登录")
|
@PostMapping("/loginByPhone")
|
public ApiResponse<String> loginByPhone(@Validated @RequestBody LoginPhoneDTO dto) {
|
try {
|
return ApiResponse.success(ywCustomerH5AuthService.loginByPhone(dto));
|
} catch (BusinessException e) {
|
return ApiResponse.failed(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
return ApiResponse.failed(ResponseStatus.SERVER_ERROR);
|
}
|
}
|
|
@ApiOperation("获取当前商户登录信息")
|
@GetMapping("/getUserInfo")
|
public ApiResponse<LoginUserInfo> getUserInfo(@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
|
LoginUserInfo user = this.getLoginUser(token);
|
if (user == null || !Constants.equalsInteger(user.getH5UserType(), LoginUserInfo.H5_USER_CUSTOMER)) {
|
return ApiResponse.failed("登录已失效");
|
}
|
return ApiResponse.success(ywCustomerH5AuthService.buildLoginUserInfo(user.getCustomerId()));
|
}
|
}
|