浏览代码

优化数据字典

zhouhao 7 年之前
父节点
当前提交
145fbc76c4
共有 12 个文件被更改,包括 20 次插入19 次删除
  1. 2 2
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-controller/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java
  2. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-dao/hsweb-system-dictionary-dao-api/src/main/java/org/hswebframework/web/dao/dictionary/DictionaryDao.java
  3. 3 3
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-entity/src/main/java/org/hswebframework/web/entity/dictionary/DictionaryEntity.java
  4. 4 4
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-entity/src/main/java/org/hswebframework/web/entity/dictionary/SimpleDictionaryEntity.java
  5. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-api/src/main/java/org/hswebframework/web/service/dictionary/DictionaryParserService.java
  6. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-api/src/main/java/org/hswebframework/web/service/dictionary/DictionaryService.java
  7. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryParser.java
  8. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryParserService.java
  9. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryService.java
  10. 1 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/parser/SimpleSingleDictParser.java
  11. 2 1
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/test/java/org/hswebframework/web/starter/dictionary/DictionaryParserTests.java
  12. 2 2
      hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/starter/dictionary/DictionaryTests.java

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

@@ -37,12 +37,12 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("${hsweb.web.mappings.dictionary:dictionary}")
 @Authorize(permission = "dictionary")
 @AccessLogger("数据字典")
