ソースを参照

动态表单Demo接口

于俊龙 1 週間 前
コミット
8701370980

+ 43 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/demo/domain/ReceptionFormItem.java

@@ -0,0 +1,43 @@
+package jp.yamoto.farm.crm.biz.demo.domain;
+
+import lombok.Data;
+
+@Data
+public class ReceptionFormItem {
+
+    // ID
+    private String id;
+
+    // 项目代码
+    private String code;
+
+    // 名称
+    private String name;
+
+    // 顺序
+    private Integer rank;
+
+    // 类型:string, number, date...
+    private String type;
+
+    // 输入类型:text,date,select...
+    private String formEditor;
+
+    // 最大值:0 没有最大值
+    private Integer maxLength;
+
+    // 引用类型
+    private String refType;
+
+    // 引用名称
+    private String refName;
+
+    // 是否为空:N 不能为空,Y可以为空
+    private String nullable;
+
+    // 列合并数
+    private Integer colspan;
+
+    // 控件在Grid列里的位置
+    private Integer location;
+}

+ 23 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/demo/domain/ReceptionFormItemScheme.java

@@ -0,0 +1,23 @@
+package jp.yamoto.farm.crm.biz.demo.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ReceptionFormItemScheme {
+
+    private String id;
+
+    private String projectId;
+
+    private String groupName;
+
+    private Integer groupRank;
+
+    private String titleName;
+
+    private String titleRank;
+
+    private List<ReceptionFormItem> itemList;
+}

+ 31 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/demo/service/IReceptionFormSchemeService.java

@@ -0,0 +1,31 @@
+package jp.yamoto.farm.crm.biz.demo.service;
+
+import jp.yamoto.farm.crm.biz.demo.domain.ReceptionFormItem;
+import jp.yamoto.farm.crm.biz.demo.domain.ReceptionFormItemScheme;
+
+import java.util.List;
+
+public interface IReceptionFormSchemeService {
+
+    /**
+     * 获取所以项目
+     * @return
+     */
+    List<ReceptionFormItem> getFormItemList();
+
+    /**
+     * プロジェクト受付フォーム
+     * @param projectId
+     * @return
+     */
+    List<ReceptionFormItemScheme> getFormSchemeList(String projectId);
+
+    /**
+     * Save プロジェクト受付フォーム
+     *
+     * @param projectId
+     * @param datas
+     * @return
+     */
+    int save(String projectId, List<ReceptionFormItemScheme> datas);
+}

+ 58 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/demo/service/impl/ReceptionFormSchemeServiceImpl.java

@@ -0,0 +1,58 @@
+package jp.yamoto.farm.crm.biz.demo.service.impl;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import jp.yamoto.farm.common.exception.ServiceException;
+import jp.yamoto.farm.common.utils.MessageUtils;
+import jp.yamoto.farm.crm.biz.demo.domain.ReceptionFormItem;
+import jp.yamoto.farm.crm.biz.demo.domain.ReceptionFormItemScheme;
+import jp.yamoto.farm.crm.biz.demo.service.IReceptionFormSchemeService;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ReceptionFormSchemeServiceImpl implements IReceptionFormSchemeService {
+
+    @Override
+    public List<ReceptionFormItem> getFormItemList() {
+        ObjectMapper mapper = new ObjectMapper();
+        ClassPathResource resource = new ClassPathResource("demo/items.json");
+        List<ReceptionFormItem> result = null;
+        try {
+            result = mapper.readValue(
+                    resource.getInputStream(),
+                    new TypeReference<List<ReceptionFormItem>>() {
+                    }
+            );
+        } catch (Exception e){
+            throw new ServiceException(MessageUtils.message("I0004"));
+        }
+
+        return result;
+    }
+
+    @Override
+    public List<ReceptionFormItemScheme> getFormSchemeList(String projectId) {
+        ObjectMapper mapper = new ObjectMapper();
+        ClassPathResource resource = new ClassPathResource("demo/scheme-items.json");
+        List<ReceptionFormItemScheme> result = null;
+        try {
+            result = mapper.readValue(
+                    resource.getInputStream(),
+                    new TypeReference<List<ReceptionFormItemScheme>>() {
+                    }
+            );
+        } catch (Exception e){
+            throw new ServiceException(MessageUtils.message("I0004"));
+        }
+
+        return result;
+    }
+
+    @Override
+    public int save(String projectId, List<ReceptionFormItemScheme> datas) {
+        return 0;
+    }
+}

