|  |  |  | 
|---|
|  |  |  | import com.mzl.flower.base.BaseController; | 
|---|
|  |  |  | import com.mzl.flower.base.R; | 
|---|
|  |  |  | import com.mzl.flower.base.ReturnDataDTO; | 
|---|
|  |  |  | import com.mzl.flower.base.cache.StringCacheClient; | 
|---|
|  |  |  | import com.mzl.flower.config.exception.ValidationException; | 
|---|
|  |  |  | import com.mzl.flower.constant.Constants; | 
|---|
|  |  |  | import com.mzl.flower.dto.request.partner.*; | 
|---|
|  |  |  | import com.mzl.flower.dto.response.partner.PartnerDTO; | 
|---|
|  |  |  | import com.mzl.flower.entity.system.User; | 
|---|
|  |  |  | import com.mzl.flower.service.partner.PartnerService; | 
|---|
|  |  |  | import com.mzl.flower.service.system.UserService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.ResponseEntity; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | public class PartnerController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final PartnerService partnerService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StringCacheClient stringCacheClient; | 
|---|
|  |  |  | public static final String SMS_CODE_KEY = "SMS-CODE-KEY"; | 
|---|
|  |  |  | public static final String TOKEN_KEY = "TOKEN-KEY"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String SEPARATOR = ":"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PartnerController(PartnerService partnerService) { | 
|---|
|  |  |  | this.partnerService = partnerService; | 
|---|
|  |  |  | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/phone/update") | 
|---|
|  |  |  | @ApiOperation(value = "合伙人注册手机号修改", notes = "合伙人注册手机号修改") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> phoneUpdate(@Validated @RequestBody UpdatePhoneDTO dto) { | 
|---|
|  |  |  | // TODO | 
|---|
|  |  |  | String tel = dto.getUsername(); | 
|---|
|  |  |  | String smsCode = dto.getSmsCode(); | 
|---|
|  |  |  | if (StringUtils.isBlank(tel)) { | 
|---|
|  |  |  | throw new ValidationException("手机号码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.isBlank(smsCode)) { | 
|---|
|  |  |  | throw new ValidationException("手机验证码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //从缓存中获取验证码 | 
|---|
|  |  |  | String smsCacheCode = stringCacheClient.get(SMS_CODE_KEY + SEPARATOR + Constants.USER_TYPE.admin.name() + SEPARATOR + tel); | 
|---|
|  |  |  | if (!StringUtils.equals(smsCode, smsCacheCode)) { | 
|---|
|  |  |  | throw new ValidationException("手机验证码不正确"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | partnerService.phoneUpdate(dto); | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|