| | |
| | | dvalue integer default 0, |
| | | min_value integer default 0, |
| | | max_value integer default 0, |
| | | times integer default 1, |
| | | descr varchar(256), |
| | | mark varchar(50), |
| | | create_user integer default 1, |
| | |
| | | comment on column lf.sys_args.dvalue is '默认值'; |
| | | comment on column lf.sys_args.min_value is '最小值'; |
| | | comment on column lf.sys_args.max_value is '最大值'; |
| | | comment on column lf.sys_args.times is '倍数'; |
| | | comment on column lf.sys_args.descr is '描述'; |
| | | comment on column lf.sys_args.mark is '标识'; |
| | | comment on column lf.sys_args.create_user is '创建人ID'; |
| | | comment on column lf.sys_args.create_time is '创建时间'; |
| | | comment on column lf.sys_args.update_user is '更新人ID'; |
| | | comment on column lf.sys_args.update_time is '更新时间'; |
| | | /* insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('自动登出时间',15,15,3,1440,'默认用户15分钟不操作,就自动登出系统。','AUTO_LOGOUT'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('令牌有效期',240,240,60,1440,'令牌默认有效期为240分钟,超时将失效。','TOKEN_EXPIRE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('缓存有效期',240,240,60,1440,'缓存默认有效期为240分钟,超时将失效。','CACHE_EXPIRE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('最大文件数',2000,2000,500,2500,'单个文件夹下默认最大存储文件的数目为2000个。','MAX_FILES'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('Cookie有效期',240,240,60,43200,'Cookie默认有效期为240分钟,超时将失效。','COOKIE_MAX_AGE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,descr,mark) values ('附件大小',50,50,5,1024,'单个附件大小默认最大为50MB。','MAX_FILE_SIZE'); */ |
| | | /* insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('自动登出时间',15,15,3,1440,1,'默认用户15分钟不操作,就自动登出系统。','AUTO_LOGOUT'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('令牌有效期',240,240,60,1440,1,'令牌默认有效期为240分钟,超时将失效。','TOKEN_EXPIRE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('缓存有效期',240,240,60,1440,1,'缓存默认有效期为240分钟,超时将失效。','CACHE_EXPIRE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('最大文件数',2000,2000,500,2500,1,'单个文件夹下默认最大存储文件的数目为2000个。','MAX_FILES'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('Cookie有效期',240,240,60,43200,60,'Cookie默认有效期为240分钟,超时将失效。','COOKIE_MAX_AGE'); |
| | | insert into lf.sys_args (name,cvalue,dvalue,min_value,max_value,times,descr,mark) values ('附件大小',50,50,5,1024,1048576,'单个附件大小默认最大为50MB。','MAX_FILE_SIZE'); */ |
| | | |
| | | select * from lf.sys_args; |
| | | ----------------------------------------------------------------------------------------------------- 25.黑名单表 |
| | |
| | | package com.lf.server.config; |
| | | |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.service.sys.ArgsService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private final static Log log = LogFactory.getLog(InitConfig.class); |
| | | |
| | | @Autowired |
| | | private PathHelper pathHelper; |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | ArgsService argsService; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) { |
| | | try { |
| | | pathHelper.init(); |
| | | |
| | | log.info("*****************系统启动完毕*****************" + "\n"); |
| | | argsService.initSettingData(); |
| | | |
| | | log.info("***************** 系统启动完毕 *****************" + "\n"); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | |
| | | @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> update(@RequestBody ArgsEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | ArgsEntity ae = argsService.selectById(entity.getId()); |
| | | if (ae == null) { |
| | | return fail("找不到待更新的实体", -1); |
| | | } |
| | | if (entity.getCvalue() > ae.getMaxValue() || entity.getCvalue() < ae.getMinValue()) { |
| | | return fail("待更新的值不在有效范围内", -1); |
| | | } |
| | | ae.setCvalue(entity.getCvalue()); |
| | | |
| | | int count = argsService.updateForValue(entity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | ae.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = argsService.updateForValue(ae); |
| | | if (count > 0) { |
| | | argsService.updateSettingData(ae); |
| | | } |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | public static int MAX_FILES = 2000; |
| | | |
| | | /** |
| | | * Cookie有效期 |
| | | * Cookie有效期:s |
| | | */ |
| | | public static int COOKIE_MAX_AGE = 4 * 60 * 60; |
| | | |
| | | /** |
| | | * 附件大小 |
| | | * 附件大小:B |
| | | */ |
| | | public static long MAX_FILE_SIZE = 50 * 1024 * 1024; |
| | | } |
| | |
| | | |
| | | private int maxValue; |
| | | |
| | | private int times; |
| | | |
| | | private String descr; |
| | | |
| | | private String mark; |
| | |
| | | this.maxValue = maxValue; |
| | | } |
| | | |
| | | public int getTimes() { |
| | | return times; |
| | | } |
| | | |
| | | public void setTimes(int times) { |
| | | this.times = times; |
| | | } |
| | | |
| | | public String getDescr() { |
| | | return descr; |
| | | } |
| | |
| | | package com.lf.server.service.sys; |
| | | |
| | | import com.lf.server.entity.all.SettingData; |
| | | import com.lf.server.entity.sys.ArgsEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.sys.ArgsMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public Integer updates(List<ArgsEntity> list) { |
| | | return argsMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 初始化设置值 |
| | | */ |
| | | public void initSettingData() throws Exception { |
| | | List<ArgsEntity> list = selectAll(); |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | for (ArgsEntity entity : list) { |
| | | updateSettingData(entity); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新设置值 |
| | | */ |
| | | public void updateSettingData(ArgsEntity entity) throws Exception { |
| | | Field field = SettingData.class.getField(entity.getMark()); |
| | | // field.setAccessible(true) |
| | | field.set(null, entity.getCvalue() * entity.getTimes()); |
| | | } |
| | | } |