+ 234 - 0
farm-crm-biz/src/main/resources/demo/items.json

@@ -0,0 +1,234 @@
+[
+  {
+    "id":"1",
+    "code": "001",
+    "name": "受付日時",
+    "rank": 1,
+    "type": "date",
+    "formEditor": "date",
+    "maxLength": 10,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"2",
+    "code": "002",
+    "name": "受付区分",
+    "rank": 2,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 2,
+    "refType": "SysDictType",
+    "refName": "sys_recetpion_kbn",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"3",
+    "code": "003",
+    "name": "入電者氏名",
+    "rank": 3,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"4",
+    "code": "004",
+    "name": "入電者氏名(カナ)",
+    "rank": 4,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"5",
+    "code": "005",
+    "name": "入電者電話番号",
+    "rank": 5,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"6",
+    "code": "006",
+    "name": "入電者電話番号2",
+    "rank": 6,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "Y",
+    "colspan": 0
+  },
+  {
+    "id":"7",
+    "code": "007",
+    "name": "入電者郵便番号",
+    "rank": 7,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"8",
+    "code": "008",
+    "name": "入電者住所1",
+    "rank": 8,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 128,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 2
+  },
+  {
+    "id":"9",
+    "code": "009",
+    "name": "入電者住所2",
+    "rank": 9,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 128,
+    "refType": "",
+    "refName": "",
+    "nullable": "Y",
+    "colspan": 2
+  },{
+  "id":"101",
+  "code": "101",
+  "name": "Web管理番号",
+  "rank": 1,
+  "type": "string",
+  "formEditor": "text",
+  "maxLength": 10,
+  "refType": "",
+  "refName": "",
+  "nullable": "Y",
+  "colspan": 0
+},{
+    "id":"102",
+    "code": "102",
+    "name": "メールアドレス",
+    "rank": 2,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 128,
+    "refType": "",
+    "refName": "",
+    "nullable": "Y",
+    "colspan": 0
+  },
+  {
+    "id":"103",
+    "code": "103",
+    "name": "購入経路",
+    "rank": 3,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"104",
+    "code": "104",
+    "name": "購入経路詳細",
+    "rank": 4,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 200,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"105",
+    "code": "105",
+    "name": "商品名",
+    "rank": 6,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "Y",
+    "colspan": 0
+  },
+  {
+    "id":"106",
+    "code": "106",
+    "name": "台数",
+    "rank": 7,
+    "type": "number",
+    "formEditor": "number",
+    "maxLength": 5,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"107",
+    "code": "107",
+    "name": "JANコード",
+    "rank": 8,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  },
+  {
+    "id":"108",
+    "code": "108",
+    "name": "製造番号",
+    "rank": 9,
+    "type": "string",
+    "formEditor": "text",
+    "maxLength": 20,
+    "refType": "",
+    "refName": "",
+    "nullable": "Y",
+    "colspan": 0
+  },
+  {
+    "id":"109",
+    "code": "109",
+    "name": "Web取込日",
+    "rank": 11,
+    "type": "date",
+    "formEditor": "date",
+    "maxLength": 10,
+    "refType": "",
+    "refName": "",
+    "nullable": "N",
+    "colspan": 0
+  }
+]

+ 274 - 0
farm-crm-biz/src/main/resources/demo/scheme-items.json

