package com.zt.defaultShowConfig.service; import com.zt.common.service.BaseService; import com.zt.core.context.UserContext; import com.zt.defaultShowConfig.dao.DefaultShowConfigDao; import com.zt.defaultShowConfig.model.DefaultShowConfig; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; @Service public class DefaultShowConfigService extends BaseService { public Map getDefaultShowConfig(String pageName,String pageCode) { Map map = new HashMap(); Long userId = UserContext.getUser().getId(); List list = baseDao.defaultShowConfigList(pageName,pageCode,userId); if (list.size() > 0) { for (DefaultShowConfig defaultShowConfig : list) { map.put(defaultShowConfig.getColumnName(),defaultShowConfig.getIsShow()); } } return map; } @Override public void insert(DefaultShowConfig defaultShowConfig) { Long userId = UserContext.getUser().getId(); List list = baseDao.defaultShowConfigList(defaultShowConfig.getPageName(), defaultShowConfig.getPageCode(),userId); if (list.size() > 0) { baseDao.defaultShowConfigDelete(list); } for (String arr : defaultShowConfig.getColumnList()) { DefaultShowConfig newDefaultShowConfig = new DefaultShowConfig(); newDefaultShowConfig.setPageName(defaultShowConfig.getPageName()); newDefaultShowConfig.setPageCode(defaultShowConfig.getPageCode()); newDefaultShowConfig.setUserId(userId); newDefaultShowConfig.setColumnName(arr); newDefaultShowConfig.setIsShow(defaultShowConfig.getIsShow()); baseDao.insert(newDefaultShowConfig); } } }