增加系统配置的功能(优化)
This commit is contained in:
parent
df49f5a350
commit
2caaab4fd2
143
src/main/java/com/jsh/action/basic/SystemConfigAction.java
Normal file
143
src/main/java/com/jsh/action/basic/SystemConfigAction.java
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
package com.jsh.action.basic;
|
||||||
|
|
||||||
|
import com.jsh.base.BaseAction;
|
||||||
|
import com.jsh.base.Log;
|
||||||
|
import com.jsh.model.po.Logdetails;
|
||||||
|
import com.jsh.model.po.SystemConfig;
|
||||||
|
import com.jsh.model.vo.basic.SystemConfigModel;
|
||||||
|
import com.jsh.service.basic.SystemConfigIService;
|
||||||
|
import com.jsh.util.PageUtil;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 系统配置
|
||||||
|
* @author jishenghua qq:7-5-2-7 1-8-9-2-0
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class SystemConfigAction extends BaseAction<SystemConfigModel>
|
||||||
|
{
|
||||||
|
private SystemConfigIService systemConfigService;
|
||||||
|
private SystemConfigModel model = new SystemConfigModel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新系统配置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
Boolean flag = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SystemConfig sysConfig = systemConfigService.get(model.getId());
|
||||||
|
sysConfig.setType(sysConfig.getType());
|
||||||
|
sysConfig.setName(sysConfig.getName());
|
||||||
|
sysConfig.setValue(model.getValue());
|
||||||
|
sysConfig.setDescription(sysConfig.getDescription());
|
||||||
|
systemConfigService.update(sysConfig);
|
||||||
|
|
||||||
|
flag = true;
|
||||||
|
tipMsg = "成功";
|
||||||
|
tipType = 0;
|
||||||
|
}
|
||||||
|
catch (DataAccessException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>修改系统配置ID为 : " + model.getId() + "信息失败", e);
|
||||||
|
flag = false;
|
||||||
|
tipMsg = "失败";
|
||||||
|
tipType = 1;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
toClient(flag.toString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>修改系统配置回写客户端结果异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logService.create(new Logdetails(getUser(), "更新系统配置", model.getClientIp(),
|
||||||
|
new Timestamp(System.currentTimeMillis())
|
||||||
|
, tipType, "更新系统配置ID为 "+ model.getId() + " " + tipMsg + "!", "更新系统配置" + tipMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找系统配置信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void findBy()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PageUtil<SystemConfig> pageUtil = new PageUtil<SystemConfig>();
|
||||||
|
pageUtil.setPageSize(0);
|
||||||
|
pageUtil.setCurPage(0);
|
||||||
|
pageUtil.setAdvSearch(getCondition());
|
||||||
|
systemConfigService.find(pageUtil);
|
||||||
|
List<SystemConfig> dataList = pageUtil.getPageList();
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if(null != dataList)
|
||||||
|
{
|
||||||
|
for(SystemConfig sysConfig:dataList)
|
||||||
|
{
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", sysConfig.getId());
|
||||||
|
item.put("type", sysConfig.getType());
|
||||||
|
item.put("name", sysConfig.getName());
|
||||||
|
item.put("value", sysConfig.getValue());
|
||||||
|
item.put("description", sysConfig.getDescription());
|
||||||
|
item.put("op", 1);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("rows", dataArray);
|
||||||
|
//回写查询结果
|
||||||
|
toClient(outer.toString());
|
||||||
|
}
|
||||||
|
catch (DataAccessException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找系统配置信息异常", e);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询系统配置信息结果异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼接搜索条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Map<String,Object> getCondition()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 拼接搜索条件
|
||||||
|
*/
|
||||||
|
Map<String,Object> condition = new HashMap<String,Object>();
|
||||||
|
condition.put("id_s_order", "asc");
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
||||||
|
@Override
|
||||||
|
public SystemConfigModel getModel()
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
public void setSystemConfigService(SystemConfigIService systemConfigService)
|
||||||
|
{
|
||||||
|
this.systemConfigService = systemConfigService;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/main/java/com/jsh/dao/basic/SystemConfigDAO.java
Normal file
17
src/main/java/com/jsh/dao/basic/SystemConfigDAO.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.jsh.dao.basic;
|
||||||
|
|
||||||
|
import com.jsh.base.BaseDAO;
|
||||||
|
import com.jsh.model.po.SystemConfig;
|
||||||
|
|
||||||
|
public class SystemConfigDAO extends BaseDAO<SystemConfig> implements SystemConfigIDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 设置dao映射基类
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Class<SystemConfig> getEntityClass()
|
||||||
|
{
|
||||||
|
return SystemConfig.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/main/java/com/jsh/dao/basic/SystemConfigIDAO.java
Normal file
9
src/main/java/com/jsh/dao/basic/SystemConfigIDAO.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.jsh.dao.basic;
|
||||||
|
|
||||||
|
import com.jsh.base.BaseIDAO;
|
||||||
|
import com.jsh.model.po.SystemConfig;
|
||||||
|
|
||||||
|
public interface SystemConfigIDAO extends BaseIDAO<SystemConfig>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
51
src/main/java/com/jsh/model/po/SystemConfig.java
Normal file
51
src/main/java/com/jsh/model/po/SystemConfig.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.jsh.model.po;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class SystemConfig implements java.io.Serializable
|
||||||
|
{
|
||||||
|
private Long id;
|
||||||
|
private String type;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
||||||
77
src/main/java/com/jsh/model/vo/basic/SystemConfigModel.java
Normal file
77
src/main/java/com/jsh/model/vo/basic/SystemConfigModel.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package com.jsh.model.vo.basic;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class SystemConfigModel implements Serializable
|
||||||
|
{
|
||||||
|
private SystemConfigShowModel showModel = new SystemConfigShowModel();
|
||||||
|
|
||||||
|
/**======开始接受页面参数=================**/
|
||||||
|
private Long id = 0l;
|
||||||
|
private String type = "";
|
||||||
|
private String name = "";
|
||||||
|
private String value = "";
|
||||||
|
private String description = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户IP,用户记录操作日志
|
||||||
|
*/
|
||||||
|
private String clientIp = "";
|
||||||
|
|
||||||
|
public SystemConfigShowModel getShowModel() {
|
||||||
|
return showModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowModel(SystemConfigShowModel showModel) {
|
||||||
|
this.showModel = showModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientIp() {
|
||||||
|
return clientIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientIp(String clientIp) {
|
||||||
|
this.clientIp = clientIp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.jsh.model.vo.basic;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class SystemConfigShowModel implements Serializable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 提示信息
|
||||||
|
*/
|
||||||
|
private String msgTip = "";
|
||||||
|
|
||||||
|
public String getMsgTip()
|
||||||
|
{
|
||||||
|
return msgTip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsgTip(String msgTip)
|
||||||
|
{
|
||||||
|
this.msgTip = msgTip;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.jsh.service.basic;
|
||||||
|
|
||||||
|
import com.jsh.base.BaseIService;
|
||||||
|
import com.jsh.model.po.SystemConfig;
|
||||||
|
|
||||||
|
public interface SystemConfigIService extends BaseIService<SystemConfig>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
23
src/main/java/com/jsh/service/basic/SystemConfigService.java
Normal file
23
src/main/java/com/jsh/service/basic/SystemConfigService.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package com.jsh.service.basic;
|
||||||
|
|
||||||
|
import com.jsh.base.BaseService;
|
||||||
|
import com.jsh.dao.basic.SystemConfigIDAO;
|
||||||
|
import com.jsh.model.po.SystemConfig;
|
||||||
|
|
||||||
|
public class SystemConfigService extends BaseService<SystemConfig> implements SystemConfigIService
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private SystemConfigIDAO systemConfigDao;
|
||||||
|
|
||||||
|
public void setSystemConfigDao(SystemConfigIDAO systemConfigDao)
|
||||||
|
{
|
||||||
|
this.systemConfigDao = systemConfigDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<SystemConfig> getEntityClass()
|
||||||
|
{
|
||||||
|
return SystemConfig.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user