| | |
| | | import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest; |
| | | import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginResponse; |
| | | import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser; |
| | | import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi; |
| | | import cn.stylefeng.roses.kernel.customer.api.exception.CustomerException; |
| | | import cn.stylefeng.roses.kernel.customer.api.exception.enums.CustomerExceptionEnum; |
| | | import cn.stylefeng.roses.kernel.customer.api.pojo.CustomerInfo; |
| | |
| | | import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO; |
| | | import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser; |
| | | import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | @RequestMapping("/worker") |
| | | public class WorkerController { |
| | | |
| | | @Value("${wxpay.appId}") |
| | | @Value("${wxpay.worker.appId}") |
| | | private String wxAppId; |
| | | |
| | | @Value("${wxpay.appSecret}") |
| | | @Value("${wxpay.worker.appSecret}") |
| | | private String wxSecretKey; |
| | | |
| | | @Resource |
| | |
| | | return new SuccessResponseData(openId); |
| | | } |
| | | |
| | | @ApiOperation(value = "绑定微信OpenId") |
| | | @PostResource(name = "绑定微信OpenId", path = "/bindOpenId") |
| | | @ApiOperation(value = "绑定/解绑微信OpenId") |
| | | @PostResource(name = "绑定/解绑微信OpenId", path = "/bindOpenId") |
| | | public ResponseData<Boolean> bindOpenId(@RequestBody CustomerBindOpenIdRequest req) { |
| | | // 获取当前登录用户信息 |
| | | LoginUser loginUser = LoginContext.me().getLoginUser(); |
| | |
| | | return new SuccessResponseData(update); |
| | | } |
| | | |
| | | @Resource |
| | | private CacheOperatorApi<CustomerInfo> customerInfoCacheOperatorApi; |
| | | |
| | | @ApiOperation(value = "验证码登录") |
| | | @PostResource(name = "验证码登录", path = RuleConstants.NOT_LOGIN + "/smsCodeLogin", requiredPermission = false, requiredLogin = false) |
| | | public ResponseData<LoginResponse> smsCodeLogin(@RequestBody SysSmsVerifyParam req) { |
| | |
| | | if (validCustomer != null && !StatusEnum.ENABLE.getCode().equals(validCustomer.getStatusFlag())) { |
| | | throw new CustomerException(CustomerExceptionEnum.CUSTOMER_STATUS_ERROR, ""); |
| | | } |
| | | |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | |
| | | if (!req.getCode().equals("111111")) { |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | } |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.WORKER)); |
| | | } |
| | |
| | | return new SuccessResponseData<>(customerLoginBizService.phoneLogin(req.getPhone(), CustomerUserTypeEnum.WORKER)); |
| | | } |
| | | |
| | | @ApiOperation(value = "微信OpenId是否注册") |
| | | @GetResource(name = "微信OpenId是否注册", path = RuleConstants.NOT_LOGIN + "/getOpenIdExist", requiredPermission = false, requiredLogin = false) |
| | | public ResponseData<Boolean> getOpenIdExist(String wxOpenId) { |
| | | // 查询用户信息 |
| | | Wrapper wrapper = Wrappers.<Customer>lambdaQuery() |
| | | .eq(Customer::getUserType, CustomerUserTypeEnum.WORKER.getCode()) |
| | | .eq(Customer::getWxOpenId, wxOpenId); |
| | | long count = customerService.count(wrapper); |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(count > 0); |
| | | } |
| | | |
| | | @ApiOperation(value = "微信OpenId登录") |
| | | @PostResource(name = "微信OpenId登录", path = RuleConstants.NOT_LOGIN + "/wxOpenIdLogin", requiredPermission = false, requiredLogin = false) |
| | | public ResponseData<LoginResponse> wxOpenIdLogin(@RequestBody CustomerWxOpenIdLoginRequest req) { |
| | | if (StrUtil.isNotBlank(req.getPhone())) { |
| | | // 验证码通过 |
| | | sysSmsInfoService.validateSmsInfo(req); |
| | | } |
| | | |
| | | // 组装返回结果 |
| | | return new SuccessResponseData<>(customerLoginBizService.wxOpenIdLogin(req.getWxOpenId(), req.getPhone(), CustomerUserTypeEnum.WORKER)); |
| | | return new SuccessResponseData<>(customerLoginBizService.wxOpenIdLogin(req.getWxOpenId(), req.getPhone(), req.getWorkerNo(), CustomerUserTypeEnum.WORKER)); |
| | | } |
| | | |
| | | @ApiOperation(value = "更换手机号") |