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.base.util.UniqueIdUtil;
import com.hotent.i18n.persistence.manager.I18nMessageErrorManager;
import com.hotent.i18n.persistence.model.I18nMessageError;
import com.hotent.i18n.util.I18nUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 *
 * <pre>
 * 描述：国际化资源异常日志 控制器类
 * @author zhaoxy
 * @company 广州宏天软件股份有限公司
 * @email zhxy@jee-soft.cn
 * @date 2018-06-06 14:20
 * </pre>
 */
@RestController
@RequestMapping("/i18n/custom/i18nMessageError/v2/")
@Api(tags="国际化资源异常日志2")
@ApiGroup(group= {ApiGroupConsts.GROUP_PORTAL})
public class I18nMessageErrorController2 extends BaseController2<I18nMessageErrorManager, I18nMessageError> {
	@Resource
	I18nMessageErrorManager i18nMessageErrorManager;


	@RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "保存国际化资源异常日志信息", httpMethod = "POST", notes = "保存国际化资源异常日志信息")
	public CommonResult<String> save(@ApiParam(name="i18nMessageError",value="error的实体定义", required = true) @RequestBody I18nMessageError i18nMessageError) throws Exception{
		String resultMsg=null;
		String id=i18nMessageError.getId();
		if(StringUtil.isEmpty(id)){
			i18nMessageError.setId(UniqueIdUtil.getSuid());
			i18nMessageErrorManager.create(i18nMessageError);
			resultMsg=I18nUtil.getMessage("i18nMessageError.addSuccess",LocaleContextHolder.getLocale());
		}else{
			i18nMessageErrorManager.update(i18nMessageError);
			resultMsg= I18nUtil.getMessage("i18nMessageError.updateSuccess",LocaleContextHolder.getLocale());
		}
		return CommonResult.<String>ok().message(resultMsg);
	}

}
