admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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;
    }
}