gwtools 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gwtools/generate/swift.rb +10 -14
- data/lib/gwtools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de144674a5f0d90f4e7748588a2dbcf7e23e72612c93b9e8d43a14747116ec5c
|
4
|
+
data.tar.gz: 7bb208e297924ae193e7ab0adb6e3a246f3bf5435e5d61157bfa84291a0a3114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecd6321bc3a60f7189a69efd3e936e7c67e11042f20c6d9ce71535901657caa5468b6585604c4f6726a431961af220385e5765fcbc760772e026cdc9cb37e502
|
7
|
+
data.tar.gz: 11fa148bf79fbd0a0978385f9e7799d5d8d4f04fdfcbbff8c7de1c40ee553f47418dfe48ed3f93c4e19762897f83d00398d47ea8fea3a6ddb161197d1e249942
|
@@ -16,7 +16,7 @@ module Gwtools
|
|
16
16
|
def config_file
|
17
17
|
# ERB.new(File.read('restful_url.swift.erb'), nil, '>').result(binding)
|
18
18
|
template = <<-ERB
|
19
|
-
///
|
19
|
+
/// 此文件由代码生成,不要修改任何内容
|
20
20
|
|
21
21
|
import RxSwift
|
22
22
|
import GWNetWork
|
@@ -33,7 +33,9 @@ public extension <%="#{@api_name}"%> {
|
|
33
33
|
}
|
34
34
|
|
35
35
|
public extension <%="#{@api_name}"%> {
|
36
|
-
static func <%="#{@httpmethod}"%>(
|
36
|
+
static func <%="#{@httpmethod}"%>(
|
37
|
+
headerParms: [String: String] = [:],
|
38
|
+
parms: [String: Any] = [:],
|
37
39
|
isCache: Bool = false,
|
38
40
|
isLoading: Bool = false,
|
39
41
|
module: String? = nil,
|
@@ -42,11 +44,6 @@ public extension <%="#{@api_name}"%> {
|
|
42
44
|
<% else %>
|
43
45
|
des: String? = nil) -> Observable<Self.<%="#{@model_name}"%>> {
|
44
46
|
<% end %>
|
45
|
-
// ================= 逻辑处理 =================
|
46
|
-
let headerParms: [String : String] = [:]
|
47
|
-
let parms: [String : Any] = [:]
|
48
|
-
// ================= 逻辑处理 =================
|
49
|
-
|
50
47
|
return GWNetworkManager.request(requestType: .<%="#{@httpmethod}"%>,
|
51
48
|
prefixPath: "<%="#{@prefixPath}"%>",
|
52
49
|
modulePath: "<%="#{@modulePath}"%>",
|
@@ -174,8 +171,9 @@ public extension <%="#{@api_name}"%> {
|
|
174
171
|
|
175
172
|
modulePath = getModulePath(path, prefixPath)
|
176
173
|
detailPath = getDetailPath(path, prefixPath, modulePath)
|
177
|
-
|
174
|
+
json_data_is_arr = responseJson[root_path].is_a?(Array)
|
178
175
|
readme = """
|
176
|
+
|
179
177
|
请求参数
|
180
178
|
URL = #{path.chomp}
|
181
179
|
HTTPMETHOD = #{httpMethod.chomp}
|
@@ -189,12 +187,12 @@ class <##SomeViewModel##> {
|
|
189
187
|
}
|
190
188
|
|
191
189
|
public struct Output {
|
192
|
-
let data: BehaviorRelay<#{
|
190
|
+
let data: BehaviorRelay<#{json_data_is_arr ? "[" : ""}#{app_name}.#{httpMethod.capitalize.chomp}Model#{json_data_is_arr ? "]" : ""}>
|
193
191
|
}
|
194
192
|
|
195
193
|
public func transform(input: Input) -> Output {
|
196
|
-
let outDatas = BehaviorRelay<#{
|
197
|
-
input.<##AnyObservable##>.flatMapLatest({ [weak self] () -> Observable<#{
|
194
|
+
let outDatas = BehaviorRelay<#{json_data_is_arr ? "[" : ""}#{app_name}.#{httpMethod.capitalize.chomp}Model#{json_data_is_arr ? "]" : ""}>(value: [])
|
195
|
+
input.<##AnyObservable##>.flatMapLatest({ [weak self] () -> Observable<#{json_data_is_arr ? "[" : ""}#{app_name}.#{httpMethod.capitalize.chomp}Model#{json_data_is_arr ? "]" : ""}> in
|
198
196
|
guard let self = self else { return Observable.just([]) }
|
199
197
|
return self.reqData()
|
200
198
|
}).subscribe(onNext: { (items) in
|
@@ -208,15 +206,13 @@ class <##SomeViewModel##> {
|
|
208
206
|
}
|
209
207
|
|
210
208
|
extension <##SomeViewModel##> {
|
211
|
-
func reqData() -> Observable<#{
|
209
|
+
func reqData() -> Observable<#{json_data_is_arr ? "[" : ""}#{app_name}.#{httpMethod.capitalize.chomp}Model#{json_data_is_arr ? "]" : ""}> {
|
212
210
|
#{app_name}.#{httpMethod.capitalize.chomp}()
|
213
211
|
.compactMap { $0 } // 解析出需要的类型
|
214
212
|
.observeOn(MainScheduler.instance)
|
215
213
|
.catchErrorJustReturn([])
|
216
214
|
}
|
217
215
|
}
|
218
|
-
|
219
|
-
public extension app_api.api.v1_0.complaintsComments.protocol.getProtocols {}
|
220
216
|
"""
|
221
217
|
|
222
218
|
ModelReqGenerateConfig.new(
|
data/lib/gwtools/version.rb
CHANGED