Ver código fonte

学校功能

TRX 1 ano atrás
pai
commit
a118dc5258

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DictInfoSearch.java

@@ -2,6 +2,7 @@ package com.zhongshu.card.client.model.school;
 
 import com.zhongshu.card.client.model.base.SuperParam;
 import com.zhongshu.card.client.model.base.SuperSearch;
+import com.zhongshu.card.client.utils.type.DictInfoType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -14,4 +15,7 @@ public class DictInfoSearch extends SuperSearch {
     @Schema(description = "字典名称")
     private String name;
 
+    @Schema(description = "字典类型")
+    DictInfoType dictInfoType;
+
 }

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/service/school/DictInfoService.java

@@ -6,6 +6,8 @@ import com.zhongshu.card.client.ret.ResultContent;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
+import java.util.List;
+
 /**
  * 字典
  *
@@ -22,4 +24,6 @@ public interface DictInfoService {
 
     ResultContent<Page<DictInfoParam>> page(DictInfoSearch param, Pageable pageable);
 
+    ResultContent<List<DictInfoParam>> findDictInfosByOid(DictInfoSearch param);
+
 }

+ 10 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/school/DictInfoController.java

@@ -22,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * 字典管理
  *
@@ -75,4 +77,12 @@ public class DictInfoController {
         return dictInfoService.page(param, pageable);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "查询字典所有的数据", description = "查询字典所有的数据")
+    @RequestMapping(value = {"findDictInfosByOid"}, method = {RequestMethod.POST})
+    public ResultContent<List<DictInfoParam>> findDictInfosByOid(
+            @Parameter(required = false) DictInfoSearch param) {
+        return dictInfoService.findDictInfosByOid(param);
+    }
+
 }

+ 1 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/school/DictInfoDao.java

@@ -20,4 +20,5 @@ public interface DictInfoDao extends MongoDao<DictInfo>, DictInfoDaoExtend {
 
     DictInfo findTopByNameAndOidAndDictInfoType(String name, String oid, DictInfoType dictInfoType);
 
+    List<DictInfo> findByOidAndDictInfoTypeOrderBySortAsc(String oid, DictInfoType dictInfoType);
 }

+ 4 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/school/impl/DictInfoDaoImpl.java

@@ -48,6 +48,10 @@ public class DictInfoDaoImpl extends BaseImpl implements DictInfoDaoExtend {
             criteria.and("oid").is(param.getOid());
         }
 
+        if (param.getDictInfoType() != null) {
+            criteria.and("dictInfoType").is(param.getDictInfoType());
+        }
+
         // 模糊搜索
         List<Criteria> criterias = new ArrayList<>();
         if (StringUtils.isNotEmpty(param.getName())) {

+ 15 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/AreaServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongshu.card.server.core.service.school;
 
 import com.zhongshu.card.client.model.school.AreaModel;
 import com.zhongshu.card.client.model.school.AreaParam;
+import com.zhongshu.card.client.model.school.DictInfoParam;
 import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.ret.ResultMessage;
 import com.zhongshu.card.client.service.school.AreaService;
@@ -10,8 +11,10 @@ import com.zhongshu.card.client.utils.TreeUtil;
 import com.zhongshu.card.client.utils.type.DataState;
 import com.zhongshu.card.server.core.dao.school.AreaDao;
 import com.zhongshu.card.server.core.dao.school.CollegeDao;
+import com.zhongshu.card.server.core.dao.school.DictInfoDao;
 import com.zhongshu.card.server.core.domain.school.Area;
 import com.zhongshu.card.server.core.domain.school.College;
+import com.zhongshu.card.server.core.domain.school.DictInfo;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import com.zhongshu.card.server.core.util.CommonUtil;
@@ -35,6 +38,9 @@ public class AreaServiceImpl extends SuperService implements AreaService {
     @Autowired
     AreaDao areaDao;
 
+    @Autowired
+    DictInfoDao dictInfoDao;
+
     /**
      * 添加院级
      *
@@ -42,7 +48,7 @@ public class AreaServiceImpl extends SuperService implements AreaService {
      * @return
      */
     @Override
-    public ResultContent<College> addArea(AreaParam param) {
+    public ResultContent<Area> addArea(AreaParam param) {
         initDefaultUserAndOid(param);
 
         if (CommonUtil.longIsEmpty(param.getSort())) {
@@ -82,6 +88,8 @@ public class AreaServiceImpl extends SuperService implements AreaService {
             entity = new Area();
         }
         BeanUtils.copyProperties(param, entity);
+        DictInfo dictInfo = dictInfoDao.findTopById(param.getDictInfoId());
+        entity.setDictInfo(dictInfo);
         areaDao.save(entity);
         return ResultContent.buildSuccess(entity);
     }
@@ -128,6 +136,12 @@ public class AreaServiceImpl extends SuperService implements AreaService {
         AreaModel model = new AreaModel();
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
+            DictInfo dictInfo = entity.getDictInfo();
+            if (dictInfo != null) {
+                DictInfoParam param = new DictInfoParam();
+                BeanUtils.copyProperties(dictInfo, param);
+                model.setDictInfo(param);
+            }
         }
         return model;
     }

+ 17 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/school/DictInfoServiceImpl.java

@@ -23,6 +23,9 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Assert;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * 字典管理服务
  *
@@ -117,6 +120,20 @@ public class DictInfoServiceImpl extends SuperService implements DictInfoService
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
 
+    /**
+     * 查询字典所有数据
+     *
+     * @param param
+     * @return
+     */
+    @Override
+    public ResultContent<List<DictInfoParam>> findDictInfosByOid(DictInfoSearch param) {
+        initOidSearchParam(param);
+        Assert.isNull(param.getDictInfoType(), "dictInfoType不能为空");
+        List<DictInfo> list = dictInfoDao.findByOidAndDictInfoTypeOrderBySortAsc(param.getOid(), param.getDictInfoType());
+        List<DictInfoParam> models = list.stream().map(this::toModel).collect(Collectors.toList());
+        return ResultContent.buildSuccess(models);
+    }
 
     public DictInfoParam toModel(DictInfo dictInfo) {
         DictInfoParam model = new DictInfoParam();