New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.service.UserService; |
| | | |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"小程序用户管理"}) |
| | | @RestController |
| | | @RequestMapping("/AppUser") |
| | | public class AppUserController { |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @ApiOperation(value = "登陆信息") |
| | | @PostMapping("logins") |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters) { |
| | | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Map<String, Object> result = userService.loginSmallRoutine(parameters); |
| | | if (!result.containsKey("token")) { |
| | | return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); |
| | | } |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/wx/login") |
| | | @ApiOperation(value = "小程序登陆") |
| | | public ResultMessage userLogin(@RequestParam(value = "code") String code |
| | | ) { |
| | | Map<String, Object> result = userService.wxLogin(code); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/wx/exit") |
| | | @ApiOperation(value = "小程序登陆") |
| | | public ResultMessage updateUserId(@RequestParam @ApiParam(value = "userId",name = "用户主键") Integer userId) { |
| | | userService.updateUserId(userId); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | } |