package com.newvideo.web.action;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.apache.struts2.interceptor.ServletRequestAware;
|
import org.springframework.stereotype.Controller;
|
|
import com.newvideo.domain.Config;
|
import com.newvideo.service.imp.ConfigService;
|
import com.newvideo.service.imp.OtherService;
|
import com.newvideo.util.StringUtil;
|
import com.newvideo.util.Utils;
|
import com.opensymphony.xwork2.ActionSupport;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
@Controller
|
public class ConfigAction extends ActionSupport implements ServletRequestAware {
|
@Resource
|
private ConfigService configService;
|
|
public ConfigService getConfigService() {
|
return configService;
|
}
|
|
public void setConfigService(ConfigService configService) {
|
this.configService = configService;
|
}
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
HttpServletRequest request;
|
|
/**
|
* �ؼ��������б�
|
*
|
* @return
|
*/
|
public String configList() {
|
|
List<Config> list = configService.getConfig();
|
request.setAttribute("configList", list);
|
|
return SUCCESS;
|
}
|
|
/**
|
* �������ļ�
|
*
|
* @return
|
*/
|
public String updateConfig() {
|
|
List<Config> list = configService.getConfig();
|
for (Config cf : list) {
|
String value = request.getParameter(cf.getKey());
|
value = StringUtil.getUTF8String(value, "iso-8859-1");
|
cf.setValue(value);
|
configService.updateConfig(cf);
|
}
|
return SUCCESS;
|
}
|
|
public String getHotSearchRank() {
|
Config cf = configService.getConfigByKey("topsearch");
|
List<String> list = new ArrayList<String>();
|
if (cf != null) {
|
try {
|
JSONArray array = JSONArray.fromObject(cf.getValue());
|
for (int i = 0; i < array.size(); i++) {
|
list.add(array.optString(i));
|
}
|
} catch (Exception e) {
|
}
|
}
|
request.setAttribute("list", list);
|
return SUCCESS;
|
}
|
|
public void setServletRequest(HttpServletRequest arg0) {
|
this.request = arg0;
|
}
|
}
|