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

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

import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.portal.model.SysIndexLayout;
import com.hotent.portal.persistence.dao.SysIndexLayoutDao;
import com.hotent.portal.persistence.manager.SysIndexLayoutManager;

import javax.annotation.Resource;

/**
 * 系统主页布局 处理实现类
 * 
 * @company 广州宏天软件股份有限公司
 * @author maoww
 * @email maoww@jee-soft.cn
 * @date 2018年6月11日
 */
@Service("sysIndexLayoutManager")
public class SysIndexLayoutManagerImpl extends BaseManagerImpl<SysIndexLayoutDao, SysIndexLayout> implements SysIndexLayoutManager{
    @Resource
    SysIndexLayoutManager sysIndexLayoutManager;

    @Override
    public CommonResult<String> saveSysIndexLayout(SysIndexLayout sysIndexLayout) {
        String resultMsg=null;
        Long id=sysIndexLayout.getId();
        try {
            if(id==null||id==0){
                sysIndexLayout.setId(UniqueIdUtil.getUId());
                sysIndexLayoutManager.create(sysIndexLayout);
                resultMsg="添加布局成功";
            }else{
                sysIndexLayoutManager.update(sysIndexLayout);
                resultMsg="更新布局成功";
            }
            return new CommonResult<>(true, resultMsg, null);
        } catch (Exception e) {
            resultMsg="对布局操作失败";
            return new CommonResult<>(false, resultMsg, null);
        }
    }
}