@@ -0,0 +1,274 @@
+[
+  {
+    "id": "1",
+    "projectId": "P1001",
+    "groupName": "受付登録",
+    "groupRank": 1,
+    "titleName": "基本情報",
+    "titleRank": 1,
+    "itemList": [
+      {
+        "id":"1",
+        "code": "001",
+        "name": "受付日時",
+        "rank": 1,
+        "location": 1,
+        "type": "date",
+        "formEditor": "date",
+        "maxLength": 10,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"2",
+        "code": "002",
+        "name": "受付区分",
+        "rank": 2,
+        "location": 2,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 2,
+        "refType": "SysDictType",
+        "refName": "sys_recetpion_kbn",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"3",
+        "code": "003",
+        "name": "入電者氏名",
+        "rank": 3,
+        "location": 3,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"4",
+        "code": "004",
+        "name": "入電者氏名(カナ)",
+        "rank": 4,
+        "location": 4,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"5",
+        "code": "005",
+        "name": "入電者電話番号",
+        "rank": 5,
+        "location": 5,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"6",
+        "code": "006",
+        "name": "入電者電話番号2",
+        "rank": 6,
+        "location": 6,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 0
+      },
+      {
+        "id":"7",
+        "code": "007",
+        "name": "入電者郵便番号",
+        "rank": 7,
+        "location": 7,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"8",
+        "code": "008",
+        "name": "入電者住所1",
+        "rank": 8,
+        "location": 8,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 128,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 2
+      },
+      {
+        "id":"9",
+        "code": "009",
+        "name": "入電者住所2",
+        "rank": 9,
+        "location": 10,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 128,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 2
+      }
+    ]
+  },{
+    "id": "2",
+    "projectId": "P1001",
+    "groupName": "受付登録",
+    "groupRank": 1,
+    "titleName": "追加情報",
+    "titleRank": 2,
+    "itemList": [
+      {
+        "id":"101",
+        "code": "101",
+        "name": "Web管理番号",
+        "rank": 1,
+        "location": 1,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 10,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 0
+      },
+      {
+        "id":"102",
+        "code": "102",
+        "name": "メールアドレス",
+        "rank": 2,
+        "location": 2,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 128,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 0
+      },
+      {
+        "id":"103",
+        "code": "103",
+        "name": "購入経路",
+        "rank": 3,
+        "location": 3,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"104",
+        "code": "104",
+        "name": "購入経路詳細",
+        "rank": 4,
+        "location": 4,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 200,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"105",
+        "code": "105",
+        "name": "商品名",
+        "rank": 5,
+        "location": 6,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 0
+      },
+      {
+        "id":"106",
+        "code": "106",
+        "name": "台数",
+        "rank": 6,
+        "location": 7,
+        "type": "number",
+        "formEditor": "number",
+        "maxLength": 5,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"107",
+        "code": "107",
+        "name": "JANコード",
+        "rank": 7,
+        "location": 8,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      },
+      {
+        "id":"108",
+        "code": "108",
+        "name": "製造番号",
+        "rank": 8,
+        "location": 9,
+        "type": "string",
+        "formEditor": "text",
+        "maxLength": 20,
+        "refType": "",
+        "refName": "",
+        "nullable": "Y",
+        "colspan": 0
+      },
+      {
+        "id":"109",
+        "code": "109",
+        "name": "Web取込日",
+        "rank": 9,
+        "location": 11,
+        "type": "date",
+        "formEditor": "date",
+        "maxLength": 10,
+        "refType": "",
+        "refName": "",
+        "nullable": "N",
+        "colspan": 0
+      }
+    ]
+  }
+
+]

+ 30 - 0
farm-crm/src/main/java/jp/yamoto/farm/crm/web/controller/demo/ReceptionFormController.java

@@ -0,0 +1,30 @@
+package jp.yamoto.farm.crm.web.controller.demo;
+
+import jp.yamoto.farm.common.core.controller.BaseController;
+import jp.yamoto.farm.common.core.domain.AjaxResult;
+import jp.yamoto.farm.crm.biz.demo.service.IReceptionFormSchemeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api/demo/form")
+public class ReceptionFormController extends BaseController{
+
+    @Autowired
+    private IReceptionFormSchemeService receptionFormSchemeService;
+
+    @GetMapping("/item/list")
+    public AjaxResult itemList()
+    {
+        return this.success(this.receptionFormSchemeService.getFormItemList());
+    }
+
+    @GetMapping("/scheme/{projectId}")
+    public AjaxResult getSchemeByProject(@PathVariable String projectId)
+    {
+        return this.success(this.receptionFormSchemeService.getFormSchemeList(projectId));
+    }
+}