|  |  |  | 
|---|
|  |  |  | package com.doumee.api.web; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.Jwt.JwtPayLoad; | 
|---|
|  |  |  | import com.doumee.core.Jwt.JwtTokenUtil; | 
|---|
|  |  |  | import com.doumee.core.annotation.LoginRequired; | 
|---|
|  |  |  | import com.doumee.core.annotation.trace.Trace; | 
|---|
|  |  |  | import com.doumee.core.constants.Constants; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.wx.WxMiniConfig; | 
|---|
|  |  |  | import com.doumee.core.wx.WxMiniUtilService; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Locks; | 
|---|
|  |  |  | import com.doumee.dao.business.web.request.RegisterRequest; | 
|---|
|  |  |  | import com.doumee.dao.business.web.request.WxPhoneRequest; | 
|---|
|  |  |  | import com.doumee.dao.business.web.response.AccountResponse; | 
|---|
|  |  |  | import com.doumee.dao.business.web.response.UserResponse; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDictData; | 
|---|
|  |  |  | import com.doumee.service.business.MemberService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import me.chanjar.weixin.common.error.WxErrorException; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberService memberService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "用户注册", notes = "小程序端") | 
|---|
|  |  |  | @PostMapping("/userRegister") | 
|---|
|  |  |  | public ApiResponse<AccountResponse> userRegister(@RequestBody RegisterRequest registerRequest) { | 
|---|
|  |  |  | return  ApiResponse.success("操作成功",memberService.userRegister(registerRequest)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxMiniUtilService wxMiniUtilService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Trace | 
|---|
|  |  |  | @LoginRequired | 
|---|
|  |  |  | @ApiOperation(value = "微信授权(登录后)", notes = "小程序端") | 
|---|
|  |  |  | @GetMapping("/wxEmpower") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "微信code", required = true) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse wxEmpower(@RequestParam String code) { | 
|---|
|  |  |  | memberService.wxEmpower(code,getMemberId()); | 
|---|
|  |  |  | return  ApiResponse.success("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @ApiOperation(value = "用户注册", notes = "小程序端") | 
|---|
|  |  |  | //    @PostMapping("/userRegister") | 
|---|
|  |  |  | //    public ApiResponse<AccountResponse> userRegister(@RequestBody RegisterRequest registerRequest) { | 
|---|
|  |  |  | //        return  ApiResponse.success("操作成功",memberService.userRegister(registerRequest)); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    @Trace | 
|---|
|  |  |  | //    @LoginRequired | 
|---|
|  |  |  | //    @ApiOperation(value = "微信授权(登录后)", notes = "小程序端") | 
|---|
|  |  |  | //    @GetMapping("/wxEmpower") | 
|---|
|  |  |  | //    @ApiImplicitParams({ | 
|---|
|  |  |  | //            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), | 
|---|
|  |  |  | //            @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "微信code", required = true) | 
|---|
|  |  |  | //    }) | 
|---|
|  |  |  | //    public ApiResponse wxEmpower(@RequestParam String code) { | 
|---|
|  |  |  | //        memberService.wxEmpower(code,getMemberId()); | 
|---|
|  |  |  | //        return  ApiResponse.success("操作成功"); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Trace | 
|---|
|  |  |  | @ApiOperation(value = "微信授权", notes = "小程序端") | 
|---|
|  |  |  | @GetMapping("/wxLogin") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "微信code", required = true) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse<AccountResponse> wxLogin(@RequestParam String code) { | 
|---|
|  |  |  | return  ApiResponse.success("操作成功",memberService.wxLogin(code)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | JwtPayLoad payLoad = new JwtPayLoad("07a9f07178864e57bf1fb34e7a321f08"); | 
|---|
|  |  |  | System.out.println(JwtTokenUtil.generateToken(payLoad)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginRequired | 
|---|
|  |  |  | @ApiOperation(value = "解析微信手机号", notes = "小程序端") | 
|---|
|  |  |  | @PostMapping("/wxPhone") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse<AccountResponse> wxPhone(@RequestBody WxPhoneRequest wxPhoneRequest) { | 
|---|
|  |  |  | wxPhoneRequest.setMemberId(getMemberId()); | 
|---|
|  |  |  | return  ApiResponse.success("操作成功",memberService.wxPhone(wxPhoneRequest)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "测试生成二维码", notes = "小程序端") | 
|---|
|  |  |  | @GetMapping("/generateWXMiniCode") | 
|---|
|  |  |  | public ApiResponse<Locks> generateWXMiniCode() throws WxErrorException { | 
|---|
|  |  |  | Locks locks = new Locks(); | 
|---|
|  |  |  | locks.setCode(12); | 
|---|
|  |  |  | locks.setSiteId("1005"); | 
|---|
|  |  |  | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.ACCESS_TOKEN); | 
|---|
|  |  |  | wxMiniUtilService.generateWXMiniCode(locks, WxMiniConfig.wxMaService.getAccessToken(),"/usr/local/static_resources/bike/bike_file/",""); | 
|---|
|  |  |  | return  ApiResponse.success("操作成功",locks); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|