package com.njcn.cssystem.controller.sendmsg;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.cssystem.pojo.param.MsgSendParam;
import com.njcn.cssystem.service.IMsgSendService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xy
 */
@Slf4j
@RestController
@RequestMapping("/send")
@Api(tags = "消息推送")
@AllArgsConstructor
public class MsgSendController extends BaseController {

    private final IMsgSendService msgSendService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/appMsgSend")
    @ApiOperation("app消息推送")
    public HttpResult<Boolean> appMsgSend(@RequestBody MsgSendParam param){
        String methodDescribe = getMethodDescribe("appMsgSend");
        msgSendService.sendAppNotification(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/smsMsgSend")
    @ApiOperation("短信消息推送")
    public HttpResult<Boolean> smsMsgSend(@RequestBody MsgSendParam param){
        String methodDescribe = getMethodDescribe("smsMsgSend");
        msgSendService.sendSmsForDipEvent(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}