-public class DictionaryController implements GenericEntityController<DictionaryEntity<DictionaryItemEntity>, String, QueryParamEntity, DictionaryEntity> {
+public class DictionaryController implements GenericEntityController<DictionaryEntity, String, QueryParamEntity, DictionaryEntity> {
 
     private DictionaryService dictionaryService;
 
     @Override
-    public DictionaryEntity<DictionaryItemEntity> modelToEntity(DictionaryEntity model, DictionaryEntity entity) {
+    public DictionaryEntity modelToEntity(DictionaryEntity model, DictionaryEntity entity) {
         return model;
     }
 

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-dao/hsweb-system-dictionary-dao-api/src/main/java/org/hswebframework/web/dao/dictionary/DictionaryDao.java

@@ -24,5 +24,5 @@ import org.hswebframework.web.entity.dictionary.DictionaryItemEntity;
 *  数据字典 DAO接口
 *  @author hsweb-generator-online
  */
-public interface DictionaryDao extends CrudDao<DictionaryEntity<DictionaryItemEntity>,String> {
+public interface DictionaryDao extends CrudDao<DictionaryEntity,String> {
 }

+ 3 - 3
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-entity/src/main/java/org/hswebframework/web/entity/dictionary/DictionaryEntity.java

@@ -26,7 +26,7 @@ import java.util.List;
  *
  * @author hsweb-generator-online
  */
-public interface DictionaryEntity<ITEM extends DictionaryItemEntity> extends GenericEntity<String>, RecordCreationEntity {
+public interface DictionaryEntity extends GenericEntity<String>, RecordCreationEntity {
  /*-------------------------------------------
     |               属性名常量               |
     ===========================================*/
@@ -95,8 +95,8 @@ public interface DictionaryEntity<ITEM extends DictionaryItemEntity> extends Gen
      */
     void setStatus(Byte enabled);
 
-    List<ITEM> getItems();
+    List<DictionaryItemEntity> getItems();
 
-    void setItems(List<ITEM> items);
+    void setItems(List<DictionaryItemEntity> items);
 
 }

+ 4 - 4
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-entity/src/main/java/org/hswebframework/web/entity/dictionary/SimpleDictionaryEntity.java

@@ -25,7 +25,7 @@ import java.util.List;
  *
  * @author hsweb-generator-online
  */
-public class SimpleDictionaryEntity extends SimpleGenericEntity<String> implements DictionaryEntity<SimpleDictionaryItemEntity> {
+public class SimpleDictionaryEntity extends SimpleGenericEntity<String> implements DictionaryEntity {
     //字典名称
     private String                           name;
     //分类id
@@ -39,7 +39,7 @@ public class SimpleDictionaryEntity extends SimpleGenericEntity<String> implemen
     //状态
     private Byte                             status;
     //字段选项
-    private List<SimpleDictionaryItemEntity> items;
+    private List<DictionaryItemEntity> items;
 
     /**
      * @return 字典名称
@@ -126,12 +126,12 @@ public class SimpleDictionaryEntity extends SimpleGenericEntity<String> implemen
     }
 
     @Override
-    public List<SimpleDictionaryItemEntity> getItems() {
+    public List<DictionaryItemEntity> getItems() {
         return items;
     }
 
     @Override
-    public void setItems(List<SimpleDictionaryItemEntity> items) {
+    public void setItems(List<DictionaryItemEntity> items) {
         this.items = items;
     }
 }

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-api/src/main/java/org/hswebframework/web/service/dictionary/DictionaryParserService.java

@@ -28,7 +28,7 @@ import org.hswebframework.web.service.CrudService;
  */
 public interface DictionaryParserService extends CrudService<DictionaryParserEntity, String> {
 
-    <V> DictionaryParser<V> getParser(DictionaryEntity<? extends DictionaryItemEntity> dict, String parserId);
+    <V> DictionaryParser<V> getParser(DictionaryEntity dict, String parserId);
 
 
 }

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-api/src/main/java/org/hswebframework/web/service/dictionary/DictionaryService.java

@@ -25,6 +25,6 @@ import org.hswebframework.web.service.CrudService;
  *
  * @author hsweb-generator-online
  */
-public interface DictionaryService extends CrudService<DictionaryEntity<DictionaryItemEntity>, String> {
+public interface DictionaryService extends CrudService<DictionaryEntity, String> {
 
 }

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryParser.java

@@ -80,7 +80,7 @@ public class SimpleDictionaryParser<V> implements DictionaryParser<V> {
     }
 
     //设置DictionaryEntity作为配置
-    public SimpleDictionaryParser<V> setDict(DictionaryEntity<? extends DictionaryItemEntity> dict) {
+    public SimpleDictionaryParser<V> setDict(DictionaryEntity dict) {
         SimpleSingleDictParser toTextParser = new SimpleSingleDictParser();
         toTextParser.setDict(dict, DictionaryItemEntity::getValue
                 , DictionaryItemEntity::getText

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryParserService.java

@@ -53,7 +53,7 @@ public class SimpleDictionaryParserService extends GenericEntityService<Dictiona
     }
 
     @Override
-    public <V> DictionaryParser<V> getParser(DictionaryEntity<? extends DictionaryItemEntity> dict, String parserId) {
+    public <V> DictionaryParser<V> getParser(DictionaryEntity dict, String parserId) {
         DictionaryParserEntity entity = selectByPk(parserId);
         assertNotNull(entity);
         SimpleDictionaryParser<V> parser = new SimpleDictionaryParser<>();

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/SimpleDictionaryService.java

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Service;
  * @author hsweb-generator-online
  */
 @Service("dictionaryService")
-public class SimpleDictionaryService extends GenericEntityService<DictionaryEntity<DictionaryItemEntity>, String>
+public class SimpleDictionaryService extends GenericEntityService<DictionaryEntity, String>
         implements DictionaryService {
     @Autowired
     private DictionaryDao dictionaryDao;

+ 1 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/main/java/org/hswebframework/web/service/dictionary/simple/parser/SimpleSingleDictParser.java

@@ -27,7 +27,7 @@ public class SimpleSingleDictParser implements SingleDictParser {
     private DictParserFormatter formatter = new SimpleDictParserFormatter();
 
     //设置DictionaryEntity作为配置
-    public void setDict(DictionaryEntity<? extends DictionaryItemEntity> dict,
+    public void setDict(DictionaryEntity dict,
                         Function<DictionaryItemEntity, String> keyGetter,
                         Function<DictionaryItemEntity, String> valueGetter,
                         Function<DictionaryItemEntity, String> expressionGetter) {

+ 2 - 1
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/test/java/org/hswebframework/web/starter/dictionary/DictionaryParserTests.java

@@ -19,6 +19,7 @@
 package org.hswebframework.web.starter.dictionary;
 
 import com.alibaba.fastjson.JSON;
+import org.hswebframework.web.entity.dictionary.DictionaryItemEntity;
 import org.hswebframework.web.entity.dictionary.SimpleDictionaryEntity;
 import org.hswebframework.web.entity.dictionary.SimpleDictionaryItemEntity;
 import org.hswebframework.web.service.dictionary.DictionaryParser;
@@ -56,7 +57,7 @@ public class DictionaryParserTests {
                 ",{'value':'2','text':'蔬菜'}" +
                 "]";
 
-        List<SimpleDictionaryItemEntity> itemEntities = JSON.parseArray(json, SimpleDictionaryItemEntity.class);
+        List<DictionaryItemEntity> itemEntities = JSON.parseArray(json, DictionaryItemEntity.class);
         dictionaryEntity.setItems(itemEntities);
         this.parser = new SimpleDictionaryParser<String>()
                 .addToTextExpression("10105", "${#value}[${#context[otherApple]}]")

+ 2 - 2
hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/starter/dictionary/DictionaryTests.java

@@ -45,7 +45,7 @@ public class DictionaryTests extends SimpleWebApplicationTests {
 
     @Test
     public void testCrud() throws Exception {
-        DictionaryEntity<DictionaryItemEntity> entity = entityFactory.newInstance(DictionaryEntity.class);
+        DictionaryEntity entity = entityFactory.newInstance(DictionaryEntity.class);
         //todo 设置测试属性
         entity.setName("test");
         entity.setCreatorId("admin");
@@ -72,7 +72,7 @@ public class DictionaryTests extends SimpleWebApplicationTests {
                 ",{'value':'2','text':'蔬菜'}" +
                 "]";
 
-        List<DictionaryItemEntity> itemEntities = (List) JSON.parseArray(json, SimpleDictionaryItemEntity.class);
+        List<DictionaryItemEntity> itemEntities = JSON.parseArray(json, DictionaryItemEntity.class);
         entity.setItems(itemEntities);
         // test add data
         String requestBody = JSON.toJSONString(entity);