Browse Source

增加api

zhou-hao 7 years ago
parent
commit
f2d55918e9

+ 14 - 0
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java

@@ -25,6 +25,7 @@ import org.hswebframework.web.controller.SimpleGenericEntityController;
 import org.hswebframework.web.controller.message.ResponseMessage;
 import org.hswebframework.web.dict.DictDefine;
 import org.hswebframework.web.dict.DictDefineRepository;
+import org.hswebframework.web.dict.ItemDefine;
 import org.hswebframework.web.dictionary.api.DictionaryService;
 import org.hswebframework.web.dictionary.api.entity.DictionaryEntity;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +34,10 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
 import static org.hswebframework.web.controller.message.ResponseMessage.*;
 
 /**
@@ -65,4 +70,13 @@ public class DictionaryController implements SimpleGenericEntityController<Dicti
         return ok(repository.getDefine(id));
     }
 
+    @GetMapping("/define/{id:.+}/items")
+    @Authorize(merge = false)
+    @ApiOperation("获取数据字典选项信息")
+    public ResponseMessage<List<ItemDefine>> getItemDefineById(@PathVariable String id) {
+        return ok(Optional.ofNullable(repository.getDefine(id))
+                .map(DictDefine::getItems)
+                .orElse(Collections.emptyList()));
+    }
+
 }