Quellcode durchsuchen

1.添加获取科室列表功能

王鹏鹏 vor 2 Jahren
Ursprung
Commit
c14b303b25

+ 46 - 2
baselib/schemas/com.yingyangfly.baselib.db.AppDataBase/1.json

@@ -2,7 +2,7 @@
   "formatVersion": 1,
   "database": {
     "version": 1,
-    "identityHash": "a8e4dc429cedceb34dc39bb5c7e4ee60",
+    "identityHash": "86a44f7dd432c2931916a6088529ea75",
     "entities": [
       {
         "tableName": "Questions",
@@ -371,12 +371,56 @@
         },
         "indices": [],
         "foreignKeys": []
+      },
+      {
+        "tableName": "Department",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `departmentName` TEXT, `orgCode` TEXT, `orgName` TEXT, `remark` TEXT, PRIMARY KEY(`id`))",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "departmentName",
+            "columnName": "departmentName",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "orgCode",
+            "columnName": "orgCode",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "orgName",
+            "columnName": "orgName",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "remark",
+            "columnName": "remark",
+            "affinity": "TEXT",
+            "notNull": false
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": false
+        },
+        "indices": [],
+        "foreignKeys": []
       }
     ],
     "views": [],
     "setupQueries": [
       "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
-      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a8e4dc429cedceb34dc39bb5c7e4ee60')"
+      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '86a44f7dd432c2931916a6088529ea75')"
     ]
   }
 }

+ 7 - 0
baselib/src/main/java/com/yingyangfly/baselib/base/BaseActivity.kt

@@ -26,6 +26,7 @@ import com.yingyangfly.baselib.R
 import com.yingyangfly.baselib.bean.MessageBean
 import com.yingyangfly.baselib.databinding.ActivityBaseBinding
 import com.yingyangfly.baselib.db.AppDataBase
+import com.yingyangfly.baselib.db.DepartmentDao
 import com.yingyangfly.baselib.db.DoctorDao
 import com.yingyangfly.baselib.db.GameSoundDao
 import com.yingyangfly.baselib.db.QuestionsDao
@@ -97,6 +98,11 @@ abstract class BaseActivity<DB : ViewDataBinding> : AppCompatActivity(), OnRefre
      */
     var voicePlayerDao: VoicePlayerDao? = null
 
+    /**
+     * 科室列表
+     */
+    var departmentDao: DepartmentDao? = null
+
     @SuppressLint("SourceLockedOrientationActivity")
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -121,6 +127,7 @@ abstract class BaseActivity<DB : ViewDataBinding> : AppCompatActivity(), OnRefre
             doctorDao = db?.getDoctorsDao()
             gameSoundDao = db?.getGameSoundDao()
             voicePlayerDao = db?.getVoicePlayerDao()
+            departmentDao = db?.getDepartmentDao()
         }
         initProducer()
         initMVVM()

+ 1 - 1
baselib/src/main/java/com/yingyangfly/baselib/db/DepartmentDao.kt

@@ -14,7 +14,7 @@ interface DepartmentDao : BaseDao<DepartmentBean> {
     @Query("select * from Department")
     fun getAllDepartmentBean(): MutableList<DepartmentBean>
 
-    @Query("select * from Doctor where id = :id")
+    @Query("select * from Department where id = :id")
     fun getDepartmentById(id: String): DepartmentBean
 
     @Query("delete from Department")

+ 64 - 32
healthconsultation/src/main/java/com/yingyang/healthconsultation/activity/HealthConsultationActivity.kt

@@ -17,6 +17,7 @@ import com.yingyang.healthconsultation.adapter.RecommendDoctorAdapter
 import com.yingyang.healthconsultation.databinding.ActivityHealthConsultationBinding
 import com.yingyangfly.baselib.bean.def.PermissionList
 import com.yingyangfly.baselib.config.AccountConfig
+import com.yingyangfly.baselib.db.DepartmentBean
 import com.yingyangfly.baselib.db.DoctorBean
 import com.yingyangfly.baselib.ext.*
 import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
@@ -49,6 +50,11 @@ class HealthConsultationActivity :
     private val consultationAdapter by lazy { ConsultationAdapter() }
     private val consultationBeans = mutableListOf<DoctorBean>()
 
+    /**
+     * 科室列表
+     */
+    private var departmentBeans = mutableListOf<DepartmentBean>()
+
     override fun initViews() {
         binding {
             rvProgress.adapter = consultationAdapter
@@ -68,16 +74,12 @@ class HealthConsultationActivity :
                         "您有正在医疗咨询中,结束问诊后才能购买".toast()
                     } else {
                         JumpUtil.jumpActivityWithUrl(
-                            RouterUrlCommon.consultationRequest,
-                            bean.id,
-                            mContext
+                            RouterUrlCommon.consultationRequest, bean.id, mContext
                         )
                     }
                 } else {
                     JumpUtil.jumpActivityWithUrl(
-                        RouterUrlCommon.doctorDetails,
-                        bean.id,
-                        mContext
+                        RouterUrlCommon.doctorDetails, bean.id, mContext
                     )
                 }
 
@@ -106,6 +108,7 @@ class HealthConsultationActivity :
                     v.startAnimation(getScaleAnimation())
                 }
             }
