调整系统配置相关代码
This commit is contained in:
parent
f7134b6e27
commit
afc6ae0c77
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.hxkj.admin.controller.setting;
|
||||||
|
|
||||||
|
import com.hxkj.admin.service.setting.ISettingCopyrightService;
|
||||||
|
import com.hxkj.common.core.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站版权配置管理
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/setting/copyright")
|
||||||
|
public class CopyrightController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ISettingCopyrightService iSettingCopyrightService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站版权信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public Object detail() {
|
||||||
|
List<Map<String, String>> list = iSettingCopyrightService.detail();
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站版本信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Object save(@RequestBody List<Map<String, String>> params) {
|
||||||
|
iSettingCopyrightService.save(params);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.hxkj.admin.controller.setting;
|
||||||
|
|
||||||
|
import com.hxkj.admin.service.setting.ISettingProtocolService;
|
||||||
|
import com.hxkj.common.core.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/setting/protocol")
|
||||||
|
public class ProtocolController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ISettingProtocolService iSettingProtocolService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站版权信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public Object detail() {
|
||||||
|
Map<String, Map<String, String>> detail = iSettingProtocolService.detail();
|
||||||
|
return AjaxResult.success(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站版本信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Object save(@RequestBody Map<String, Object> params) {
|
||||||
|
iSettingProtocolService.save(params);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.hxkj.admin.controller.setting;
|
package com.hxkj.admin.controller.setting;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
import com.hxkj.admin.service.setting.IStorageService;
|
import com.hxkj.admin.service.setting.ISettingStorageService;
|
||||||
import com.hxkj.common.core.AjaxResult;
|
import com.hxkj.common.core.AjaxResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ import java.util.Map;
|
||||||
public class StorageController {
|
public class StorageController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
IStorageService iStorageService;
|
ISettingStorageService iSettingStorageService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储列表
|
* 存储列表
|
||||||
|
|
@ -24,7 +24,7 @@ public class StorageController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Object list() {
|
public Object list() {
|
||||||
List<Map<String, Object>> list = iStorageService.list();
|
List<Map<String, Object>> list = iSettingStorageService.list();
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class StorageController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public Object detail(String alias) {
|
public Object detail(String alias) {
|
||||||
Map<String, Object> map = iStorageService.detail(alias);
|
Map<String, Object> map = iSettingStorageService.detail(alias);
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class StorageController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
public Object edit(@RequestBody Map<String, String> params) {
|
public Object edit(@RequestBody Map<String, String> params) {
|
||||||
iStorageService.edit(params);
|
iSettingStorageService.edit(params);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class StorageController {
|
||||||
Assert.notNull(params.get("status"), "status参数缺失");
|
Assert.notNull(params.get("status"), "status参数缺失");
|
||||||
String alias = params.get("alias");
|
String alias = params.get("alias");
|
||||||
Integer status = Integer.parseInt(params.get("status"));
|
Integer status = Integer.parseInt(params.get("status"));
|
||||||
iStorageService.change(alias, status);
|
iSettingStorageService.change(alias, status);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.hxkj.admin.controller.setting;
|
||||||
|
|
||||||
|
import com.hxkj.admin.service.setting.ISettingWebsiteService;
|
||||||
|
import com.hxkj.common.core.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/setting/website")
|
||||||
|
public class WebsiteController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ISettingWebsiteService iSettingWebsiteService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站配置信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public Object detail() {
|
||||||
|
Map<String, String> detail = iSettingWebsiteService.detail();
|
||||||
|
return AjaxResult.success(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站配置信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Object save(@RequestBody Map<String, String> params) {
|
||||||
|
iSettingWebsiteService.save(params);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.hxkj.admin.service.setting;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站备案服务接口类
|
||||||
|
*/
|
||||||
|
public interface ISettingCopyrightService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站备案信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Map<String, String>
|
||||||
|
*/
|
||||||
|
List<Map<String, String>> detail();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站备案信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
void save(List<Map<String, String>> params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.hxkj.admin.service.setting;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 政策协议服务接口类
|
||||||
|
*/
|
||||||
|
public interface ISettingProtocolService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取政策协议信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Map<String, String>
|
||||||
|
*/
|
||||||
|
Map<String, Map<String, String>> detail();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存政策协议信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
void save(Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -4,9 +4,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储配置接口类
|
* 存储配置服务接口类
|
||||||
*/
|
*/
|
||||||
public interface IStorageService {
|
public interface ISettingStorageService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储列表
|
* 存储列表
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.hxkj.admin.service.setting;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站信息服务接口类
|
||||||
|
*/
|
||||||
|
public interface ISettingWebsiteService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Map<String, String>
|
||||||
|
*/
|
||||||
|
Map<String, String> detail();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
void save(Map<String, String> params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.hxkj.admin.service.setting.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.hxkj.admin.service.setting.ISettingCopyrightService;
|
||||||
|
import com.hxkj.common.utils.ArrayUtil;
|
||||||
|
import com.hxkj.common.utils.ConfigUtil;
|
||||||
|
import com.hxkj.common.utils.StringUtil;
|
||||||
|
import com.hxkj.common.utils.ToolsUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站备案服务实现类
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SettingCopyrightServiceImpl implements ISettingCopyrightService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站备案信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return List<Map<String, String>>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, String>> detail() {
|
||||||
|
String config = ConfigUtil.get("website", "copyright", "[]");
|
||||||
|
return ArrayUtil.stringToListAsMapStr(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站备案信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(List<Map<String, String>> params) {
|
||||||
|
List<Map<String, String>> list = new LinkedList<>();
|
||||||
|
for (Map<String, String> item : params) {
|
||||||
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
if (StringUtil.isNotEmpty(item.get("name")) || StringUtil.isNotEmpty(item.get("link"))) {
|
||||||
|
map.put("name", item.get("name"));
|
||||||
|
map.put("link", item.get("link"));
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConfigUtil.set("website", "copyright", JSON.toJSONString(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.hxkj.admin.service.setting.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.hxkj.admin.service.setting.ISettingProtocolService;
|
||||||
|
import com.hxkj.common.utils.ConfigUtil;
|
||||||
|
import com.hxkj.common.utils.ToolsUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 政策接口服务实现类
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SettingProtocolServiceImpl implements ISettingProtocolService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取政策协议信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Map<String, Map<String, String>>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Map<String, String>> detail() {
|
||||||
|
String service = ConfigUtil.get("protocol", "service", "{\"name\":\"\",\"content\":\"\"}");
|
||||||
|
String privacy = ConfigUtil.get("protocol", "privacy", "{\"name\":\"\",\"content\":\"\"}");
|
||||||
|
|
||||||
|
Map<String, Map<String, String>> map = new LinkedHashMap<>();
|
||||||
|
map.put("service", ToolsUtil.jsonToMap(service));
|
||||||
|
map.put("privacy", ToolsUtil.jsonToMap(privacy));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存政策协议信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(Map<String, Object> params) {
|
||||||
|
ConfigUtil.set("protocol","service", JSON.toJSONString(params.get("service")));
|
||||||
|
ConfigUtil.set("protocol","privacy", JSON.toJSONString(params.get("privacy")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ package com.hxkj.admin.service.setting.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
import com.hxkj.admin.service.setting.IStorageService;
|
import com.hxkj.admin.service.setting.ISettingStorageService;
|
||||||
import com.hxkj.common.utils.ConfigUtil;
|
import com.hxkj.common.utils.ConfigUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.*;
|
||||||
* 存储配置实现类
|
* 存储配置实现类
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class StorageServiceImpl implements IStorageService {
|
public class SettingStorageServiceImpl implements ISettingStorageService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储列表
|
* 存储列表
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.hxkj.admin.service.setting.impl;
|
||||||
|
|
||||||
|
import com.hxkj.admin.service.setting.ISettingWebsiteService;
|
||||||
|
import com.hxkj.common.utils.ConfigUtil;
|
||||||
|
import com.hxkj.common.utils.UrlUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网站信息配置服务实现类
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SettingWebsiteServiceImpl implements ISettingWebsiteService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网站信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Map<String, String>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> detail() {
|
||||||
|
Map<String, String> config = ConfigUtil.get("website");
|
||||||
|
|
||||||
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
map.put("name", config.getOrDefault("name", ""));
|
||||||
|
map.put("logo", UrlUtil.toAbsoluteUrl(config.getOrDefault("logo", "")));
|
||||||
|
map.put("favicon", UrlUtil.toAbsoluteUrl(config.getOrDefault("favicon", "")));
|
||||||
|
map.put("backdrop", UrlUtil.toAbsoluteUrl(config.getOrDefault("backdrop", "")));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存网站信息
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @param params 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(Map<String, String> params) {
|
||||||
|
ConfigUtil.set("website", "name", params.getOrDefault("name", ""));
|
||||||
|
ConfigUtil.set("website", "logo", UrlUtil.toRelativeUrl(params.getOrDefault("logo", "")));
|
||||||
|
ConfigUtil.set("website", "favicon", UrlUtil.toRelativeUrl(params.getOrDefault("favicon", "")));
|
||||||
|
ConfigUtil.set("website", "backdrop", UrlUtil.toRelativeUrl(params.getOrDefault("backdrop", "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue