|
| 1 | +import 'dart:io'; |
| 2 | + |
| 3 | +import 'package:dio/dio.dart'; |
1 | 4 | import 'package:gsy_github_app_flutter/common/dao/DaoResult.dart'; |
2 | 5 | import 'package:gsy_github_app_flutter/common/net/Address.dart'; |
3 | 6 | import 'package:gsy_github_app_flutter/common/net/Api.dart'; |
@@ -105,4 +108,84 @@ class IssueDao { |
105 | 108 | return new DataResult(null, false); |
106 | 109 | } |
107 | 110 | } |
| 111 | + |
| 112 | + /** |
| 113 | + * 增加issue的回复 |
| 114 | + */ |
| 115 | + static addIssueCommentDao(userName, repository, number, comment) async { |
| 116 | + String url = Address.addIssueComment(userName, repository, number); |
| 117 | + var res = await HttpManager.netFetch(url, {"body": comment}, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'POST')); |
| 118 | + if (res != null && res.result) { |
| 119 | + return new DataResult(res.data, true); |
| 120 | + } else { |
| 121 | + return new DataResult(null, false); |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * 编辑issue |
| 127 | + */ |
| 128 | + static editIssueDao(userName, repository, number, issue) async { |
| 129 | + String url = Address.editIssue(userName, repository, number); |
| 130 | + var res = await HttpManager.netFetch(url, issue, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'PATCH')); |
| 131 | + if (res != null && res.result) { |
| 132 | + return new DataResult(res.data, true); |
| 133 | + } else { |
| 134 | + return new DataResult(null, false); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * 锁定issue |
| 140 | + */ |
| 141 | + static lockIssueDao(userName, repository, number, locked) async { |
| 142 | + String url = Address.lockIssue(userName, repository, number); |
| 143 | + var res = await HttpManager.netFetch( |
| 144 | + url, null, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: locked ? "DELETE" : 'PUT', contentType: ContentType.TEXT), |
| 145 | + noTip: true); |
| 146 | + if (res != null && res.result) { |
| 147 | + return new DataResult(res.data, true); |
| 148 | + } else { |
| 149 | + return new DataResult(null, false); |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * 创建issue |
| 155 | + */ |
| 156 | + static createIssueDao(userName, repository, issue) async { |
| 157 | + String url = Address.createIssue(userName, repository); |
| 158 | + var res = await HttpManager.netFetch(url, issue, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'POST')); |
| 159 | + if (res != null && res.result) { |
| 160 | + return new DataResult(res.data, true); |
| 161 | + } else { |
| 162 | + return new DataResult(null, false); |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * 编辑issue回复 |
| 168 | + */ |
| 169 | + static editCommentDao(userName, repository, number, commentId, comment) async { |
| 170 | + String url = Address.editComment(userName, repository, commentId); |
| 171 | + var res = await HttpManager.netFetch(url, comment, {"Accept": 'application/vnd.github.VERSION.full+json'}, new Options(method: 'PATCH')); |
| 172 | + if (res != null && res.result) { |
| 173 | + return new DataResult(res.data, true); |
| 174 | + } else { |
| 175 | + return new DataResult(null, false); |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * 删除issue回复 |
| 181 | + */ |
| 182 | + static deleteCommentDao(userName, repository, number, commentId) async { |
| 183 | + String url = Address.editComment(userName, repository, commentId); |
| 184 | + var res = await HttpManager.netFetch(url, null, null, new Options(method: 'DELETE')); |
| 185 | + if (res != null && res.result) { |
| 186 | + return new DataResult(res.data, true); |
| 187 | + } else { |
| 188 | + return new DataResult(null, false); |
| 189 | + } |
| 190 | + } |
108 | 191 | } |
0 commit comments