|
@ -1,8 +1,8 @@ |
|
|
/** |
|
|
/** |
|
|
* Copyright (c) 2018 人人开源 All rights reserved. |
|
|
* Copyright (c) 2018 人人开源 All rights reserved. |
|
|
* |
|
|
* <p> |
|
|
* https://www.renren.io
|
|
|
* https://www.renren.io
|
|
|
* |
|
|
* <p> |
|
|
* 版权所有,侵权必究! |
|
|
* 版权所有,侵权必究! |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
@ -19,7 +19,6 @@ import com.elink.esua.epdc.commons.tools.validator.group.AliyunGroup; |
|
|
import com.elink.esua.epdc.commons.tools.validator.group.QcloudGroup; |
|
|
import com.elink.esua.epdc.commons.tools.validator.group.QcloudGroup; |
|
|
import com.elink.esua.epdc.dto.SysSmsDTO; |
|
|
import com.elink.esua.epdc.dto.SysSmsDTO; |
|
|
import com.elink.esua.epdc.enums.PlatformEnum; |
|
|
import com.elink.esua.epdc.enums.PlatformEnum; |
|
|
import com.elink.esua.epdc.remote.ParamsRemoteService; |
|
|
|
|
|
import com.elink.esua.epdc.service.SysSmsService; |
|
|
import com.elink.esua.epdc.service.SysSmsService; |
|
|
import com.elink.esua.epdc.sms.SmsConfig; |
|
|
import com.elink.esua.epdc.sms.SmsConfig; |
|
|
import com.elink.esua.epdc.utils.ModuleConstant; |
|
|
import com.elink.esua.epdc.utils.ModuleConstant; |
|
@ -27,6 +26,7 @@ import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
@ -41,79 +41,96 @@ import java.util.Map; |
|
|
*/ |
|
|
*/ |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("sms") |
|
|
@RequestMapping("sms") |
|
|
@Api(tags="短信服务") |
|
|
@Api(tags = "短信服务") |
|
|
public class SmsController { |
|
|
public class SmsController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysSmsService sysSmsService; |
|
|
private SysSmsService sysSmsService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ParamsRemoteService paramsRemoteService; |
|
|
private ParamsRemoteService paramsRemoteService; |
|
|
|
|
|
|
|
|
private final static String KEY = ModuleConstant.SMS_CONFIG_KEY; |
|
|
private final static String KEY = ModuleConstant.SMS_CONFIG_KEY; |
|
|
|
|
|
|
|
|
@GetMapping("page") |
|
|
@GetMapping("page") |
|
|
@ApiOperation("分页") |
|
|
@ApiOperation("分页") |
|
|
@ApiImplicitParams({ |
|
|
@ApiImplicitParams({ |
|
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , |
|
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), |
|
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , |
|
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), |
|
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , |
|
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), |
|
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , |
|
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), |
|
|
@ApiImplicitParam(name = "mobile", value = "mobile", paramType = "query", dataType="String"), |
|
|
@ApiImplicitParam(name = "mobile", value = "mobile", paramType = "query", dataType = "String"), |
|
|
@ApiImplicitParam(name = "status", value = "status", paramType = "query", dataType="String") |
|
|
@ApiImplicitParam(name = "status", value = "status", paramType = "query", dataType = "String") |
|
|
}) |
|
|
}) |
|
|
public Result<PageData<SysSmsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |
|
|
public Result<PageData<SysSmsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) { |
|
|
PageData<SysSmsDTO> page = sysSmsService.page(params); |
|
|
PageData<SysSmsDTO> page = sysSmsService.page(params); |
|
|
|
|
|
|
|
|
return new Result<PageData<SysSmsDTO>>().ok(page); |
|
|
return new Result<PageData<SysSmsDTO>>().ok(page); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("config") |
|
|
@GetMapping("config") |
|
|
@ApiOperation("获取配置短信") |
|
|
@ApiOperation("获取配置短信") |
|
|
public Result<SmsConfig> config(){ |
|
|
public Result<SmsConfig> config() { |
|
|
SmsConfig config = paramsRemoteService.getValueObject(KEY, SmsConfig.class); |
|
|
SmsConfig config = paramsRemoteService.getValueObject(KEY, SmsConfig.class); |
|
|
|
|
|
|
|
|
return new Result<SmsConfig>().ok(config); |
|
|
return new Result<SmsConfig>().ok(config); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("saveConfig") |
|
|
@PostMapping("saveConfig") |
|
|
@ApiOperation("保存配置短信") |
|
|
@ApiOperation("保存配置短信") |
|
|
@LogOperation("保存配置短信") |
|
|
@LogOperation("保存配置短信") |
|
|
public Result saveConfig(@RequestBody SmsConfig config){ |
|
|
public Result saveConfig(@RequestBody SmsConfig config) { |
|
|
//校验类型
|
|
|
//校验类型
|
|
|
ValidatorUtils.validateEntity(config); |
|
|
ValidatorUtils.validateEntity(config); |
|
|
|
|
|
|
|
|
if(config.getPlatform() == PlatformEnum.ALIYUN.value()){ |
|
|
if (config.getPlatform() == PlatformEnum.ALIYUN.value()) { |
|
|
//校验阿里云数据
|
|
|
//校验阿里云数据
|
|
|
ValidatorUtils.validateEntity(config, AliyunGroup.class); |
|
|
ValidatorUtils.validateEntity(config, AliyunGroup.class); |
|
|
}else if(config.getPlatform() == PlatformEnum.QCLOUD.value()){ |
|
|
} else if (config.getPlatform() == PlatformEnum.QCLOUD.value()) { |
|
|
//校验腾讯云数据
|
|
|
//校验腾讯云数据
|
|
|
ValidatorUtils.validateEntity(config, QcloudGroup.class); |
|
|
ValidatorUtils.validateEntity(config, QcloudGroup.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
paramsRemoteService.updateValueByCode(KEY, JSON.toJSONString(config)); |
|
|
paramsRemoteService.updateValueByCode(KEY, JSON.toJSONString(config)); |
|
|
|
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("send") |
|
|
@PostMapping("send") |
|
|
@ApiOperation("发送短信") |
|
|
@ApiOperation("发送短信") |
|
|
@LogOperation("发送短信") |
|
|
@LogOperation("发送短信") |
|
|
@ApiImplicitParams({ |
|
|
@ApiImplicitParams({ |
|
|
@ApiImplicitParam(name = "mobile", value = "手机好号", paramType = "query", required = true, dataType="String"), |
|
|
@ApiImplicitParam(name = "mobile", value = "手机好号", paramType = "query", required = true, dataType = "String"), |
|
|
@ApiImplicitParam(name = "params", value = "参数", paramType = "query", required = true, dataType="String") |
|
|
@ApiImplicitParam(name = "params", value = "参数", paramType = "query", required = true, dataType = "String") |
|
|
}) |
|
|
}) |
|
|
public Result send(String mobile, String params){ |
|
|
public Result send(String mobile, String params) { |
|
|
sysSmsService.send(mobile, params); |
|
|
sysSmsService.send(mobile, params); |
|
|
|
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@DeleteMapping |
|
|
/** |
|
|
@ApiOperation("删除") |
|
|
* 发送手机验证码 |
|
|
@LogOperation("删除") |
|
|
* |
|
|
public Result delete(@RequestBody Long[] ids){ |
|
|
* @param mobile |
|
|
sysSmsService.deleteBatchIds(Arrays.asList(ids)); |
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|
|
|
|
|
* @author yujintao |
|
|
|
|
|
* @date 2019/9/6 16:50 |
|
|
|
|
|
*/ |
|
|
|
|
|
@GetMapping("sendCode") |
|
|
|
|
|
public Result sendCode(String mobile) { |
|
|
|
|
|
if (StringUtils.isBlank(mobile)) { |
|
|
|
|
|
return new Result().error(); |
|
|
|
|
|
} |
|
|
|
|
|
sysSmsService.sendCode(mobile); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping |
|
|
|
|
|
@ApiOperation("删除") |
|
|
|
|
|
@LogOperation("删除") |
|
|
|
|
|
public Result delete(@RequestBody Long[] ids) { |
|
|
|
|
|
sysSmsService.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|