|
@@ -1,20 +1,25 @@
|
|
|
package com.dgtly.wxportal.service.impl;
|
|
package com.dgtly.wxportal.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.dgtly.common.constant.UserConstants;
|
|
import com.dgtly.common.constant.UserConstants;
|
|
|
-import com.dgtly.common.core.controller.ApiBaseController;
|
|
|
|
|
import com.dgtly.common.core.domain.Ztree;
|
|
import com.dgtly.common.core.domain.Ztree;
|
|
|
import com.dgtly.common.utils.StringUtils;
|
|
import com.dgtly.common.utils.StringUtils;
|
|
|
import com.dgtly.system.domain.SysRole;
|
|
import com.dgtly.system.domain.SysRole;
|
|
|
import com.dgtly.system.domain.SysUser;
|
|
import com.dgtly.system.domain.SysUser;
|
|
|
import com.dgtly.system.mapper.SysRoleMenuMapper;
|
|
import com.dgtly.system.mapper.SysRoleMenuMapper;
|
|
|
import com.dgtly.system.service.ISysConfigService;
|
|
import com.dgtly.system.service.ISysConfigService;
|
|
|
|
|
+import com.dgtly.wxportal.domain.HomeIconConfig;
|
|
|
import com.dgtly.wxportal.domain.RoleMagnet;
|
|
import com.dgtly.wxportal.domain.RoleMagnet;
|
|
|
import com.dgtly.wxportal.domain.WxMagnet;
|
|
import com.dgtly.wxportal.domain.WxMagnet;
|
|
|
import com.dgtly.wxportal.mapper.WxMagnetMapper;
|
|
import com.dgtly.wxportal.mapper.WxMagnetMapper;
|
|
|
import com.dgtly.wxportal.service.IWxMagnetService;
|
|
import com.dgtly.wxportal.service.IWxMagnetService;
|
|
|
|
|
+
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -28,7 +33,8 @@ import java.util.*;
|
|
|
public class WxMagnetServiceImpl implements IWxMagnetService
|
|
public class WxMagnetServiceImpl implements IWxMagnetService
|
|
|
{
|
|
{
|
|
|
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
|
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxMagnetMapper wxMagnetMapper;
|
|
private WxMagnetMapper wxMagnetMapper;
|
|
|
|
|
|
|
@@ -242,6 +248,7 @@ public class WxMagnetServiceImpl implements IWxMagnetService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public static String KL(String inStr) {
|
|
public static String KL(String inStr) {
|
|
|
char[] a = inStr.toCharArray();
|
|
char[] a = inStr.toCharArray();
|
|
|
for (int i = 0; i < a.length; i++) {
|
|
for (int i = 0; i < a.length; i++) {
|
|
@@ -280,4 +287,63 @@ public class WxMagnetServiceImpl implements IWxMagnetService
|
|
|
return ztrees;
|
|
return ztrees;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public static boolean isValidJson(String jsonStr) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ JsonNode node = mapper.readTree(jsonStr);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ /*保存首页图标配置*/
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateHomeIcon(HomeIconConfig homeIconConfig) {
|
|
|
|
|
+ //校验json字符串是否正确
|
|
|
|
|
+ if(StringUtils.isNotBlank(homeIconConfig.getSmall_icon_extra())){
|
|
|
|
|
+ if(!isValidJson(homeIconConfig.getSmall_icon_extra())){
|
|
|
|
|
+ throw new RuntimeException("小图标json数据格式错误!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isNotBlank(homeIconConfig.getActivity_icon_extra())){
|
|
|
|
|
+ if(!isValidJson(homeIconConfig.getActivity_icon_extra())){
|
|
|
|
|
+ throw new RuntimeException("活动图标json数据格式错误!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isBlank(String.valueOf(homeIconConfig.getId()))) {
|
|
|
|
|
+ String insertSql = "INSERT INTO system_home_config (portal_background,small_icon_extra,activity_icon_extra,activity_icon_starttime,activity_icon_endtime,bottom_prompt_text,prompt_text_color,create_by,create_time) VALUES (?,?,?,?,?,?,?,?,now());";
|
|
|
|
|
+ Object[] args = new Object[]{homeIconConfig.getPortal_background(), homeIconConfig.getSmall_icon_extra(), homeIconConfig.getActivity_icon_extra(), homeIconConfig.getActivity_icon_starttime(), homeIconConfig.getActivity_icon_endtime(), homeIconConfig.getBottom_prompt_text(), homeIconConfig.getPrompt_text_color(),homeIconConfig.getCreateBy()};
|
|
|
|
|
+ jdbcTemplate.update(insertSql, args);
|
|
|
|
|
+ }
|
|
|
|
|
+ String updateSql = "update system_home_config set portal_background=?,small_icon_extra=?,activity_icon_extra=?,activity_icon_starttime=?,activity_icon_endtime=?,bottom_prompt_text=?,prompt_text_color=?,update_by=?,update_time=now() where id=?;";
|
|
|
|
|
+ Object[] args = new Object[]{homeIconConfig.getPortal_background(), homeIconConfig.getSmall_icon_extra(), homeIconConfig.getActivity_icon_extra(), homeIconConfig.getActivity_icon_starttime(), homeIconConfig.getActivity_icon_endtime(), homeIconConfig.getBottom_prompt_text(), homeIconConfig.getPrompt_text_color(),homeIconConfig.getUpdateBy(),homeIconConfig.getId()};
|
|
|
|
|
+ jdbcTemplate.update(updateSql, args);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, Object> selectHomeIconInfoById(Long id) {
|
|
|
|
|
+ List<Map<String,Object>> iconInfos=jdbcTemplate.queryForList("select * from system_home_config where id=?",id);
|
|
|
|
|
+ Map<String,Object> iconInfo= iconInfos.size()!=0?iconInfos.get(0):null;
|
|
|
|
|
+ if(iconInfo!=null) {
|
|
|
|
|
+ String smallIconString = iconInfo.get("small_icon_extra").toString();
|
|
|
|
|
+ String activityIconString = iconInfo.get("activity_icon_extra").toString();
|
|
|
|
|
+ if (StringUtils.isNotBlank(smallIconString)) {
|
|
|
|
|
+ Map mapType = JSON.parseObject(smallIconString, Map.class);
|
|
|
|
|
+ iconInfo.put("smallIconObject", mapType);
|
|
|
|
|
+ iconInfo.remove("small_icon_extra");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotBlank(activityIconString)) {
|
|
|
|
|
+ Map mapType = JSON.parseObject(activityIconString, Map.class);
|
|
|
|
|
+ iconInfo.put("activityIconObject", mapType);
|
|
|
|
|
+ iconInfo.remove("activity_icon_extra");
|
|
|
|
|
+ }
|
|
|
|
|
+ return iconInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|