From 39ada1702979b83b0573faf784a7c0bd46335260 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期二, 10 五月 2022 18:17:47 +0800
Subject: [PATCH] 一键求助

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java |   47 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
index e81e7f7..269da56 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/InterphoneHostService.java
@@ -1,8 +1,14 @@
 package com.sandu.ximon.admin.service;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
+import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
 import com.sandu.ximon.admin.param.InterphoneHostParam;
+import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.dao.bo.InterphoneHostBo;
 import com.sandu.ximon.dao.domain.InterphoneHost;
+import com.sandu.ximon.dao.domain.InterphoneHostSubPole;
 import com.sandu.ximon.dao.mapper.InterphoneHostMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.BeanUtils;
@@ -12,27 +18,28 @@
 
 @Service
 @AllArgsConstructor
-public class InterphoneHostService extends BaseServiceImpl <InterphoneHostMapper, InterphoneHost>{
+public class InterphoneHostService extends BaseServiceImpl<InterphoneHostMapper, InterphoneHost> {
 
     private final InterphoneHostMapper interphoneHostMapper;
+
+    private final InterphoneHostSubService interphoneHostSubService;
 
 
     /**
      * 娣诲姞涓绘満
-     *
      */
     public boolean addHost(InterphoneHostParam interphoneHostParam) {
         InterphoneHost interphoneHost = new InterphoneHost();
         BeanUtils.copyProperties(interphoneHostParam, interphoneHost);
-       return save(interphoneHost);
+        return save(interphoneHost);
     }
 
     /**
      * 淇敼涓绘満
      */
-    public boolean updateHost(Integer id,InterphoneHostParam interphoneHostParam) {
+    public boolean updateHost(Integer id, InterphoneHostParam interphoneHostParam) {
         InterphoneHost byId = getById(id);
-        if(byId == null){
+        if (byId == null) {
             return false;
         }
         InterphoneHost interphoneHost = new InterphoneHost();
@@ -43,13 +50,18 @@
 
     /**
      * 鍒犻櫎涓绘満
+     *
      * @param id
      * @return
-     *
-      */
+     */
     public boolean deleteHost(Integer id) {
         InterphoneHost byId = getById(id);
-        if(byId == null){
+
+        InterphoneHostSubPole one = interphoneHostSubService.getOne(Wrappers.lambdaQuery(InterphoneHostSubPole.class).eq(InterphoneHostSubPole::getHostId, id));
+        if(one!=null){
+            throw new RuntimeException("璇ヤ富鏈哄瓨鍦ㄧ粦瀹氬叧绯伙紝涓嶈兘鍒犻櫎");
+        }
+        if (byId == null) {
             return false;
         }
         return removeById(id);
@@ -57,12 +69,13 @@
 
     /**
      * 鏌ヨ涓绘満
+     *
      * @param id
      * @return
      */
     public InterphoneHost getHost(Integer id) {
         InterphoneHost byId = getById(id);
-        if(byId == null){
+        if (byId == null) {
             return null;
         }
         return byId;
@@ -71,10 +84,16 @@
     /**
      * 鏌ヨ涓绘満鍒楄〃
      */
-    public List<InterphoneHost> getHostList() {
-        List<InterphoneHost> list = list();//TODO
-        return list();
+    public List<InterphoneHostBo> getInterphoneHostList(BaseConditionVO baseConditionVO, String keyword) {
+        if (baseConditionVO != null) {
+            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+        }
+        List<InterphoneHostBo> list;
+        if (SecurityUtils.getClientId() == null) {
+            list = interphoneHostMapper.getInterphoneHostList(keyword, null);
+        } else {
+            list = interphoneHostMapper.getInterphoneHostList(keyword, SecurityUtils.getUserId());
+        }
+        return list;
     }
-
-
 }

--
Gitblit v1.9.3