FieldAction.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. The MIT License (MIT) * Copyright (c) 2016 铭飞科技(mingsoft.net)
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. * this software and associated documentation files (the "Software"), to deal in
  5. * the Software without restriction, including without limitation the rights to
  6. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  7. * the Software, and to permit persons to whom the Software is furnished to do so,
  8. * subject to the following conditions:
  9. * The above copyright notice and this permission notice shall be included in all
  10. * copies or substantial portions of the Software.
  11. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  13. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  14. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  15. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. */
  18. package net.mingsoft.cms.action.web;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpServletResponse;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Controller;
  23. import org.springframework.web.bind.annotation.PathVariable;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.ResponseBody;
  26. import com.alibaba.fastjson.JSONObject;
  27. import net.mingsoft.basic.biz.IColumnBiz;
  28. import net.mingsoft.mdiy.biz.IContentModelBiz;
  29. import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
  30. import net.mingsoft.basic.entity.ColumnEntity;
  31. import net.mingsoft.mdiy.entity.ContentModelEntity;
  32. import net.mingsoft.mdiy.entity.ContentModelFieldEntity;
  33. import net.mingsoft.base.action.BaseAction;
  34. import net.mingsoft.basic.util.BasicUtil;
  35. /**
  36. *
  37. *
  38. *
  39. * <p>
  40. * <b>铭飞科技</b>
  41. * </p>
  42. *
  43. * <p>
  44. * Copyright: Copyright (c) 2014 - 2015
  45. * </p>
  46. *
  47. * @author 史爱华
  48. *
  49. * <p>
  50. * Comments: 供前端页面获取自定义模型中字段实体信息
  51. * </p>
  52. *
  53. * <p>
  54. * Create Date:2015-07-11
  55. * </p>
  56. *
  57. * <p>
  58. * Modification history:
  59. * </p>
  60. */
  61. @Controller("webField")
  62. @RequestMapping("/field")
  63. public class FieldAction extends BaseAction{
  64. /**
  65. * 栏目业务层
  66. */
  67. @Autowired
  68. private IColumnBiz columnBiz;
  69. /**
  70. * 内容模型业务层
  71. */
  72. @Autowired
  73. private IContentModelBiz contentModelBiz;
  74. /**
  75. * 字段管理业务层
  76. */
  77. @Autowired
  78. private IContentModelFieldBiz fieldBiz;
  79. /**
  80. *
  81. * 根据当前栏目id和字段名称获取自定义模型中的字段实体信息
  82. * @param request
  83. * @param response
  84. */
  85. @RequestMapping("/{columId}/getEntity")
  86. @ResponseBody
  87. public void getEntity(@PathVariable int columId,HttpServletRequest request, HttpServletResponse response) {
  88. System.out.println("111");
  89. BasicUtil.setSession("xxx", "888");
  90. System.err.println("session:"+BasicUtil.getSession("xxx"));
  91. //获取字段名称
  92. String fieldFieldName = request.getParameter("fieldFieldName");
  93. //根据栏目id获取栏目实体
  94. ColumnEntity column = (ColumnEntity) this.columnBiz.getEntity(columId);
  95. if(column==null){
  96. this.outJson(response, this.getResString("err"));
  97. return;
  98. }else{
  99. //判断该栏目下是存在内容模型
  100. if(column.getColumnContentModelId()>0){
  101. //获取当前栏目对应的内容模型
  102. ContentModelEntity contentModel = (ContentModelEntity) this.contentModelBiz.getEntity(column.getColumnContentModelId());
  103. if(contentModel==null){
  104. this.outJson(response, this.getResString("err"));
  105. return;
  106. }
  107. //获取字段实体
  108. ContentModelFieldEntity field = fieldBiz.getEntityByCmId(column.getColumnContentModelId(), fieldFieldName);
  109. //返回字段实体
  110. this.outJson(response, JSONObject.toJSONString(field));
  111. }
  112. }
  113. }
  114. }