package com.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.model.OrgBookField;
import com.model.OrgSetting;
import com.model.User;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



public class SysConfigService<psvn> {
    public static final SysConfigService me = new SysConfigService();

    OrgBookField orgBookFieldDao = new OrgBookField().dao();
    OrgSetting orgSettingDao = new OrgSetting().dao();

    public void addOrUpdate(OrgBookField orgBookField, OrgSetting orgSetting){
        OrgBookField old =orgBookFieldDao.findById(orgBookField.getOrgid());
        if (old ==null){
            orgBookField.save();
        }else {
            orgBookField.delete();
            orgBookField.save();
        }

        if (null ==orgSettingDao.findById(orgSetting.getOrgid())){
            orgSetting.save();
        }else{
            orgSetting.update();
        }
    }


    public OrgBookField findOrgBookField(int orgid){
        return orgBookFieldDao.findById(orgid);
    }

    public OrgSetting findOrgSetting(int orgid){
        return orgSettingDao.findById(orgid);
    }
}
