message
parent
6a4a832671
commit
1581e963c9
|
|
@ -1,14 +1,22 @@
|
||||||
package org.qinan.safetyeval.adapter.web;
|
package org.qinan.safetyeval.adapter.web;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.jjb.saas.message.client.message.facede.MessageFacade;
|
||||||
|
import com.jjb.saas.message.client.message.request.MessageSendCmd;
|
||||||
|
import com.jjb.saas.message.client.message.request.MessageTargetCmd;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.qinan.safetyeval.client.api.AccountApi;
|
import org.qinan.safetyeval.client.api.AccountApi;
|
||||||
import org.qinan.safetyeval.client.co.AccountCO;
|
import org.qinan.safetyeval.client.co.AccountCO;
|
||||||
import org.qinan.safetyeval.client.dto.AccountAddCmd;
|
import org.qinan.safetyeval.client.dto.AccountAddCmd;
|
||||||
import org.qinan.safetyeval.client.dto.AccountModifyCmd;
|
import org.qinan.safetyeval.client.dto.AccountModifyCmd;
|
||||||
import org.qinan.safetyeval.client.dto.AccountPageQuery;
|
import org.qinan.safetyeval.client.dto.AccountPageQuery;
|
||||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
|
import org.qinan.safetyeval.client.dto.SendMessageCmd;
|
||||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -25,6 +33,7 @@ import javax.annotation.Resource;
|
||||||
*
|
*
|
||||||
* @author safety-eval
|
* @author safety-eval
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Api(tags = "用户管理")
|
@Api(tags = "用户管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/account")
|
@RequestMapping("/account")
|
||||||
|
|
@ -33,6 +42,9 @@ public class AccountController {
|
||||||
@Resource
|
@Resource
|
||||||
private AccountApi accountApi;
|
private AccountApi accountApi;
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private MessageFacade messageFacade;
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public SingleResponse<AccountCO> add(@Validated @RequestBody AccountAddCmd cmd) {
|
public SingleResponse<AccountCO> add(@Validated @RequestBody AccountAddCmd cmd) {
|
||||||
|
|
@ -62,4 +74,25 @@ public class AccountController {
|
||||||
public PageResponse<AccountCO> page(@Validated AccountPageQuery query) {
|
public PageResponse<AccountCO> page(@Validated AccountPageQuery query) {
|
||||||
return accountApi.page(query);
|
return accountApi.page(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("发送短信")
|
||||||
|
@PostMapping("/sendMessage")
|
||||||
|
public com.alibaba.cola.dto.SingleResponse<Boolean> sendMessage(@Validated @RequestBody SendMessageCmd cmd) {
|
||||||
|
MessageSendCmd messageSendCmd = new MessageSendCmd();
|
||||||
|
messageSendCmd.setBusinessId(UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
|
||||||
|
MessageTargetCmd messageTargetCmd = new MessageTargetCmd();
|
||||||
|
messageTargetCmd.setUserId(cmd.getUserId());
|
||||||
|
messageSendCmd.setTargetCmd(messageTargetCmd);
|
||||||
|
|
||||||
|
messageSendCmd.setSourceCode("MS000146");
|
||||||
|
messageSendCmd.setNeedTokenEnum(false);
|
||||||
|
messageSendCmd.setParams(cmd.getParams());
|
||||||
|
|
||||||
|
log.info("发送短信参数: messageSendCmd: {}", JSONUtil.toJsonStr(messageSendCmd));
|
||||||
|
com.alibaba.cola.dto.SingleResponse<Boolean> result = messageFacade.send(messageSendCmd);
|
||||||
|
log.info("发送短信结果: result: {}", JSONUtil.toJsonStr(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.qinan.safetyeval.client.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信命令
|
||||||
|
*
|
||||||
|
* @author safety-eval
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SendMessageCmd {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "消息接受人ID", required = true)
|
||||||
|
@NotNull(message = "消息接受人ID不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "消息模板编码", required = true)
|
||||||
|
@NotBlank(message = "消息模板编码不能为空")
|
||||||
|
private String sourceCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "消息模板参数")
|
||||||
|
private Map<String, Object> params;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue