Browse Source

Revert "2024-07-05 修改"

This reverts commit ef29f4e16cae4ae1645f465ee63dcbba08ffc349.
zhaiy 8 months ago
parent
commit
a819a80ea2

+ 2 - 1
app/src/main/java/com/pan_american/android/data/model/resource_management/airplane_three_code/entity/AirplaneThreeCode.kt

@@ -1,8 +1,9 @@
 package com.pan_american.android.data.model.resource_management.airplane_three_code.entity
 
 import com.pan_american.android.OASystem
+import java.io.Serializable
 
-class AirplaneThreeCode {
+class AirplaneThreeCode: Serializable {
 
     var three = ""
     var four = ""

+ 0 - 3
app/src/main/java/com/pan_american/android/data/model/resource_management/airplane_three_code/network/AirplaneThreeCodeDetailRequest.kt

@@ -1,3 +0,0 @@
-package com.pan_american.android.data.model.resource_management.airplane_three_code.network
-
-class AirplaneThreeCodeDetailRequest(val id: Int)

+ 0 - 8
app/src/main/java/com/pan_american/android/data/model/resource_management/airplane_three_code/network/AirplaneThreeCodeDetailResponse.kt

@@ -1,8 +0,0 @@
-package com.pan_american.android.data.model.resource_management.airplane_three_code.network
-
-import com.pan_american.android.base.BaseResponse
-
-class AirplaneThreeCodeDetailResponse(val data: Data):BaseResponse() {
-
-    inner class Data (val three: String, val four: String, val airPort: String, val airPort_En: String, val city: String, val country: String, val remark: String)
-}

+ 0 - 8
app/src/main/java/com/pan_american/android/data/network/APIService.kt

@@ -140,8 +140,6 @@ import com.pan_american.android.data.model.message.network.MessageUnReadCountReq
 import com.pan_american.android.data.model.message.network.MessageUnReadCountResponse
 import com.pan_american.android.data.model.message.network.MessageUnReadTotalResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.entity.AirplaneThreeCode
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailRequest
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeRequest
 import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeResponse
 import com.pan_american.android.data.model.resource_management.car_resource.entity.CarResource
@@ -301,12 +299,6 @@ interface APIService {
     @POST("/api/Resource/QueryThreeCode")
     fun getAirplaneThreeCodeData(@Body airplaneThreeCodeRequest: AirplaneThreeCodeRequest): Call<AirplaneThreeCodeResponse>
 
-    /**
-     * 机场三字码资料数据,根据ID查询三字码详情
-     */
-    @POST("api/Resource/QuerySingleThreeCode")
-    fun getAirplaneThreeCodeDetailById(@Body airplaneThreeCodeDetailRequest: AirplaneThreeCodeDetailRequest): Call<AirplaneThreeCodeDetailResponse>
-
     /**
      * 机场三字码资料数据,机场三字码信息操作
      * status: 1.新增     2.修改

+ 11 - 58
app/src/main/java/com/pan_american/android/ui/resource_management/airplane_three_code/AddAirplaneThreeCodeActivity.kt

@@ -1,13 +1,12 @@
 package com.pan_american.android.ui.resource_management.airplane_three_code
 
 import android.os.Bundle
+import android.view.View
 import com.pan_american.android.OASystem
 import com.pan_american.android.R
 import com.pan_american.android.base.BaseActivity
 import com.pan_american.android.base.BaseResponse
 import com.pan_american.android.data.model.resource_management.airplane_three_code.entity.AirplaneThreeCode
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailRequest
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailResponse
 import com.pan_american.android.data.network.APIService
 import com.pan_american.android.data.network.ServiceCreator
 import com.pan_american.android.databinding.ActivityAddAirplaneThreeCodeBinding
@@ -20,11 +19,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
     private lateinit var titleBinding: LayoutTitleBinding
 
-    private var threeCodeId = 0
-
-    private val apiService = ServiceCreator.create<APIService>()
-
-    private val airplaneThreeCode = AirplaneThreeCode()
+    private lateinit var airplaneThreeCode: AirplaneThreeCode
 
     private var fromList = false
 
@@ -34,13 +29,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
         super.onCreate(savedInstanceState)
         screenAdaptation(binding)
 
-        intent.apply {
-            fromList = getBooleanExtra("fromList", false)
-
-            if (fromList) {
-                threeCodeId = getIntExtra("id", 0)
-            }
-        }
+        fromList = intent.getBooleanExtra("fromList", false)
 
         initTitle()
         initViews()
@@ -66,25 +55,22 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
         if (fromList) {
 
-            getAirplaneThreeCodeById()
+            airplaneThreeCode =
+                intent.getSerializableExtra("airplaneResource") as AirplaneThreeCode
+            initAirplaneResourceInfo()
 
             binding.commit.setText(resources.getString(R.string.update))
-
         } else {
 
             binding.commit.setText(resources.getString(R.string.add))
+
+            airplaneThreeCode = AirplaneThreeCode()
         }
     }
 
     override fun initEvents() {
 
         binding.commit.setOnClickListener {
-
-            if (!OASystem.authorization(OASystem.THREE_CODE_RESOURCE, OASystem.EDIT)) {
-                back()
-                return@setOnClickListener
-            }
-
             if (intent.getBooleanExtra("fromList", false)) {
                 initAirplaneResource(2)
                 updateAirplaneResource()
@@ -95,42 +81,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
         }
     }
 
-    private fun getAirplaneThreeCodeById() {
-
-        apiService.getAirplaneThreeCodeDetailById(AirplaneThreeCodeDetailRequest(threeCodeId)).enqueue(object : Callback<AirplaneThreeCodeDetailResponse> {
-            override fun onResponse(
-                call: Call<AirplaneThreeCodeDetailResponse>,
-                response: Response<AirplaneThreeCodeDetailResponse>
-            ) {
-                val detailResponse = response.body()
-
-                if (detailResponse != null) {
-                    if (detailResponse.code == 200) {
-                        airplaneThreeCode.apply {
-                            id = threeCodeId
-                            three = detailResponse.data.three
-                            four = detailResponse.data.four
-                            airPort = detailResponse.data.airPort
-                            airPort_En = detailResponse.data.airPort_En
-                            city = detailResponse.data.city
-                            remark = detailResponse.data.remark
-                        }
-
-                        initAirplaneResourceInfo()
-                    } else {
-                        showMessage(detailResponse.msg)
-                    }
-                }
-            }
-
-            override fun onFailure(p0: Call<AirplaneThreeCodeDetailResponse>, p1: Throwable) {
-                showErrorInfo(R.string.airplane_three_code_detail_get_failed)
-            }
-        })
-    }
-
     private fun initAirplaneResourceInfo() {
-
         binding.apply {
             threeCode.setText(airplaneThreeCode.three)
             fourCode.setText(airplaneThreeCode.four)
@@ -149,7 +100,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
                 airplaneNameEn.isEnabled(false)
                 otherInfo.isEnabled(false)
 
-                commit.setText(resources.getString(R.string.back))
+                commit.visibility = View.GONE
             }
         }
     }
@@ -172,6 +123,8 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
 
         binding.commit.setButtonStatus(1)
 
+        val apiService = ServiceCreator.create<APIService>()
+
         apiService.airplaneThreeCodeOperation(airplaneThreeCode)
             .enqueue(object : Callback<BaseResponse> {
                 override fun onResponse(

+ 1 - 1
app/src/main/java/com/pan_american/android/ui/resource_management/airplane_three_code/AirplaneThreeCodeListFragment.kt

@@ -173,7 +173,7 @@ class AirplaneThreeCodeListFragment : BaseFragment<FragmentAirplaneThreeCodeList
                 override fun onItemClick(position: Int) {
                     val intent =
                         Intent(OASystem.context, AddAirplaneThreeCodeActivity::class.java).apply {
-                            putExtra("id", airplaneList[position].id)
+                            putExtra("airplaneResource", airplaneList[position])
                             putExtra("fromList", true)
                         }
 

+ 0 - 1
app/src/main/res/values/strings.xml

@@ -444,7 +444,6 @@
 
     <!-- 机场三字码,错误信息-->
     <string name="airplane_three_code_list_get_failed">机场三字码列表获取失败</string>
-    <string name="airplane_three_code_detail_get_failed">机场三字码详情获取失败</string>
 
     <!-- 团组资料-->
     <string name="group_status">团组状态</string>