+
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 when (v.id) {
@@ -113,17 +116,19 @@ class HealthConsultationActivity :
                         //返回首页
                         finish()
                     }
+
                     R.id.searchLayout -> {
                         JumpUtil.jumpActivity(RouterUrlCommon.searchDoctor, mContext)
                     }
+
                     R.id.btnConsultationRecord -> {
                         JumpUtil.jumpActivity(
-                            RouterUrlCommon.consultationRecord,
-                            mContext
+                            RouterUrlCommon.consultationRecord, mContext
                         )
                     }
                 }
             }
+
             MotionEvent.ACTION_CANCEL -> {
                 if (v.id == R.id.layoutHome || v.id == R.id.searchLayout || v.id == R.id.btnConsultationRecord) {
                     v.startAnimation(getEndAnimation())
@@ -135,6 +140,13 @@ class HealthConsultationActivity :
 
     override fun onResume() {
         super.onResume()
+        departmentBeans.clear()
+        if (departmentDao != null) {
+            val departmentBeanList = departmentDao?.getAllDepartmentBean()
+            if (departmentBeanList.isNullOrEmpty().not()) {
+                departmentBeans.addAll(departmentBeanList!!)
+            }
+        }
         getConsultationList()
         getRecommendDoctorList()
     }
@@ -153,6 +165,13 @@ class HealthConsultationActivity :
                     consultationStatus = it.status
                     consultationAdapter.setTime(it.createTime)
                     if (it.doctor != null) {
+                        if (departmentDao != null) {
+                            val departmentBean =
+                                departmentDao?.getDepartmentById(it.doctor.departmentName)
+                            if (departmentBean != null) {
+                                it.doctor.departmentName = departmentBean.departmentName
+                            }
+                        }
                         consultationBeans.add(it.doctor)
                     }
                 }
@@ -176,15 +195,25 @@ class HealthConsultationActivity :
         viewModel.getRecommendDoctorList(fail = {
             "获取推荐医生列表失败".toast()
         }, success = {
-            if (it.isNullOrEmpty().not()) {
-                doctorBeans.clear()
-                doctorBeans.addAll(it!!)
-                if (doctorDao != null) {
-                    doctorDao?.insertAll(doctorBeans)
+            runOnUiThread {
+                if (it.isNullOrEmpty().not()) {
+                    doctorBeans.clear()
+                    if (departmentDao != null) {
+                        it?.forEach {
+                            val departmentBean = departmentDao?.getDepartmentById(it.departmentName)
+                            if (departmentBean != null) {
+                                it.departmentName = departmentBean.departmentName
+                            }
+                        }
+                    }
+                    doctorBeans.addAll(it!!)
+                    if (doctorDao != null) {
+                        doctorDao?.insertAll(doctorBeans)
+                    }
                 }
+                recommendDoctorAdapter.showEmptyView = doctorBeans.isEmpty()
+                recommendDoctorAdapter.setData(doctorBeans)
             }
-            recommendDoctorAdapter.showEmptyView = doctorBeans.isEmpty()
-            recommendDoctorAdapter.setData(doctorBeans)
         })
     }
 
@@ -207,26 +236,29 @@ class HealthConsultationActivity :
      * 登录IM
      */
     private fun loginIM(sign: String, bean: DoctorBean) {
-        TUILogin.login(mContext, AccountConfig.TENCENT_IM_APPID, User.getUserId(), sign, object :
-            TUICallback() {
-            override fun onSuccess() {
-                runOnUiThread {
-                    val param = Bundle()
-                    param.putInt(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C)
-                    param.putString(TUIConstants.TUIChat.CHAT_ID, bean.id)
-                    param.putString(TUIConstants.TUIChat.CHAT_NAME, bean.userName)
-                    param.putString(TUIConstants.TUIChat.FACE_URL, bean.avatar)
-                    User.saveDoctorAvatar(bean.avatar)
-                    TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
+        TUILogin.login(mContext,
+            AccountConfig.TENCENT_IM_APPID,
+            User.getUserId(),
+            sign,
+            object : TUICallback() {
+                override fun onSuccess() {
+                    runOnUiThread {
+                        val param = Bundle()
+                        param.putInt(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C)
+                        param.putString(TUIConstants.TUIChat.CHAT_ID, bean.id)
+                        param.putString(TUIConstants.TUIChat.CHAT_NAME, bean.userName)
+                        param.putString(TUIConstants.TUIChat.FACE_URL, bean.avatar)
+                        User.saveDoctorAvatar(bean.avatar)
+                        TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
+                    }
                 }
-            }
 
-            override fun onError(errorCode: Int, errorMessage: String?) {
-                runOnUiThread {
-                    "IM登陆失败".toast()
+                override fun onError(errorCode: Int, errorMessage: String?) {
+                    runOnUiThread {
+                        "IM登陆失败".toast()
+                    }
                 }
-            }
-        })
+            })
     }
 
     /**

+ 1 - 1
healthconsultation/src/main/java/com/yingyang/healthconsultation/dialog/PaymentQrCodeDialog.kt

@@ -141,7 +141,7 @@ class PaymentQrCodeDialog : DialogFragment() {
             time = 60 * 15 * 1 - it - 1
             val minutes = time / 60
             val seconds = time % 60
-            if (it.toInt() == 0) {
+            if (time.toInt() == 0) {
                 rxTimer.cancel()
                 tvCountdown?.show(false)
                 delPayOrder()

+ 8 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/doctordetails/DoctorDetailsActivity.kt

@@ -100,6 +100,12 @@ class DoctorDetailsActivity :
             it.toast()
         }, success = {
             if (it != null) {
+                if (departmentDao != null) {
+                    val departmentBean = departmentDao?.getDepartmentById(it.departmentName)
+                    if (departmentBean != null) {
+                        it.departmentName = departmentBean.departmentName
+                    }
+                }
                 if (doctorDao != null) {
                     doctorDao?.insert(it)
                 }
@@ -149,6 +155,7 @@ class DoctorDetailsActivity :
                     v.startAnimation(getScaleAnimation())
                 }
             }
+
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 when (v.id) {
@@ -181,6 +188,7 @@ class DoctorDetailsActivity :
                     }
                 }
             }
+
             MotionEvent.ACTION_CANCEL -> {
                 if (v.id == R.id.backLayout || v.id == R.id.btnConsult || v.id == R.id.tvAllEvaluate) {
                     v.startAnimation(getEndAnimation())

+ 6 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/paid/PaidActivity.kt

@@ -398,6 +398,12 @@ class PaidActivity : BaseMVVMActivity<ActivityPaidBinding, PaidViewModel>(),
                 it.toast()
             }, success = {
                 if (it != null) {
+                    if (departmentDao != null) {
+                        val departmentBean = departmentDao?.getDepartmentById(it.departmentName)
+                        if (departmentBean != null) {
+                            it.departmentName = departmentBean.departmentName
+                        }
+                    }
                     doctor = it
                     binding.doctor = it
                 }

+ 15 - 5
healthconsultation/src/main/java/com/yingyang/healthconsultation/payment/PaymentActivity.kt

@@ -79,6 +79,12 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
             it.toast()
         }, success = {
             if (it != null) {
+                if (departmentDao != null) {
+                    val departmentBean = departmentDao?.getDepartmentById(it.departmentName)
+                    if (departmentBean != null) {
+                        it.departmentName = departmentBean.departmentName
+                    }
+                }
                 binding.data = it
                 binding.tvMoney.text = if (TextUtils.isEmpty(price)) {
                     "¥ " + it.price
@@ -111,12 +117,14 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
                     v.startAnimation(getScaleAnimation())
                 }
             }
+
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 when (v.id) {
                     R.id.backLayout -> {
                         finish()
                     }
+
                     R.id.wechatLayout -> {
                         if (purchaseConsultationBean != null) {
                             purchaseConsultationBean?.payMethod = "1"
@@ -129,6 +137,7 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
                             imageAlipaySelected.show(false)
                         }
                     }
+
                     R.id.alipayLayout -> {
                         if (purchaseConsultationBean != null) {
                             purchaseConsultationBean?.payMethod = "2"
@@ -141,6 +150,7 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
                             imageAlipaySelected.show(true)
                         }
                     }
+
                     R.id.btnSubmit -> {
                         if (CommonUtils.isFastClick) {
                             submit()
@@ -148,6 +158,7 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
                     }
                 }
             }
+
             MotionEvent.ACTION_CANCEL -> {
                 if (v.id == R.id.backLayout || v.id == R.id.wechatLayout || v.id == R.id.alipayLayout || v.id == R.id.btnSubmit) {
                     v.startAnimation(getEndAnimation())
@@ -213,11 +224,10 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
                     "是"
                 }
                 patientInfoBean.isConsultation = consultation
-                RxBus.get()
-                    .send(
-                        RxBusCodes.purchaseConsultationEvent,
-                        PurchaseConsultationEvent(id, GsonUtil.GsonString(patientInfoBean))
-                    )
+                RxBus.get().send(
+                    RxBusCodes.purchaseConsultationEvent,
+                    PurchaseConsultationEvent(id, GsonUtil.GsonString(patientInfoBean))
+                )
             }
         }
         super.onDestroy()

+ 16 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/record/ConsultationRecordActivity.kt

@@ -52,6 +52,7 @@ class ConsultationRecordActivity :
                         //0未支付
                         payOrder(bean)
                     }
+
                     "1" -> {
                         //1待接诊
                         showTipsDialog(
@@ -60,20 +61,24 @@ class ConsultationRecordActivity :
                             "您确定取消咨询?医生很快就会在线回复,如果您继续取消,咨询费用1到3天原路退回您的支付账户。"
                         )
                     }
+
                     "2" -> {
                         //2接诊中
                         if (bean.doctor != null) {
                             applyCameraPermission(bean.doctor)
                         }
                     }
+
                     "3" -> {
                         //3已拒诊
                         reinterview(bean.sysUserId)
                     }
+
                     "4" -> {
                         //4已完成
                         evaluationOrder(bean, position)
                     }
+
                     "5" -> {
                         //已取消
                         reinterview(bean.sysUserId)
@@ -198,6 +203,15 @@ class ConsultationRecordActivity :
         }, success = {
             records.clear()
             if (it.isNullOrEmpty().not()) {
+                it?.forEach {
+                    if (departmentDao != null && it.doctor != null) {
+                        val departmentBean =
+                            departmentDao?.getDepartmentById(it.doctor.departmentName)
+                        if (departmentBean != null) {
+                            it.doctor.departmentName = departmentBean.departmentName
+                        }
+                    }
+                }
                 records.addAll(it!!)
             }
             adapter.showEmptyView = records.isEmpty()
@@ -213,6 +227,7 @@ class ConsultationRecordActivity :
                     v.startAnimation(getScaleAnimation())
                 }
             }
+
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 if (v.id == R.id.backLayout) {
@@ -220,6 +235,7 @@ class ConsultationRecordActivity :
                     finish()
                 }
             }
+
             MotionEvent.ACTION_CANCEL -> {
                 if (v.id == R.id.backLayout) {
                     v.startAnimation(getEndAnimation())

+ 5 - 5
healthconsultation/src/main/res/layout/item_consultation_record.xml

@@ -97,7 +97,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginStart="@dimen/divider_27px"
-                android:layout_marginTop="@dimen/divider_12px"
+                android:layout_marginTop="@dimen/divider_18px"
                 android:textColor="@color/color_FF333333"
                 android:textSize="@dimen/divider_24px"
                 app:layout_constraintStart_toEndOf="@+id/imageHead"
@@ -107,28 +107,28 @@
                 android:id="@+id/btnEvaluate"
                 android:layout_width="@dimen/divider_160px"
                 android:layout_height="@dimen/divider_58px"
-                android:layout_marginTop="@dimen/divider_108px"
+                android:layout_marginTop="@dimen/divider_12px"
                 android:layout_marginEnd="@dimen/divider_16px"
                 android:background="@drawable/bg_consultation_record"
                 android:gravity="center"
                 android:textColor="@android:color/white"
                 android:textSize="@dimen/divider_20px"
                 app:layout_constraintEnd_toStartOf="@+id/btnRecord"
-                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/tvContent"
                 tools:text="@string/evaluate" />
 
             <androidx.appcompat.widget.AppCompatButton
                 android:id="@+id/btnRecord"
                 android:layout_width="@dimen/divider_160px"
                 android:layout_height="@dimen/divider_58px"
-                android:layout_marginTop="@dimen/divider_108px"
+                android:layout_marginTop="@dimen/divider_12px"
                 android:layout_marginEnd="@dimen/divider_20px"
                 android:background="@drawable/bg_consultation_record"
                 android:gravity="center"
                 android:textColor="@android:color/white"
                 android:textSize="@dimen/divider_20px"
                 app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/tvContent"
                 tools:text="@string/album" />
 
         </androidx.constraintlayout.widget.ConstraintLayout>

+ 38 - 10
home/src/main/java/com/yingyangfly/home/activity/HomeActivity.kt

@@ -17,6 +17,7 @@ import com.yingyang.home.databinding.ActivityHomeBinding
 import com.yingyangfly.baselib.bean.MessageBean
 import com.yingyangfly.baselib.bean.PurchaseConsultationEvent
 import com.yingyangfly.baselib.bean.Record
+import com.yingyangfly.baselib.db.DepartmentBean
 import com.yingyangfly.baselib.db.VoicePlayerBean
 import com.yingyangfly.baselib.dialog.TipsDialog
 import com.yingyangfly.baselib.ext.getEndAnimation
@@ -149,6 +150,8 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
             getCountTrain()
             //获取未读消息数量
             getCountMyMsg()
+            //获取科室列表
+            getDepartmentList()
             binding {
                 gameLayout.show(false)
                 interstellarLayout.show(false)
@@ -658,17 +661,17 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
      */
     private fun makeMessageAsRead(msg: V2TIMMessage) {
         runOnUiThread {
-            V2TIMManager.getConversationManager()
-                .cleanConversationUnreadMessageCount(String.format("c2c_%s", msg.sender),
-                    0,
-                    0,
-                    object : V2TIMCallback {
-                        override fun onSuccess() {
-                        }
+            V2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(
+                String.format("c2c_%s", msg.sender),
+                0,
+                0,
+                object : V2TIMCallback {
+                    override fun onSuccess() {
+                    }
 
-                        override fun onError(p0: Int, p1: String?) {
-                        }
-                    })
+                    override fun onError(p0: Int, p1: String?) {
+                    }
+                })
         }
     }
 
@@ -952,4 +955,29 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
             sendLog(log)
         }
     }
+
+    /**
+     * 获取科室列表
+     */
+    private fun getDepartmentList() {
+        viewModel.getDepartmentList(fail = {}, success = {
+            if (it.isNullOrEmpty().not()) {
+                updateDepartmentList(it!!)
+            }
+        })
+    }
+
+    /**
+     * 更新科室信息
+     */
+    private fun updateDepartmentList(departmentBeans: List<DepartmentBean>) {
+        runOnUiThread {
+            if (departmentDao != null) {
+                departmentDao?.deleteAll()
+                val list = mutableListOf<DepartmentBean>()
+                list.addAll(departmentBeans)
+                departmentDao?.insertAll(list)
+            }
+        }
+    }
 }

+ 21 - 14
home/src/main/java/com/yingyangfly/home/activity/HomeViewModel.kt

@@ -1,6 +1,7 @@
 package com.yingyangfly.home.activity
 
 import com.yingyangfly.baselib.bean.Record
+import com.yingyangfly.baselib.db.DepartmentBean
 import com.yingyangfly.baselib.mvvm.BaseViewModel
 import com.yingyangfly.home.entity.CountTrainBean
 import com.yingyangfly.home.entity.MyTaskBean
@@ -22,8 +23,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.getGameList()
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -35,8 +35,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.getCountTrain()
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -48,8 +47,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.findMyCurrentTask()
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -61,8 +59,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.getCountMyMsg()
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -75,8 +72,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.selectNewVersion(versionCode)
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -89,8 +85,7 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(false) {
         HOME_API.getVoiceUrl(msg)
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
     /**
@@ -103,8 +98,20 @@ class HomeViewModel : BaseViewModel() {
     ) = launchFlow(true) {
         HOME_API.gameReplay(id)
     }.runUI(
-        success,
-        fail
+        success, fail
     )
 
+    /**
+     * 科室列表
+     */
+    fun getDepartmentList(
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: List<DepartmentBean>?) -> Unit)? = null,
+    ) = launchFlow(false) {
+        HOME_API.getDepartmentList()
+    }.runUI(
+        success, fail
+    )
+
+
 }

+ 7 - 0
home/src/main/java/com/yingyangfly/home/net/HomeApiService.kt

@@ -1,6 +1,7 @@
 package com.yingyangfly.home.net
 
 import com.yingyangfly.baselib.bean.Record
+import com.yingyangfly.baselib.db.DepartmentBean
 import com.yingyangfly.baselib.db.QuestionsBean
 import com.yingyangfly.baselib.net.BaseResp
 import com.yingyangfly.home.entity.*
@@ -96,4 +97,10 @@ interface HomeApiService {
     @POST("questionRecord/selectAnswerRecordDetail")
     suspend fun selectAnswerRecordDetail(@Body requestBody: RequestBody): BaseResp<SelectAnswerRecordDetailBean>
 
+    /**
+     * 科室列表
+     */
+    @POST("department/list")
+    suspend fun getDepartmentList(): BaseResp<List<DepartmentBean>>
+
 }