package com.hotent.portal.controller;

import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.controller.BaseController;
import com.hotent.base.controller.BaseController2;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.util.StringUtil;
import com.hotent.portal.model.MessageLog;
import com.hotent.portal.persistence.manager.MessageLogManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 
 * <pre> 
 * 描述：portal_message_log 控制器类
 * 构建组：x7
 * 作者:zhangxw
 * 邮箱:zhangxw@jee-soft.cn
 * 日期:2019-05-30 21:34:36
 * 版权：广州宏天软件有限公司
 * </pre>
 */
@RestController
@RequestMapping(value="/portal/messageLog/v2")
@Api(tags="消息发送日志2")
@ApiGroup(group= {ApiGroupConsts.GROUP_PORTAL})
public class MessageLogController2 extends BaseController2<MessageLogManager, MessageLog> {
	@Resource
	MessageLogManager messageLogManager;


	
    /**
	 * 新增消息发送日志
	 * @param MessageLog
	 * @throws Exception 
	 * @return
	 * @exception 
	 */
	@PostMapping(value="/save")
	@ApiOperation(value = "新增,更新消息发送日志数据", httpMethod = "POST", notes = "新增,更新消息发送日志数据")
	public CommonResult<String> save(@ApiParam(name="MessageLog",value="消息发送日志业务对象", required = true)@RequestBody MessageLog MessageLog) throws Exception{
		String msg = "添加消息发送日志成功";
		if(StringUtil.isEmpty(MessageLog.getId())){
			messageLogManager.create(MessageLog);
		}else{
			messageLogManager.update(MessageLog);
			 msg = "更新消息发送日志成功";
		}
		return CommonResult.<String>ok().message(msg);
	}


	
	/**
	 * 重新调用接口
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value="/reinvoke/{id}")
	@ApiOperation(value = "接口重调", httpMethod = "POST", notes = "接口重调")
	public CommonResult<String> reinvoke(@ApiParam(name="id",value="业务主键", required = true)@PathVariable String id) throws Exception{
		messageLogManager.reinvoke(id);
		return CommonResult.<String>ok().message("调用成功");
	}
	
	/**
	 * 设置为调用成功
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value="/signSuccess/{id}")
	@ApiOperation(value = "标记为成功", httpMethod = "POST", notes = "标记为成功")
	public CommonResult<String> signSuccess(@ApiParam(name="id",value="业务主键", required = true)@PathVariable String id) throws Exception{
		messageLogManager.signSuccess(id);
		return CommonResult.<String>ok().message("标记成功");
	}
}
