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.query.QueryOP;
import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.CommonResultUtil;
import com.hotent.base.util.StringUtil;
import com.hotent.base.util.UniqueIdUtil;
import com.hotent.portal.model.MsgTemplate;
import com.hotent.portal.persistence.manager.MsgTemplateManager;
import com.hotent.uc.api.impl.util.ContextUtil;
import com.hotent.uc.api.model.IGroup;
import com.hotent.uc.api.service.IUserGroupService;
import com.hotent.uc.api.service.IUserService;
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;

/**
 * 描述：消息模版 控制器类
 * @company 广州宏天软件有限公司
 * @author wanghb
 * @email wanghb@jee-soft.cn
 * @date 2018年7月19日
 */
@RestController
@RequestMapping("/flow/MsgTemplate/v2")
@Api(tags="消息模板管理2")
@ApiGroup(group= {ApiGroupConsts.GROUP_PORTAL})
public class MsgTemplateController2 extends BaseController2<MsgTemplateManager, MsgTemplate> {
	@Resource
	MsgTemplateManager MsgTemplateManager;
	@Resource
	IUserService userServiceImpl;
	@Resource
	IUserGroupService userGroupService;


	/**
	 * 保存消息模版信息
	 * @param msgTemplate
	 * @throws Exception 
	 * void
	 * @exception 
	 */
	@RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "保存消息模版信息", httpMethod = "POST", notes = "保存消息模版信息")
	public CommonResult<String> save(
			@ApiParam(name="template",value="代理对象", required = true) @RequestBody MsgTemplate msgTemplate)throws Exception {
		CommonResult<String> commonResult = MsgTemplateManager.saveMsgTemplate(msgTemplate);
		return CommonResultUtil.<String>getResult(commonResult);
	}


	
	/**
	 * 设置消息模板未默认
	 * @param request
	 * @param reponse
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="setDefault",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "设置消息模板未默认", httpMethod = "GET", notes = "设置消息模板未默认")
	public CommonResult<String> setDefault(
			@ApiParam(name="id",value="模板id", required = true) @RequestParam String id) throws Exception{
		MsgTemplateManager.setDefault(id);
		return CommonResult.<String>ok().message("设置默认成功");
	}

	/**
	 * 设置消息模板未默认
	 * @param request
	 * @param reponse
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="setNotDefault",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "取消默认消息模板", httpMethod = "GET", notes = "取消默认消息模板")
	public CommonResult<String> setNotDefault(
			@ApiParam(name="id",value="模板id", required = true) @RequestParam String id) throws Exception{
		MsgTemplateManager.setNotDefault(id);
		return CommonResult.<String>ok().message("取消默认成功");
	}
}
