Ver código fonte

Merge branch 'master' of https://e.coding.net/chuanghaikeji/smarCampus/backend_dormitory

夏文涛 1 ano atrás
pai
commit
f5c1a17bdb

+ 1 - 1
src/main/java/com/template/api/WelcomeDormitoryControllerAPI.java

@@ -31,7 +31,7 @@ public interface WelcomeDormitoryControllerAPI {
 
     @GetMapping(value = "/listDormitory")
     @ApiOperation(value = "查询寝室", notes = "查询寝室", httpMethod = "GET")
-    CommonResult listDormitory(@RequestParam int currentPage, @RequestParam int pageCount,Integer schoolId,Integer buildId,Integer dormitoryId,String sex,Integer collegeId,Integer status,Integer retentionState);
+    CommonResult listDormitory(@RequestParam int currentPage, @RequestParam int pageCount,Integer schoolId,Integer buildId,Integer dormitoryId,String sex,Integer collegeId,Integer status,Integer retentionState,Integer accountId);
 
 
     @GetMapping(value = "/dormitoryGroup")

+ 19 - 2
src/main/java/com/template/controller/WelcomeDormitoryController.java

@@ -68,6 +68,9 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
     @Autowired
     private WelcomeSchoolService welcomeSchoolService;
 
+    @Autowired
+    private WelcomeAccountService welcomeAccountService;
+
     @Override
     public CommonResult saveDormitory(WelcomeDormitory welcomeDormitory) {
 
@@ -255,9 +258,23 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
     }
 
     @Override
-    public CommonResult listDormitory(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, Integer collegeId, Integer status, Integer retentionState) {
+    public CommonResult listDormitory(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, Integer collegeId, Integer status, Integer retentionState,Integer accountId) {
+
+//        当学院为空
+        PageUtils<WelcomeDormitoryVo> pageUtils=null;
+        if (ObjectUtils.isEmpty(collegeId)) {
+            String collegeIds="";
+            WelcomeAccount account = welcomeAccountService.getById(accountId);
+            if (ObjectUtils.isEmpty(account)) {
+                return CommonResult.fail("当前账号已被删除,请重新登入");
+            }
+            collegeIds=account.getCollegeId();
+           pageUtils = welcomeDormitoryService.listDormitoryCPage(currentPage, pageCount, schoolId, buildId, dormitoryId, sex, collegeIds, status, retentionState);
+        }else {
+            pageUtils = welcomeDormitoryService.listDormitoryPage(currentPage, pageCount, schoolId, buildId, dormitoryId, sex, collegeId, status, retentionState);
+        }
+
 
-        PageUtils<WelcomeDormitoryVo> pageUtils = welcomeDormitoryService.listDormitoryPage(currentPage, pageCount, schoolId, buildId, dormitoryId, sex, collegeId, status, retentionState);
 
         if (pageUtils != null && pageUtils.getList() != null && pageUtils.getList().size() > 0) {
             List<Integer> dormitoryIds = pageUtils.getList().stream().map(WelcomeDormitoryVo::getId).collect(Collectors.toList());

+ 5 - 0
src/main/java/com/template/mapper/WelcomeDormitoryMapper.java

@@ -33,4 +33,9 @@ public interface WelcomeDormitoryMapper extends BaseMapper<WelcomeDormitory> {
     IPage<WelcomeDormitoryVo> listDormitoryPage(Page<WelcomeDormitoryVo> page, @Param("schoolId") Integer schoolId, @Param("buildId") Integer buildId,
                                                 @Param("dormitoryId") Integer dormitoryId, @Param("sex") String sex, @Param("collegeId") Integer collegeId,
                                                 @Param("status") Integer status,@Param("retentionState") Integer retentionState);
+
+    IPage<WelcomeDormitoryVo> listDormitoryCPage(Page<WelcomeDormitoryVo> page, @Param("schoolId") Integer schoolId, @Param("buildId") Integer buildId,
+                                                @Param("dormitoryId") Integer dormitoryId, @Param("sex") String sex, @Param("collegeIds") String collegeIds,
+                                                @Param("status") Integer status,@Param("retentionState") Integer retentionState);
+
 }

+ 2 - 0
src/main/java/com/template/services/WelcomeDormitoryService.java

@@ -39,4 +39,6 @@ public interface WelcomeDormitoryService extends IService<WelcomeDormitory> {
     PageUtils<WelcomeDormitoryVo> listDormitoryPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, Integer collegeId, Integer status, Integer retentionState);
 
     WelcomeDormitory queryExistDormotory(Integer schoolId, Integer buildId, String dormitory);
+
+    PageUtils<WelcomeDormitoryVo> listDormitoryCPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, String collegeIds, Integer status, Integer retentionState);
 }

+ 7 - 0
src/main/java/com/template/services/impl/WelcomeDormitoryServiceImpl.java

@@ -116,4 +116,11 @@ public class WelcomeDormitoryServiceImpl extends ServiceImpl<WelcomeDormitoryMap
         WelcomeDormitory result = welcomeDormitoryMapper.selectOne(queryWrapper);
         return result;
     }
+
+    @Override
+    public PageUtils<WelcomeDormitoryVo> listDormitoryCPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, String collegeIds, Integer status, Integer retentionState) {
+        Page<WelcomeDormitoryVo> page = new Page<>(currentPage, pageCount);
+        IPage<WelcomeDormitoryVo> result = welcomeDormitoryMapper.listDormitoryCPage(page,schoolId,buildId,dormitoryId,sex,collegeIds,status,retentionState);
+        return new PageUtils<>(result);
+    }
 }

+ 45 - 0
src/main/resources/mapper/template/WelcomeDormitoryMapper.xml

@@ -110,4 +110,49 @@
         </if>
         order by wd.create_time desc
     </select>
+    <select id="listDormitoryCPage" resultType="com.template.model.vo.WelcomeDormitoryVo">
+        SELECT
+        wd.id,
+        wd.school_id as schoolId,
+        ws.school,
+        wd.build_id as buildId,
+        wb.build,
+        wd.dormitory,
+        wd.sex,
+        wd.college_id as collegeId,
+        wo.name as college,
+        wd.grade as grade,
+        wd.bed_number as bedNumber,
+        wd.remark,
+        wd.status,
+        wd.free_bed_number as freeBedNumber,
+        wd.retention_state as retentionState
+        FROM
+        `welcome_dormitory` wd
+        LEFT JOIN welcome_school ws ON wd.school_id = ws.id and ws.deleted = 0
+        LEFT JOIN welcome_build wb ON wd.build_id = wb.id and wb.deleted = 0
+        LEFT JOIN welcome_org wo ON wd.college_id = wo.id and wo.deleted = 0
+        WHERE
+        wd.deleted =0
+        <if test="schoolId != null and schoolId != ''">
+            and wd.school_id = #{schoolId}
+        </if>
+        <if test="buildId != null and buildId != ''">
+            and wd.build_id = #{buildId}
+        </if>
+        <if test="dormitoryId != null and dormitoryId != ''">
+            and wd.id = #{dormitoryId}
+        </if>
+        <if test="sex != null and sex != ''">
+            and wd.sex = #{sex}
+        </if>
+        <if test="status != null and status != ''">
+            and wd.status = #{status}
+        </if>
+        <if test="retentionState != null and retentionState != ''">
+            and wd.retention_state = #{retentionState}
+        </if>
+        AND FIND_IN_SET(wd.college_id,#{collegeIds})
+        order by wd.create_time desc
+    </select>
 </mapper>