| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.moral.util.MessageUtils;
|
| | | import com.taobao.api.ApiException;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.moral.common.bean.AppData;
|
| | |
| | | List<Organization> organizations = organizationService.getOrganizationsByAreaName(parameters);
|
| | | return new AppData<List<Organization>>(organizations);
|
| | | }
|
| | |
|
| | | /**
|
| | | * Send SMS
|
| | | *
|
| | | * @param mobile
|
| | | * @return
|
| | | */
|
| | | @PostMapping("sendSms")
|
| | | public AppData<String> sendSms(String mobile) {
|
| | | AppData apiData = new AppData();
|
| | |
|
| | | if (StringUtils.isBlank(mobile)){
|
| | | apiData.setErrno(1);
|
| | | apiData.setMessage("没有输入手机号码");
|
| | | apiData.setData("{}");
|
| | | return apiData;
|
| | | }
|
| | | OperateUser user = operateUserService.getOperateUserByMobile(mobile);
|
| | | if (user==null){
|
| | | apiData.setErrno(1);
|
| | | apiData.setMessage("手机号没有关联用户");
|
| | | apiData.setData("{}");
|
| | | return apiData;
|
| | | }
|
| | | //生成验证码
|
| | | int code = (int)((Math.random() * 9 + 1) * 100000);
|
| | | user.setCode(String.valueOf(code));
|
| | | operateUserService.updateOperateUserCode(user);
|
| | |
|
| | | //发送到手机
|
| | | try {
|
| | | int state = MessageUtils.sendMsg(mobile, String.valueOf(code));
|
| | | if(state==0){
|
| | | apiData.setErrno(0);
|
| | | apiData.setMessage("发送验证码成功");
|
| | | apiData.setData("{}");
|
| | | return apiData;
|
| | | }
|
| | | if(state==1){
|
| | | apiData.setErrno(1);
|
| | | apiData.setMessage("发送验证码失败");
|
| | | apiData.setData("{}");
|
| | | return apiData;
|
| | | }
|
| | | } catch (ApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return new AppData<String>("");
|
| | | }
|
| | | }
|