OrgController.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.yihu.hos.system.controller;
  2. import com.yihu.hos.core.datatype.StringUtil;
  3. import com.yihu.hos.system.model.SystemOrganization;
  4. import com.yihu.hos.system.service.OrganizationManager;
  5. import com.yihu.hos.web.framework.model.Result;
  6. import com.yihu.hos.web.framework.util.controller.BaseController;
  7. import org.apache.commons.beanutils.BeanUtils;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.ui.Model;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import javax.annotation.Resource;
  13. import javax.servlet.http.HttpServletRequest;
  14. import java.util.HashMap;
  15. import java.util.Map;
  16. /**
  17. * 机构管理
  18. * Created by hzp on 2016/1/12.
  19. */
  20. @RequestMapping("/org")
  21. @Controller
  22. public class OrgController extends BaseController {
  23. @Resource(name = OrganizationManager.BEAN_ID)
  24. private OrganizationManager organization;
  25. /**
  26. * 组织管理界面
  27. * @param model
  28. * @return
  29. */
  30. @RequestMapping("initial")
  31. public String organization(Model model) {
  32. model.addAttribute("contentPage","system/org/organization");
  33. return "partView";
  34. }
  35. /**
  36. * 组织编辑界面
  37. */
  38. @RequestMapping("editorOrganization")
  39. public String editorOrganization(Model model,String orgId) {
  40. try {
  41. //是否编辑
  42. if (orgId != null && orgId.length() > 0) {
  43. //获取机构信息
  44. SystemOrganization org = organization.getOrgById(orgId);
  45. model.addAttribute("model", org);
  46. }
  47. model.addAttribute("contentPage", "system/org/editorOrganization");
  48. return "pageView";
  49. } catch (Exception ex) {
  50. model.addAttribute("contentPage", "organization/editorOrganization");
  51. return "pageView";
  52. }
  53. }
  54. /**
  55. * 获取组织列表
  56. */
  57. @RequestMapping("getOrgList")
  58. @ResponseBody
  59. public Result getOrgList(String pid,String name,String activityFlag,Integer page, Integer rows) {
  60. try {
  61. Map<String, Object> map = new HashMap<>();
  62. map.put("pid", pid);
  63. map.put("name", name);
  64. map.put("activityFlag", activityFlag);
  65. return organization.getOrgList(map, page, rows);
  66. }
  67. catch (Exception ex)
  68. {
  69. return Result.error(ex.getMessage());
  70. }
  71. }
  72. /**
  73. * 新增组织
  74. */
  75. @RequestMapping("addOrg")
  76. @ResponseBody
  77. public Result addOrg(HttpServletRequest request) {
  78. try {
  79. SystemOrganization obj = new SystemOrganization();
  80. BeanUtils.populate(obj, request.getParameterMap());
  81. obj.setActivityFlag("1");
  82. return organization.addOrg(obj);
  83. }
  84. catch(Exception ex)
  85. {
  86. return Result.error(ex.getMessage());
  87. }
  88. }
  89. /**
  90. * 修改组织
  91. */
  92. @RequestMapping("updateOrg")
  93. @ResponseBody
  94. public Result updateOrg(HttpServletRequest request) {
  95. try {
  96. SystemOrganization obj = new SystemOrganization();
  97. BeanUtils.populate(obj, request.getParameterMap());
  98. if(!StringUtil.isEmpty(obj.getSettledWay()))
  99. {
  100. obj.setSettled("1");
  101. }
  102. else{
  103. obj.setSettled("0");
  104. }
  105. return organization.updateOrg(obj);
  106. }
  107. catch (Exception ex)
  108. {
  109. return Result.error(ex.getMessage());
  110. }
  111. }
  112. /**
  113. * 删除组织
  114. */
  115. @RequestMapping("deleteOrg")
  116. @ResponseBody
  117. public Result deleteOrg(String orgId) {
  118. try {
  119. return organization.deleteOrg(orgId);
  120. }
  121. catch (Exception ex)
  122. {
  123. return Result.error(ex.getMessage());
  124. }
  125. }
  126. /**
  127. * 修改组织状态
  128. *//*
  129. @RequestMapping("activityOrg")
  130. @ResponseBody
  131. public Result activityOrg(String orgId,String activityFlag) {
  132. try {
  133. return organization.activityOrg(orgId,activityFlag);
  134. }
  135. catch (Exception ex)
  136. {
  137. return Result.error(ex.getMessage());
  138. }
  139. }*/
  140. }