main
parent
32d0a6186a
commit
5df75f9511
|
|
@ -87,7 +87,7 @@ public class AppSchoolController extends BaseController
|
||||||
@ApiOperation(value = "新增学校配置", notes = "新增学校配置", httpMethod = "POST")
|
@ApiOperation(value = "新增学校配置", notes = "新增学校配置", httpMethod = "POST")
|
||||||
public AjaxResult add(@RequestBody AppSchool appSchool)
|
public AjaxResult add(@RequestBody AppSchool appSchool)
|
||||||
{
|
{
|
||||||
return toAjax(appSchoolService.insertAppSchool(appSchool));
|
return appSchoolService.insertAppSchool(appSchool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,7 +99,7 @@ public class AppSchoolController extends BaseController
|
||||||
@ApiOperation(value = "修改学校配置", notes = "修改学校配置", httpMethod = "PUT")
|
@ApiOperation(value = "修改学校配置", notes = "修改学校配置", httpMethod = "PUT")
|
||||||
public AjaxResult edit(@RequestBody AppSchool appSchool)
|
public AjaxResult edit(@RequestBody AppSchool appSchool)
|
||||||
{
|
{
|
||||||
return toAjax(appSchoolService.updateAppSchool(appSchool));
|
return appSchoolService.updateAppSchool(appSchool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.app.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.app.domain.AppSchool;
|
import com.ruoyi.app.domain.AppSchool;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,7 +35,7 @@ public interface IAppSchoolService
|
||||||
* @param appSchool 学校配置
|
* @param appSchool 学校配置
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertAppSchool(AppSchool appSchool);
|
public AjaxResult insertAppSchool(AppSchool appSchool);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改学校配置
|
* 修改学校配置
|
||||||
|
|
@ -42,7 +43,7 @@ public interface IAppSchoolService
|
||||||
* @param appSchool 学校配置
|
* @param appSchool 学校配置
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateAppSchool(AppSchool appSchool);
|
public AjaxResult updateAppSchool(AppSchool appSchool);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除学校配置
|
* 批量删除学校配置
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.bean.BeanValidators;
|
import com.ruoyi.common.core.utils.bean.BeanValidators;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -60,12 +61,16 @@ public class AppSchoolServiceImpl implements IAppSchoolService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertAppSchool(AppSchool appSchool) {
|
public AjaxResult insertAppSchool(AppSchool appSchool) {
|
||||||
|
AppSchool entity = appSchoolMapper.selectAppSchoolByName(appSchool.getName());
|
||||||
|
if (entity != null) {
|
||||||
|
return AjaxResult.error(2001,"该学校名称已存在请重新输入!");
|
||||||
|
}
|
||||||
appSchool.setCreateTime(DateUtils.getNowDate());
|
appSchool.setCreateTime(DateUtils.getNowDate());
|
||||||
appSchool.setUpdateTime(DateUtils.getNowDate());
|
appSchool.setUpdateTime(DateUtils.getNowDate());
|
||||||
appSchool.setCreateBy(SecurityUtils.getUsername());
|
appSchool.setCreateBy(SecurityUtils.getUsername());
|
||||||
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return appSchoolMapper.insertAppSchool(appSchool);
|
return AjaxResult.success(appSchoolMapper.insertAppSchool(appSchool));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,10 +80,14 @@ public class AppSchoolServiceImpl implements IAppSchoolService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateAppSchool(AppSchool appSchool) {
|
public AjaxResult updateAppSchool(AppSchool appSchool) {
|
||||||
|
AppSchool entity = appSchoolMapper.selectAppSchoolByName(appSchool.getName());
|
||||||
|
if (entity != null && appSchool.getId() != entity.getId()) {
|
||||||
|
return AjaxResult.error(2001,"该学校名称已存在请重新输入!");
|
||||||
|
}
|
||||||
appSchool.setUpdateTime(DateUtils.getNowDate());
|
appSchool.setUpdateTime(DateUtils.getNowDate());
|
||||||
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return appSchoolMapper.updateAppSchool(appSchool);
|
return AjaxResult.success(appSchoolMapper.updateAppSchool(appSchool));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class AppUserFriendServiceImpl implements IAppUserFriendService
|
||||||
public AjaxResult insertAppUserFriend(AppUserFriend appUserFriend)
|
public AjaxResult insertAppUserFriend(AppUserFriend appUserFriend)
|
||||||
{
|
{
|
||||||
appUserFriend.setCreateTime(DateUtils.getNowDate());
|
appUserFriend.setCreateTime(DateUtils.getNowDate());
|
||||||
appUserFriend.setStatus(0l);
|
appUserFriend.setStatus(appUserFriend.getStatus() == null ? 0l : appUserFriend.getStatus());
|
||||||
AppUserFriend entity = new AppUserFriend();
|
AppUserFriend entity = new AppUserFriend();
|
||||||
entity.setUserId(appUserFriend.getUserId());
|
entity.setUserId(appUserFriend.getUserId());
|
||||||
entity.setFriendId(appUserFriend.getFriendId());
|
entity.setFriendId(appUserFriend.getFriendId());
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package com.ruoyi.app.utils.aliyun.sms;
|
package com.ruoyi.app.utils.aliyun.sms;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.aliyuncs.CommonRequest;
|
import com.aliyuncs.CommonRequest;
|
||||||
import com.aliyuncs.CommonResponse;
|
import com.aliyuncs.CommonResponse;
|
||||||
import com.aliyuncs.DefaultAcsClient;
|
import com.aliyuncs.DefaultAcsClient;
|
||||||
import com.aliyuncs.IAcsClient;
|
import com.aliyuncs.IAcsClient;
|
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||||
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||||
import com.aliyuncs.exceptions.ClientException;
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
import com.aliyuncs.exceptions.ServerException;
|
import com.aliyuncs.exceptions.ServerException;
|
||||||
import com.aliyuncs.http.MethodType;
|
import com.aliyuncs.http.MethodType;
|
||||||
|
|
@ -79,8 +82,14 @@ public class SendNoteUtil {
|
||||||
}
|
}
|
||||||
randomNumber = "1234";
|
randomNumber = "1234";
|
||||||
log.info("--------------------------------------------- " + PhoneNumber + "验证码:" + randomNumber);
|
log.info("--------------------------------------------- " + PhoneNumber + "验证码:" + randomNumber);
|
||||||
|
redisService.setCacheObject(PhoneNumber, randomNumber, 300L, TimeUnit.SECONDS);
|
||||||
|
if (!redisService.hasKey(PhoneNumber)) {
|
||||||
|
return "Redis存入失败";
|
||||||
|
}
|
||||||
|
if (!isChineseMobileNumber(PhoneNumber)) {
|
||||||
|
return sendForeign(PhoneNumber,randomNumber);
|
||||||
|
}
|
||||||
CommonRequest request = new CommonRequest();
|
CommonRequest request = new CommonRequest();
|
||||||
//request.setSysProtocol(ProtocolType.HTTPS);
|
|
||||||
request.setSysMethod(MethodType.POST);
|
request.setSysMethod(MethodType.POST);
|
||||||
request.setSysDomain(dysmsapi);
|
request.setSysDomain(dysmsapi);
|
||||||
request.setSysVersion("2017-05-25");
|
request.setSysVersion("2017-05-25");
|
||||||
|
|
@ -92,10 +101,6 @@ public class SendNoteUtil {
|
||||||
//用户定义的验证码内容
|
//用户定义的验证码内容
|
||||||
request.putQueryParameter("TemplateParam", "{\"code\": \"" + randomNumber + "\"}");
|
request.putQueryParameter("TemplateParam", "{\"code\": \"" + randomNumber + "\"}");
|
||||||
try {
|
try {
|
||||||
redisService.setCacheObject(PhoneNumber, randomNumber, 300L, TimeUnit.SECONDS);
|
|
||||||
if (!redisService.hasKey(PhoneNumber)) {
|
|
||||||
return "Redis存入失败";
|
|
||||||
}
|
|
||||||
CommonResponse response = client.getCommonResponse(request);
|
CommonResponse response = client.getCommonResponse(request);
|
||||||
String returnStr = response.getData();
|
String returnStr = response.getData();
|
||||||
System.out.println(returnStr);
|
System.out.println(returnStr);
|
||||||
|
|
@ -151,6 +156,9 @@ public class SendNoteUtil {
|
||||||
public String sendMessage(String PhoneNumber) {
|
public String sendMessage(String PhoneNumber) {
|
||||||
String homeTem = "SMS_467520300";
|
String homeTem = "SMS_467520300";
|
||||||
String foreignTem = "SMS_468380559";
|
String foreignTem = "SMS_468380559";
|
||||||
|
if (!isChineseMobileNumber(PhoneNumber)) {
|
||||||
|
return sendForeign(PhoneNumber,"1234");
|
||||||
|
}
|
||||||
CommonRequest request = new CommonRequest();
|
CommonRequest request = new CommonRequest();
|
||||||
request.setSysMethod(MethodType.POST);
|
request.setSysMethod(MethodType.POST);
|
||||||
request.setSysDomain(dysmsapi);
|
request.setSysDomain(dysmsapi);
|
||||||
|
|
@ -177,4 +185,53 @@ public class SendNoteUtil {
|
||||||
String regex = "^1[3-9]\\d{9}$";
|
String regex = "^1[3-9]\\d{9}$";
|
||||||
return number.matches(regex);
|
return number.matches(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String sendForeign(String phone,String code){
|
||||||
|
CommonRequest request = new CommonRequest();
|
||||||
|
|
||||||
|
request.setSysMethod(MethodType.POST);
|
||||||
|
request.setSysDomain("dysmsapi.aliyuncs.com");
|
||||||
|
request.setSysVersion("2017-05-25");
|
||||||
|
request.setSysAction("SendMessageToGlobe");
|
||||||
|
request.putQueryParameter("To", phone);
|
||||||
|
request.putQueryParameter("Message", "您的验证码是" + code + "。请不要把验证码泄露给其他人。");
|
||||||
|
//request.putQueryParameter("From", "18773124359");
|
||||||
|
request.putQueryParameter("From", "18773124359");
|
||||||
|
request.putQueryParameter("Type", "OTP");
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommonResponse response = client.getCommonResponse(request);
|
||||||
|
String returnStr = response.getData();
|
||||||
|
System.out.println(returnStr);
|
||||||
|
String data = response.getData();
|
||||||
|
return JSONObject.parseObject(data).getString("Message");
|
||||||
|
} catch (ServerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return e.getErrMsg();
|
||||||
|
} catch (ClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return e.getErrMsg();
|
||||||
|
}
|
||||||
|
/*//初始化acsClient,<accessKeyId>和<accessSecret>"在短信控制台查询即可
|
||||||
|
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou","LTAI5tQMf7PG2rH4U2mZBQnK", "3l8t7cVJGTGGu89AepWtq0CddgZNfU");
|
||||||
|
IAcsClient client = new DefaultAcsClient(profile);
|
||||||
|
// 创建API请求并设置参数
|
||||||
|
SendSmsRequest request = new SendSmsRequest();
|
||||||
|
|
||||||
|
request.setPhoneNumbers("1+4049014566"); // 该参数值为假设值,请您根据实际情况进行填写
|
||||||
|
|
||||||
|
request.setSignName("干杯GoBig"); // 该参数值为假设值,请您根据实际情况进行填写
|
||||||
|
request.setTemplateCode("SMS_468240573");
|
||||||
|
String randomNumber = "1234";
|
||||||
|
request.setTemplateParam("{\"code\": \"" + randomNumber + "\"}");
|
||||||
|
try {
|
||||||
|
SendSmsResponse response = client.getAcsResponse(request);
|
||||||
|
System.out.println(JSON.toJSONString(response));
|
||||||
|
} catch (ServerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue