package com.hotent.portal.persistence.manager.impl;

import com.hotent.base.model.CommonResult;
import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.UniqueIdUtil;
import org.springframework.stereotype.Service;

import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.portal.model.SysLayoutSetting;
import com.hotent.portal.persistence.dao.SysLayoutSettingDao;
import com.hotent.portal.persistence.manager.SysLayoutSettingManager;

/**
 * 布局设置 处理实现类
 * 
 * @company 广州宏天软件股份有限公司
 * @author maoww
 * @email maoww@jee-soft.cn
 * @date 2018年6月11日
 */
@Service("sysLayoutSettingManager")
public class SysLayoutSettingManagerImpl extends BaseManagerImpl<SysLayoutSettingDao, SysLayoutSetting> implements SysLayoutSettingManager{
	
	@Override
	public SysLayoutSetting getByLayoutId(String layoutId) {
		return baseMapper.getByLayoutId(layoutId);
	}

    @Override
    public CommonResult<String> saveSysLayoutSetting(SysLayoutSetting sysLayoutSetting) {
        String resultMsg=null;
        try {
            SysLayoutSetting setting = getByLayoutId(sysLayoutSetting.getLayoutId());
            if(setting == null){
                sysLayoutSetting.setId(UniqueIdUtil.getSuid());
                create(sysLayoutSetting);
                resultMsg="添加布局设置成功";
            }else{
                BeanUtils.copyNotNullProperties(setting, sysLayoutSetting);
                update(setting);
                resultMsg="更新布局设置成功";
            }
            return new CommonResult<>(true, resultMsg);
        } catch (Exception e) {
            resultMsg="对布局设置操作失败";
            return new CommonResult<>(false, resultMsg,e.getMessage());
        }
    }
}
