27f899b37566c1c9ae3ebe887b51f7e49c74a858.svn-base 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. package com.sinosoft.lz.system.configer.service;
  2. import java.io.UnsupportedEncodingException;
  3. import java.util.HashMap;
  4. import java.util.Iterator;
  5. import java.util.Set;
  6. import javax.ws.rs.GET;
  7. import javax.ws.rs.POST;
  8. import javax.ws.rs.Path;
  9. import javax.ws.rs.PathParam;
  10. import javax.ws.rs.ProduceMime;
  11. import org.apache.log4j.Logger;
  12. import com.formaction.Utils;
  13. import com.sinosoft.lz.system.configer.dao.PersonalconfDao;
  14. import com.sinosoft.lz.system.configer.vo.Configures;
  15. import com.sinosoft.lz.system.configer.vo.Personalconf;
  16. import com.sinosoft.lz.system.configer.vo.Personalconfs;
  17. @Path("/ConfigureService/")
  18. public class ConfigureServiceImp implements ConfigureService{
  19. private Logger log = Logger.getLogger(this.getClass());
  20. @GET
  21. @Path("/reloadConfigures")
  22. public String reloadConfigures() {
  23. // TODO Auto-generated method stub
  24. try {
  25. ConfigureImp conf = new ConfigureImp();
  26. log.info("重新加载前===" + ConfigureImp.FountConfigureMap.size());
  27. conf.getallConfigures();
  28. log.info("重新加载后===" + ConfigureImp.BehindConfigureMap.size());
  29. return "0";
  30. } catch (Exception e) {
  31. return "1";
  32. }
  33. }
  34. /**
  35. * 加载前台系统配置服务
  36. */
  37. @POST
  38. @ProduceMime("application/json")
  39. @Path("/getFountConfigures")
  40. public Configures getFountConfigures() {
  41. Configures configures = new Configures();
  42. StringBuffer confs = new StringBuffer();
  43. HashMap<String, String> fountConfMap = ConfigureImp.FountConfigureMap;
  44. Set<String> sKey = fountConfMap.keySet();
  45. Iterator<String> it = sKey.iterator();
  46. String key = "";
  47. String value = "";
  48. confs.append("{");
  49. while (it.hasNext()) {
  50. key = it.next();
  51. value = fountConfMap.get(key);
  52. confs.append("\"" + key + "\"");
  53. confs.append(":");
  54. confs.append("\"" + value + "\"");
  55. confs.append(",");
  56. }
  57. confs.setLength(confs.length() - 1);
  58. confs.append("}");
  59. configures.setConfs(confs.toString());
  60. return configures;
  61. }
  62. /**
  63. * 取得个人配置信息
  64. *
  65. * @param uid
  66. * @return
  67. */
  68. @POST
  69. @ProduceMime("application/json")
  70. @Path("/getPerInfos/{uid}")
  71. public Personalconfs getSysInfos(@PathParam("uid") String uid) {
  72. Personalconfs perCon = new Personalconfs();
  73. PersonalconfDao pDao = new PersonalconfDao();
  74. perCon = pDao.getPersonalconfs(uid);
  75. return perCon;
  76. }
  77. @POST
  78. @Path("/changPassword/")
  79. public String changPassword(String params) {
  80. try {
  81. params = java.net.URLDecoder.decode(params, "UTF-8");
  82. } catch (UnsupportedEncodingException e) {
  83. // TODO Auto-generated catch block
  84. e.printStackTrace();
  85. }
  86. String uid = Utils.getParameter("useid", params);
  87. String oPwd = Utils.getParameter("password", params);
  88. String nPwd = Utils.getParameter("userpassword", params);
  89. PersonalconfDao pconfdao = new PersonalconfDao();
  90. return pconfdao.changePWD(uid, oPwd, nPwd);
  91. }
  92. @ProduceMime("application/json")
  93. @POST
  94. @Path("/addPersonalconf")
  95. public String addPersonalconf(String params) {
  96. params = decode(params);
  97. log.debug("fdfdfd:" + params);
  98. Personalconf pconf = new Personalconf();
  99. String confkey = Utils.getParameter("confkey", params) == null ? "" : Utils.getParameter(
  100. "confkey", params);
  101. String location = Utils.getParameter("location", params) == null ? "" : Utils.getParameter(
  102. "location", params);
  103. String state = Utils.getParameter("state", params) == null ? "" : Utils.getParameter(
  104. "state", params);
  105. String id = Utils.getParameter("id", params) == null ? "" : Utils
  106. .getParameter("id", params);
  107. String uid = Utils.getParameter("uid", params) == null ? "" : Utils.getParameter("uid",
  108. params);
  109. String value = Utils.getParameter("value", params) == null ? "" : Utils.getParameter(
  110. "value", params);
  111. String description = Utils.getParameter("description", params) == null ? "" : Utils
  112. .getParameter("description", params);// 发件人id
  113. pconf.setConfkey(confkey);
  114. pconf.setDescription(description);
  115. pconf.setId(id);
  116. pconf.setLocation(location);
  117. pconf.setUidd(uid);
  118. pconf.setValue(value);
  119. pconf.setState(state);
  120. PersonalconfDao pconfdao = new PersonalconfDao();
  121. pconfdao.addPersonalconf(pconf);
  122. return "ok";
  123. }
  124. @GET
  125. @ProduceMime("application/json")
  126. @Path("/getPersonalconfs/{uid}")
  127. public Personalconfs getPersonalconfs(@PathParam("uid") String uid) {
  128. // TODO Auto-generated method stub
  129. PersonalconfDao pconfdao = new PersonalconfDao();
  130. return pconfdao.getPersonalconfs(uid);
  131. }
  132. @ProduceMime("application/json")
  133. @POST
  134. @Path("/upDatePersonalconf")
  135. public String upDatePersonalconf(String params) {
  136. params = decode(params);
  137. Personalconf pconf = new Personalconf();
  138. String confkey = Utils.getParameter("confkey", params) == null ? "" : Utils.getParameter(
  139. "confkey", params);
  140. String location = Utils.getParameter("location", params) == null ? "" : Utils.getParameter(
  141. "location", params);
  142. String state = Utils.getParameter("state", params) == null ? "" : Utils.getParameter(
  143. "state", params);
  144. String id = Utils.getParameter("id", params) == null ? "" : Utils
  145. .getParameter("id", params);
  146. String uid = Utils.getParameter("uid", params) == null ? "" : Utils.getParameter("uid",
  147. params);
  148. String value = Utils.getParameter("value", params) == null ? "" : Utils.getParameter(
  149. "value", params);
  150. String description = Utils.getParameter("description", params) == null ? "" : Utils
  151. .getParameter("description", params);// 发件人id
  152. pconf.setConfkey(confkey);
  153. pconf.setDescription(description);
  154. pconf.setId(id);
  155. pconf.setLocation(location);
  156. pconf.setUidd(uid);
  157. pconf.setValue(value);
  158. pconf.setState(state);
  159. PersonalconfDao pconfdao = new PersonalconfDao();
  160. pconfdao.editPersonalconf(pconf);
  161. return "ok";
  162. }
  163. // 编码解析
  164. protected String decode(String params) {
  165. try {
  166. params = java.net.URLDecoder.decode(params, "UTF-8");
  167. } catch (UnsupportedEncodingException e) {
  168. e.printStackTrace();
  169. log.debug("编码解析 失败!");
  170. }
  171. return params;
  172. }
  173. }