FieldAction.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 com.alibaba.fastjson.JSONObject;
  20. import net.mingsoft.base.action.BaseAction;
  21. import net.mingsoft.basic.biz.IColumnBiz;
  22. import net.mingsoft.basic.entity.ColumnEntity;
  23. import net.mingsoft.mdiy.biz.IContentModelBiz;
  24. import net.mingsoft.mdiy.biz.IContentModelFieldBiz;
  25. import net.mingsoft.mdiy.entity.ContentModelEntity;
  26. import net.mingsoft.mdiy.entity.ContentModelFieldEntity;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.stereotype.Controller;
  29. import org.springframework.web.bind.annotation.PathVariable;
  30. import org.springframework.web.bind.annotation.RequestMapping;
  31. import org.springframework.web.bind.annotation.ResponseBody;
  32. import javax.servlet.http.HttpServletRequest;
  33. import javax.servlet.http.HttpServletResponse;
  34. /**
  35. * 供前端页面获取自定义模型中字段实体信息
  36. * @author 铭飞开发团队
  37. * 创建日期:2019-11-28 15:12:32<br/>
  38. * 历史修订:<br/>
  39. */
  40. @Controller("webField")
  41. @RequestMapping("/field")
  42. public class FieldAction extends BaseAction{
  43. /**
  44. * 栏目业务层
  45. */
  46. @Autowired
  47. private IColumnBiz columnBiz;
  48. /**
  49. * 内容模型业务层
  50. */
  51. @Autowired
  52. private IContentModelBiz contentModelBiz;
  53. /**
  54. * 字段管理业务层
  55. */
  56. @Autowired
  57. private IContentModelFieldBiz fieldBiz;
  58. /**
  59. *
  60. * 根据当前栏目id和字段名称获取自定义模型中的字段实体信息
  61. * @param request
  62. * @param response
  63. */
  64. @RequestMapping("/{columId}/getEntity")
  65. @ResponseBody
  66. public void getEntity(@PathVariable int columId,HttpServletRequest request, HttpServletResponse response) {
  67. //获取字段名称
  68. String fieldFieldName = request.getParameter("fieldFieldName");
  69. //根据栏目id获取栏目实体
  70. ColumnEntity column = (ColumnEntity) this.columnBiz.getEntity(columId);
  71. if(column==null){
  72. this.outJson(response, this.getResString("err"));
  73. return;
  74. }else{
  75. //判断该栏目下是存在内容模型
  76. if(column.getColumnContentModelId()>0){
  77. //获取当前栏目对应的内容模型
  78. ContentModelEntity contentModel = (ContentModelEntity) this.contentModelBiz.getEntity(column.getColumnContentModelId());
  79. if(contentModel==null){
  80. this.outJson(response, this.getResString("err"));
  81. return;
  82. }
  83. //获取字段实体
  84. ContentModelFieldEntity field = fieldBiz.getEntityByCmId(column.getColumnContentModelId(), fieldFieldName);
  85. //返回字段实体
  86. this.outJson(response, JSONObject.toJSONString(field));
  87. }
  88. }
  89. }
  90. }