From b2eda32b99ddc336372f1cd601d4df23d5f729a8 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期一, 13 三月 2023 18:10:22 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 100 insertions(+), 6 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java index 7781fe9..a5d863a 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java @@ -2,18 +2,23 @@ import com.supersavedriving.user.core.common.annotion.ServiceLog; import com.supersavedriving.user.core.util.ToolUtil; +import com.supersavedriving.user.modular.system.model.AppUser; import com.supersavedriving.user.modular.system.service.IAppUserService; +import com.supersavedriving.user.modular.system.service.IDriverService; import com.supersavedriving.user.modular.system.util.ResultUtil; -import com.supersavedriving.user.modular.system.warpper.ResponseWarpper; -import com.supersavedriving.user.modular.system.warpper.SignInToRegister; +import com.supersavedriving.user.modular.system.warpper.*; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; /** * 用户控制器 @@ -25,10 +30,16 @@ @Autowired private IAppUserService appUserService; + @Autowired + private IDriverService driverService; + + + + @ResponseBody @PostMapping("/base/appUser/appUserLogin") - @ServiceLog(name = "微信登录", url = "/base/appUser/appUserLogin") +// @ServiceLog(name = "微信登录", url = "/base/appUser/appUserLogin") @ApiOperation(value = "微信登录", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "微信jscode", name = "jscode", required = true, dataType = "string"), @@ -50,17 +61,100 @@ @ResponseBody @PostMapping("/base/appUser/signInToRegister") - @ServiceLog(name = "微信手机授权登录", url = "/base/appUser/signInToRegister") +// @ServiceLog(name = "微信手机授权登录", url = "/base/appUser/signInToRegister") @ApiOperation(value = "微信手机授权登录", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ }) - public ResponseWarpper signInToRegister(SignInToRegister signInToRegister){ + public ResponseWarpper<SignInToRegisterWarpper> signInToRegister(SignInToRegister signInToRegister){ try { - ResultUtil resultUtil = appUserService.signInToRegister(signInToRegister); + ResultUtil<SignInToRegisterWarpper> resultUtil = appUserService.signInToRegister(signInToRegister); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } + + + + @ResponseBody + @PostMapping("/base/appUser/queryNearbyDrivers") +// @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") + @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), + @ApiImplicitParam(value = "纬度", name = "lat", required = true, dataType = "string"), + }) + public ResponseWarpper<List<NearbyDriverWarpper>> queryNearbyDrivers(String lon, String lat){ + if(ToolUtil.isEmpty(lat)){ + return ResponseWarpper.success(ResultUtil.paranErr("lat")); + } + if(ToolUtil.isEmpty(lon)){ + return ResponseWarpper.success(ResultUtil.paranErr("lon")); + } + try { + List<NearbyDriverWarpper> list = driverService.queryDriverPosition(lon, lat, 5D); + return ResponseWarpper.success(list); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/base/appUser/setEmergencyContact") +// @ServiceLog(name = "设置紧急联系人", url = "/base/appUser/queryNearbyDrivers") + @ApiOperation(value = "设置紧急联系人", tags = {"用户端-首页"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "string"), + @ApiImplicitParam(value = "电话", name = "phone", required = true, dataType = "string"), + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper setEmergencyContact(String name, String phone){ + if(ToolUtil.isEmpty(name)){ + return ResponseWarpper.success(ResultUtil.paranErr("name")); + } + if(ToolUtil.isEmpty(phone)){ + return ResponseWarpper.success(ResultUtil.paranErr("phone")); + } + try { + Integer uid = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + AppUser appUser = appUserService.selectById(uid); + appUser.setEmergencyContact(name); + appUser.setEmergencyPhone(phone); + appUserService.updateById(appUser); + return ResponseWarpper.success(); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + + + @ResponseBody + @PostMapping("/api/appUser/queryUserInfo") +// @ServiceLog(name = "获取个人信息", url = "/api/appUser/queryUserInfo") + @ApiOperation(value = "获取个人信息", tags = {"用户端-个人中心"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper<UserInfoWarpper> queryUserInfo(){ + try { + Integer uid = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + AppUser appUser = appUserService.selectById(uid); + UserInfoWarpper userInfoWarpper = new UserInfoWarpper(); + BeanUtils.copyProperties(appUser, userInfoWarpper); + return ResponseWarpper.success(userInfoWarpper); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } } -- Gitblit v1.7.1