Commit fa6b84b2 authored by 廖旭伟's avatar 廖旭伟

增加基础设置接口

parent 046c6fdf
......@@ -1654,6 +1654,79 @@ data|object|数据对象
"data":[]
}
}
```
## 基础设置
### 查看基础设置
**请求URL:** setting/info
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 查看基础设置
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|object|数据对象|-
  hotWords|String|热门搜索词汇|-
  printDisplay|Integer|空白打印材料展示数量|-
**响应消息样例:**
```
{
"code":1,
"data":{
}
}
```
### 保存基础设置
**请求URL:** setting/save
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存基础设置
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
hotWords|String|是|热门搜索词汇
printDisplay|Integer|是|空白打印材料展示数量
**请求样例:**
```
{
"hotWords": "测试,hahaha",
"printDisplay": 10
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
**响应消息样例:**
```
{
"msg":"保存成功",
"code":1,
"data":{}
}
}
```
## 字典附录
......
......@@ -5,6 +5,7 @@ import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.IParamService;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import java.util.List;
import java.util.Map;
/**
......@@ -44,4 +45,27 @@ public interface ParamService extends ICRUDCacheService<ParamEntity, Long>, IPar
*/
Map<String, String> getParamBySecondOrganize(String firstOrganize,String secondOrganize, String... excludeParamKeys);
/**
* 获取热词列表
* @return
*/
String getHotWords();
/**
* 设置热词列表
* @return
*/
void setHotWords(String value);
/**
* 空白打印材料展示数量
* @return
*/
int getPrintDisplayQuantity();
/**
* 设置空白打印材料展示数量
* @return
*/
void setPrintDisplayQuantity(int value);
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -29,6 +30,9 @@ import java.util.stream.Collectors;
@Service("paramService")
public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, ParamEntity, Long>
implements ParamService {
private final String HOT_WORDS = "HotWords";
private final String PRINT_QUANTITY = "PrintDisplayQuantity";
@Override
protected String getCacheName() {
return "ParamEntity.paramKey";
......@@ -61,6 +65,67 @@ public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, Par
).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue, (o, n) -> n));
}
@Override
public String getHotWords() {
return this.getParamValue(HOT_WORDS);
}
@Override
public void setHotWords(String value) {
List<ParamEntity> list = this.getCacheList();
ParamEntity entity = null;
for(ParamEntity paramEntity:list){
if(HOT_WORDS.equals(paramEntity.getParamKey())){
entity = paramEntity;
break;
}
}
if(entity!=null){
entity.setParamValue(value);
this.update(entity);
}else {
entity = new ParamEntity();
entity.setParamValue(value);
entity.setParamKey(HOT_WORDS);
entity.setName("热门搜索词汇");
entity.setCreateTime(new Date());
entity.setCreateUserId(1l);
entity.setCreateUserName("系统管理员");
this.save(entity);
}
}
@Override
public int getPrintDisplayQuantity() {
String printV = this.getParamValue(PRINT_QUANTITY);
return DataUtil.converStr2Int(printV,20);
}
@Override
public void setPrintDisplayQuantity(int value) {
List<ParamEntity> list = this.getCacheList();
ParamEntity entity = null;
for(ParamEntity paramEntity:list){
if(PRINT_QUANTITY.equals(paramEntity.getParamKey())){
entity = paramEntity;
break;
}
}
if(entity!=null){
entity.setParamValue(String.valueOf(value));
this.update(entity);
}else {
entity = new ParamEntity();
entity.setParamValue(String.valueOf(value));
entity.setParamKey(PRINT_QUANTITY);
entity.setName("空白打印材料展示数量");
entity.setCreateTime(new Date());
entity.setCreateUserId(1l);
entity.setCreateUserName("系统管理员");
this.save(entity);
}
}
@Override
public boolean needRefresh() {
......
package com.mortals.xhx.module.home.pdu;
import lombok.Data;
@Data
public class BasicSettingsPdu {
/** 热搜词 */
private String hotWords;
/** 空白打印材料展示数量 */
private Integer printDisplay;
}
package com.mortals.xhx.module.home.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.feign.base.pdu.DeptPdu;
import com.mortals.xhx.feign.base.pdu.SitePdu;
import com.mortals.xhx.feign.rsp.ApiResp;
import com.mortals.xhx.module.home.pdu.BasicSettingsPdu;
import com.mortals.xhx.module.home.pdu.HomeQueryPdu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@RestController
@RequestMapping("setting")
public class BasicSettingsController extends BaseJsonBodyController {
@Autowired
private ParamService paramService;
@PostMapping({"info"})
public Rest<Object> list() {
IUser user = this.getCurUser();
if(user==null){
throw new AppException("用户未登录");
}
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
String busiDesc = "查询基础设置" ;
int code=1;
try {
model.put("hotWords", paramService.getHotWords());
model.put("printDisplay", paramService.getPrintDisplayQuantity());
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"save"})
public Rest<Object> deptList(@RequestBody BasicSettingsPdu queryPdu) {
IUser user = this.getCurUser();
if(user==null){
throw new AppException("用户未登录");
}
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
String busiDesc = "保存基础设置" ;
int code=1;
try {
paramService.setHotWords(queryPdu.getHotWords());
paramService.setPrintDisplayQuantity(queryPdu.getPrintDisplay());
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment