123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- package com.sinosoft.lz.system.configer.service;
- import java.io.UnsupportedEncodingException;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Set;
- import javax.ws.rs.GET;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.ProduceMime;
- import org.apache.log4j.Logger;
- import com.formaction.Utils;
- import com.sinosoft.lz.system.configer.dao.PersonalconfDao;
- import com.sinosoft.lz.system.configer.vo.Configures;
- import com.sinosoft.lz.system.configer.vo.Personalconf;
- import com.sinosoft.lz.system.configer.vo.Personalconfs;
- @Path("/ConfigureService/")
- public class ConfigureServiceImp implements ConfigureService{
- private Logger log = Logger.getLogger(this.getClass());
- @GET
- @Path("/reloadConfigures")
- public String reloadConfigures() {
- // TODO Auto-generated method stub
- try {
- ConfigureImp conf = new ConfigureImp();
- log.info("重新加载前===" + ConfigureImp.FountConfigureMap.size());
- conf.getallConfigures();
- log.info("重新加载后===" + ConfigureImp.BehindConfigureMap.size());
- return "0";
- } catch (Exception e) {
- return "1";
- }
- }
- /**
- * 加载前台系统配置服务
- */
- @POST
- @ProduceMime("application/json")
- @Path("/getFountConfigures")
- public Configures getFountConfigures() {
- Configures configures = new Configures();
- StringBuffer confs = new StringBuffer();
- HashMap<String, String> fountConfMap = ConfigureImp.FountConfigureMap;
- Set<String> sKey = fountConfMap.keySet();
- Iterator<String> it = sKey.iterator();
- String key = "";
- String value = "";
- confs.append("{");
- while (it.hasNext()) {
- key = it.next();
- value = fountConfMap.get(key);
- confs.append("\"" + key + "\"");
- confs.append(":");
- confs.append("\"" + value + "\"");
- confs.append(",");
- }
- confs.setLength(confs.length() - 1);
- confs.append("}");
- configures.setConfs(confs.toString());
- return configures;
- }
- /**
- * 取得个人配置信息
- *
- * @param uid
- * @return
- */
- @POST
- @ProduceMime("application/json")
- @Path("/getPerInfos/{uid}")
- public Personalconfs getSysInfos(@PathParam("uid") String uid) {
- Personalconfs perCon = new Personalconfs();
- PersonalconfDao pDao = new PersonalconfDao();
- perCon = pDao.getPersonalconfs(uid);
- return perCon;
- }
- @POST
- @Path("/changPassword/")
- public String changPassword(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String uid = Utils.getParameter("useid", params);
- String oPwd = Utils.getParameter("password", params);
- String nPwd = Utils.getParameter("userpassword", params);
- PersonalconfDao pconfdao = new PersonalconfDao();
- return pconfdao.changePWD(uid, oPwd, nPwd);
- }
- @ProduceMime("application/json")
- @POST
- @Path("/addPersonalconf")
- public String addPersonalconf(String params) {
- params = decode(params);
- log.debug("fdfdfd:" + params);
- Personalconf pconf = new Personalconf();
- String confkey = Utils.getParameter("confkey", params) == null ? "" : Utils.getParameter(
- "confkey", params);
- String location = Utils.getParameter("location", params) == null ? "" : Utils.getParameter(
- "location", params);
- String state = Utils.getParameter("state", params) == null ? "" : Utils.getParameter(
- "state", params);
- String id = Utils.getParameter("id", params) == null ? "" : Utils
- .getParameter("id", params);
- String uid = Utils.getParameter("uid", params) == null ? "" : Utils.getParameter("uid",
- params);
- String value = Utils.getParameter("value", params) == null ? "" : Utils.getParameter(
- "value", params);
- String description = Utils.getParameter("description", params) == null ? "" : Utils
- .getParameter("description", params);// 发件人id
- pconf.setConfkey(confkey);
- pconf.setDescription(description);
- pconf.setId(id);
- pconf.setLocation(location);
- pconf.setUidd(uid);
- pconf.setValue(value);
- pconf.setState(state);
- PersonalconfDao pconfdao = new PersonalconfDao();
- pconfdao.addPersonalconf(pconf);
- return "ok";
- }
- @GET
- @ProduceMime("application/json")
- @Path("/getPersonalconfs/{uid}")
- public Personalconfs getPersonalconfs(@PathParam("uid") String uid) {
- // TODO Auto-generated method stub
- PersonalconfDao pconfdao = new PersonalconfDao();
- return pconfdao.getPersonalconfs(uid);
- }
- @ProduceMime("application/json")
- @POST
- @Path("/upDatePersonalconf")
- public String upDatePersonalconf(String params) {
- params = decode(params);
- Personalconf pconf = new Personalconf();
- String confkey = Utils.getParameter("confkey", params) == null ? "" : Utils.getParameter(
- "confkey", params);
- String location = Utils.getParameter("location", params) == null ? "" : Utils.getParameter(
- "location", params);
- String state = Utils.getParameter("state", params) == null ? "" : Utils.getParameter(
- "state", params);
- String id = Utils.getParameter("id", params) == null ? "" : Utils
- .getParameter("id", params);
- String uid = Utils.getParameter("uid", params) == null ? "" : Utils.getParameter("uid",
- params);
- String value = Utils.getParameter("value", params) == null ? "" : Utils.getParameter(
- "value", params);
- String description = Utils.getParameter("description", params) == null ? "" : Utils
- .getParameter("description", params);// 发件人id
- pconf.setConfkey(confkey);
- pconf.setDescription(description);
- pconf.setId(id);
- pconf.setLocation(location);
- pconf.setUidd(uid);
- pconf.setValue(value);
- pconf.setState(state);
- PersonalconfDao pconfdao = new PersonalconfDao();
- pconfdao.editPersonalconf(pconf);
- return "ok";
- }
- // 编码解析
- protected String decode(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- log.debug("编码解析 失败!");
- }
- return params;
- }
- }
|