package com.product.admin.service;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.product.admin.config.CmnConst;
|
import com.product.admin.config.SystemCode;
|
import com.product.admin.service.idel.IPortalsService;
|
import com.product.common.lang.StringUtils;
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.core.transfer.Transactional;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
|
/**
|
* Copyright LX-BASE
|
*
|
* @Title: PortalsService
|
* @Project: LX-BASE-SERVER
|
* @Date: 2021-03-18 09:55
|
* @Author: ZhouJie
|
* @Description: 门户配置
|
*/
|
@Component
|
public class PortalsService extends AbstractBaseService implements IPortalsService {
|
@Autowired
|
public BaseDao baseDao;
|
|
/**
|
* @Date: 2020-03-18 10:36
|
* @Author: ZhouJie
|
* @Description: 门户配置列表查询
|
*/
|
public DataTableEntity getPortalList(FieldSetEntity fs) throws BaseException {
|
|
DataTableEntity dt = baseDao.listTable(CmnConst.PRODUCT_SYS_PORTALS, null, null, null, null, fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
|
baseDao.loadPromptData(dt);
|
return dt;
|
}
|
|
public FieldSetEntity findUserIndexPortal() throws BaseException {
|
int userType = SpringMVCContextHolder.getCurrentUser().getUserType();
|
FieldSetEntity fieldSetBySQL = baseDao.getFieldSetBySQL("SELECT uuid FROM `product_sys_portals` where portal_type=? ORDER BY sequence limit 1", new Object[]{userType}, false);
|
if (fieldSetBySQL == null || StringUtils.isEmpty(fieldSetBySQL.getUUID())) {
|
throw new BaseException(SystemCode.USER_PORTAL_EMPTY);
|
}
|
return getPortalInfo(fieldSetBySQL);
|
}
|
|
/**
|
* @Date: 2020-03-18 10:18
|
* @Author: ZhouJie
|
* @Description: 门户配置详情查询
|
*/
|
public FieldSetEntity getPortalInfo(FieldSetEntity fs) throws BaseException {
|
FieldSetEntity fss = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_PORTALS, fs.getUUID(), true);
|
DataTableEntity dt = fss.getSubDataTable(CmnConst.PRODUCT_SYS_PORTALS_SUB);
|
if (dt != null && dt.getRows() > 0) {
|
for (int i = 0; i < dt.getRows(); i++) {
|
FieldSetEntity fsub = dt.getFieldSetEntity(i);
|
FieldSetEntity fspage = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PORTAL_COLUMN_CONFIG, CmnConst.UUID + "=?", new Object[]{fsub.getString("page_uuid")}, true);
|
fsub.setValue("page_name", fspage.getString("page_name"));
|
fsub.setValue("page_type", fspage.getString("page_type"));
|
fsub.setValue("is_use", fspage.getString("is_use"));
|
fsub.setValue("chart_name", fspage.getString("chart_name"));
|
fsub.setValue("link_address", fspage.getString("link_address"));
|
fsub.setValue("data_source", fspage.getString("data_source"));
|
fsub.setValue("click_view_more", fspage.getString("click_view_more"));
|
fsub.setValue("is_refresh_button", fspage.getString("is_refresh_button"));
|
fsub.setValue("is_show_underline", fspage.getString("is_show_underline"));
|
fsub.setValue("is_more_button", fspage.getString("is_more_button"));
|
fsub.setValue("is_add_button", fspage.getString("is_add_button"));
|
fsub.setValue("new_url", fspage.getString("new_url"));
|
fsub.setValue("is_show_title", fspage.getString("is_show_title"));
|
fsub.setValue("refresh_time", fspage.getInteger("refresh_time"));
|
fsub.setValue("column_type", fspage.getObject("column_type"));
|
fsub.setValue("color", fspage.getObject("color"));
|
fsub.setValue("icon", fspage.getObject("icon"));
|
String custom_button = fspage.getString("custom_button");
|
if (!StringUtils.isEmpty(custom_button) && JSON.isValid(custom_button)) {
|
JSONObject parse = JSON.parseObject(custom_button);
|
for (String key : parse.keySet()) {
|
String value = parse.getString(key);
|
if (JSON.isValidArray(value)) {
|
parse.put(key, JSON.parseArray(value));
|
}
|
if (JSON.isValidObject(value)) {
|
JSONObject jsonObject = JSON.parseObject(value);
|
parse.put(key, jsonObject);
|
}
|
}
|
fspage.setValue("custom_button", parse);
|
}
|
fsub.setValue("custom_button", fspage.getString("custom_button"));
|
fsub.setValue("is_custom_button", fspage.getString("is_custom_button"));
|
fsub.setValue("title_name", fspage.getString("title_name"));
|
if (!com.alibaba.druid.util.StringUtils.isEmpty(fsub.getString("page_uuid"))) {
|
FieldSetEntity fpage = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_PORTAL_COLUMN_CONFIG, fsub.getString("page_uuid"), false);
|
FieldSetEntity fsrc = null;
|
FieldSetEntity fsmp = null;
|
if (fpage != null && fpage.getInteger("page_type") == 1) {
|
fsrc = baseDao.getFieldSetEntityByFilter("product_sys_report_config", CmnConst.UUID + "=?", new Object[]{fpage.getString("data_source")}, false);
|
}
|
if (fpage != null && fpage.getInteger("page_type") == 2) {
|
fsrc = baseDao.getFieldSetEntityByFilter("product_sys_report_config ", CmnConst.UUID + "=?", new Object[]{fpage.getString("chart_name")}, false);
|
}
|
if (fsrc != null) {
|
fsmp = baseDao.getFieldSetEntityByFilter("product_sys_mvc_page ", "function_uuid = ?", new Object[]{fsrc.getString("function_uuid")}, false);
|
if (fsmp != null) {
|
fsub.setValue("link_address", fsmp.getString("page_url"));
|
}
|
}
|
}
|
}
|
}
|
return fss;
|
//return baseDao.listInternationDataTable(baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_PORTALS, fs.getString(CmnConst.UUID), true),null);
|
}
|
|
/**
|
* @Date: 2020-03-18 11:29
|
* @Author: ZhouJie
|
* @Description: 新增门户配置
|
*/
|
public String addPortal(FieldSetEntity fs) throws BaseException {
|
String addPortal = "addPortal";
|
//判断菜单是否已在其他门户配置
|
if (!StringUtils.isEmpty(fs.getString("portal_menu"))) {
|
FieldSetEntity mfs = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PORTALS, "portal_menu=?", new Object[]{fs.getString("portal_menu")}, false);
|
if (mfs != null) {
|
throw new BaseException(SystemCode.SYSTEM_MENUS_ALREADY_EXIST.getValue(), SystemCode.SYSTEM_MENUS_ALREADY_EXIST.getText(), this.getClass(), addPortal);
|
}
|
}
|
|
//fs.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fs.setValue(CmnConst.CREATED_BY, 1);
|
fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
|
return baseDao.add(fs);
|
}
|
|
/**
|
* @Date: 2020-03-18 14:07
|
* @Author: ZhouJie
|
* @Description: 修改门户配置
|
*/
|
@Transactional
|
public boolean updatePortal(FieldSetEntity fs) throws BaseException {
|
String updatePortal = "updatePortal";
|
//判断菜单是否已在其他门户配置
|
if (!StringUtils.isEmpty(fs.getString("portal_menu"))) {
|
FieldSetEntity mfs = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PORTALS, "portal_menu=?", new Object[]{fs.getString("portal_menu")}, false);
|
if (mfs == null) {
|
throw new BaseException(SystemCode.SYSTEM_MENUS_ALREADY_EXIST.getValue(), SystemCode.SYSTEM_MENUS_ALREADY_EXIST.getText(), this.getClass(), updatePortal);
|
}
|
}
|
//fs.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fs.setValue(CmnConst.UPDATED_BY, 1);
|
fs.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
|
return baseDao.update(fs, true);
|
}
|
|
/**
|
* @Date: 2020-03-18 15:11
|
* @Author: ZhouJie
|
* @Description: 删除门户配置
|
*/
|
@Transactional
|
public boolean deletePortal(FieldSetEntity fs) throws BaseException {
|
|
|
baseDao.delete(CmnConst.PRODUCT_SYS_PORTALS_SUB, "portal_uuid=?", new Object[]{fs.getString("portal_uuid")});
|
/*
|
* if (dt.getRows() > 0) { for (int i = 0; i < dt.getRows(); i++) {
|
* FieldSetEntity fssub = dt.getFieldSetEntity(i); String fuuid =
|
* fssub.getString(CmnConst.UUID);
|
* baseDao.delete(CmnConst.PRODUCT_SYS_PORTALS_SUB, new
|
* Object[]{fssub.getString(CmnConst.UUID)}); } }
|
*/
|
return baseDao.delete(CmnConst.PRODUCT_SYS_PORTALS, new Object[]{fs.getString(CmnConst.UUID)});
|
}
|
|
|
}
|