|
|
|
@ -18,6 +18,8 @@ import com.hai.service.HighUserCouponService; |
|
|
|
|
import com.hai.service.HighUserService; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.apache.poi.util.StringUtil; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Auther: 袁野 |
|
|
|
@ -79,37 +82,34 @@ public class HighUserController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updateUserPhone", method = RequestMethod.GET) |
|
|
|
|
@RequestMapping(value = "/bindUserPhone", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "修改用户手机号") |
|
|
|
|
public ResponseData updateUserPhone(@RequestParam(value = "phone", required = true) String phone, |
|
|
|
|
@ApiOperation(value = "绑定用户手机号") |
|
|
|
|
public ResponseData bindUserPhone(@RequestParam(value = "phone", required = true) String phone, |
|
|
|
|
@RequestParam(value = "code", required = true) String code, |
|
|
|
|
HttpServletRequest request) { |
|
|
|
|
HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
VerifyCode verifyCode = VerifyCodeStorage.getDate(phone); |
|
|
|
|
if(verifyCode == null) { |
|
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "验证码错误"); |
|
|
|
|
log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
|
} |
|
|
|
|
if(!verifyCode.getObject().equals(code)) { |
|
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "验证码错误"); |
|
|
|
|
log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
|
} |
|
|
|
|
// 用户
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
|
|
|
|
HighUser highUser = highUserService.findByUserId(userInfoModel.getHighUser().getId()); |
|
|
|
|
if (highUser == null) { |
|
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "未找到用户"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); |
|
|
|
|
} |
|
|
|
|
highUser.setPhone(phone); |
|
|
|
|
highUserService.updateUser(highUser); |
|
|
|
|
return ResponseMsgUtil.success("修改成功"); |
|
|
|
|
|
|
|
|
|
HighUser highUser = highUserService.bindUserPhone(phone, request); |
|
|
|
|
|
|
|
|
|
HighUserModel highUserModel = new HighUserModel(); |
|
|
|
|
highUser.setPassword(null); |
|
|
|
|
highUserModel.setHighUser(highUser); |
|
|
|
|
SessionObject so = new SessionObject(highUser.getOpenId(), 1 , highUserModel); |
|
|
|
|
userCenter.save(request, response, so); |
|
|
|
|
return ResponseMsgUtil.success(so); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighUserController --> updateUserPhone() error!", e); |
|
|
|
|
log.error("HighUserController --> bindUserPhone() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|