优化后台管理api

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
MMXX 3 years ago
parent 7e15211fd2
commit 03a6202ee2
  1. 33
      fir_admin/src/api/app.js
  2. 22
      fir_admin/src/api/developer.js
  3. 9
      fir_admin/src/api/devices.js
  4. 20
      fir_admin/src/api/domain.js
  5. 20
      fir_admin/src/api/order.js
  6. 20
      fir_admin/src/api/report.js
  7. 13
      fir_admin/src/api/storage.js
  8. 20
      fir_admin/src/api/wxbind.js
  9. 15
      fir_admin/src/views/appinfos/AppDetail.vue
  10. 18
      fir_admin/src/views/appinfos/AppReleaseDetail.vue
  11. 20
      fir_admin/src/views/appinfos/AppReleaseList.vue
  12. 20
      fir_admin/src/views/appinfos/list.vue
  13. 15
      fir_admin/src/views/domain/Detail.vue
  14. 21
      fir_admin/src/views/domain/list.vue
  15. 15
      fir_admin/src/views/order/Detail.vue
  16. 18
      fir_admin/src/views/order/list.vue
  17. 15
      fir_admin/src/views/report/Detail.vue
  18. 14
      fir_admin/src/views/report/list.vue
  19. 15
      fir_admin/src/views/storage/Detail.vue
  20. 15
      fir_admin/src/views/storage/list.vue
  21. 17
      fir_admin/src/views/supersign/bill/list.vue
  22. 15
      fir_admin/src/views/supersign/developer/Detail.vue
  23. 26
      fir_admin/src/views/supersign/developer/list.vue
  24. 13
      fir_admin/src/views/supersign/devices/list.vue
  25. 8
      fir_admin/src/views/userinfos/UserDetail.vue
  26. 15
      fir_admin/src/views/wxbind/Detail.vue
  27. 14
      fir_admin/src/views/wxbind/list.vue
  28. 3
      fir_client/src/components/user/FirUserStorage.vue
  29. 29
      fir_ser/admin/urls.py
  30. 13
      fir_ser/admin/utils.py
  31. 5
      fir_ser/admin/utils/__init__.py
  32. 23
      fir_ser/admin/utils/exception.py
  33. 296
      fir_ser/admin/utils/serializer.py
  34. 52
      fir_ser/admin/utils/utils.py
  35. 157
      fir_ser/admin/views/app.py
  36. 97
      fir_ser/admin/views/domain.py
  37. 43
      fir_ser/admin/views/login.py
  38. 110
      fir_ser/admin/views/order.py
  39. 68
      fir_ser/admin/views/report.py
  40. 82
      fir_ser/admin/views/storage.py
  41. 216
      fir_ser/admin/views/supersign.py
  42. 121
      fir_ser/admin/views/user.py
  43. 2
      fir_ser/api/utils/modelutils.py
  44. 233
      fir_ser/api/utils/serializer.py
  45. 2
      fir_ser/api/views/storage.py
  46. 15
      fir_ser/common/cache/invalid.py
  47. 15
      fir_ser/fir_ser/settings.py
  48. 3
      fir_ser/requirements.txt

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getAppInfos(query) {
export function getAppList(query) {
return request({
url: '/app/info',
method: 'get',
@ -8,23 +8,29 @@ export function getAppInfos(query) {
})
}
export function updateAppInfo(data) {
export function getAppInfos(pk) {
return request({
url: '/app/info',
url: '/app/info/' + pk,
method: 'get'
})
}
export function updateAppInfo(pk, data) {
return request({
url: '/app/info/' + pk,
method: 'put',
data
})
}
export function deleteApp(data) {
export function deleteApp(pk) {
return request({
url: '/app/info',
method: 'delete',
data
url: '/app/info/' + pk,
method: 'delete'
})
}
export function getAppReleaseInfos(query) {
export function getAppReleaseList(query) {
return request({
url: '/app/release/info',
method: 'get',
@ -32,9 +38,16 @@ export function getAppReleaseInfos(query) {
})
}
export function updateReleaseAppInfo(data) {
export function getAppReleaseInfos(pk) {
return request({
url: '/app/release/info',
url: '/app/release/info/' + pk,
method: 'get'
})
}
export function updateReleaseAppInfo(pk, data) {
return request({
url: '/app/release/info/' + pk,
method: 'put',
data
})

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getDeveloperInfo(query) {
export function getDeveloperList(query) {
return request({
url: '/developer/info',
method: 'get',
@ -8,15 +8,22 @@ export function getDeveloperInfo(query) {
})
}
export function updatedeveloperInfo(data) {
export function getDeveloperInfo(pk) {
return request({
url: '/developer/info',
url: '/developer/info/' + pk,
method: 'get'
})
}
export function updatedeveloperInfo(pk, data) {
return request({
url: '/developer/info/' + pk,
method: 'put',
data
})
}
export function getBillInfo(query) {
export function getBillList(query) {
return request({
url: '/bill/info',
method: 'get',
@ -31,11 +38,10 @@ export function addBillInfo(data) {
data
})
}
export function delBillInfo(data) {
export function delBillInfo(pk) {
return request({
url: '/bill/info',
method: 'delete',
data
url: '/bill/info/' + pk,
method: 'delete'
})
}

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getDevicesInfo(query) {
export function getDevicesList(query) {
return request({
url: '/devices/info',
method: 'get',
@ -8,10 +8,3 @@ export function getDevicesInfo(query) {
})
}
export function updatedevicesInfo(data) {
return request({
url: '/devices/info',
method: 'put',
data
})
}

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getDomainInfos(query) {
export function getDomainList(query) {
return request({
url: '/domain/info',
method: 'get',
@ -8,18 +8,24 @@ export function getDomainInfos(query) {
})
}
export function updateDomainInfo(data) {
export function getDomainInfos(pk) {
return request({
url: '/domain/info',
url: '/domain/info/' + pk,
method: 'get'
})
}
export function updateDomainInfo(pk, data) {
return request({
url: '/domain/info/' + pk,
method: 'put',
data
})
}
export function deleteDomain(data) {
export function deleteDomain(pk) {
return request({
url: '/domain/info',
method: 'delete',
data
url: '/domain/info/' + pk,
method: 'delete'
})
}

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getOrderInfo(query) {
export function getOrderList(query) {
return request({
url: '/order/info',
method: 'get',
@ -8,18 +8,24 @@ export function getOrderInfo(query) {
})
}
export function updateOrderInfo(data) {
export function getOrderInfo(pk) {
return request({
url: '/order/info',
url: '/order/info/' + pk,
method: 'get'
})
}
export function updateOrderInfo(pk, data) {
return request({
url: '/order/info/' + pk,
method: 'put',
data
})
}
export function deleteOrderInfo(data) {
export function deleteOrderInfo(pk) {
return request({
url: '/order/info',
method: 'delete',
data
url: '/order/info/' + pk,
method: 'delete'
})
}
export function createOrderInfo(data) {

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getAppReportIfo(query) {
export function getAppReportList(query) {
return request({
url: '/report/info',
method: 'get',
@ -8,18 +8,24 @@ export function getAppReportIfo(query) {
})
}
export function updateAppReportIfo(data) {
export function getAppReportIfo(pk) {
return request({
url: '/report/info',
url: '/report/info/' + pk,
method: 'get'
})
}
export function updateAppReportIfo(pk, data) {
return request({
url: '/report/info/' + pk,
method: 'put',
data
})
}
export function deleteAppReportIfo(data) {
export function deleteAppReportIfo(pk) {
return request({
url: '/report/info',
method: 'delete',
data
url: '/report/info/' + pk,
method: 'delete'
})
}

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getStorageInfo(query) {
export function getStorageList(query) {
return request({
url: '/storage/info',
method: 'get',
@ -8,9 +8,16 @@ export function getStorageInfo(query) {
})
}
export function updateStorageInfo(data) {
export function getStorageInfo(pk) {
return request({
url: '/storage/info',
url: '/storage/info/' + pk,
method: 'get'
})
}
export function updateStorageInfo(pk, data) {
return request({
url: '/storage/info/' + pk,
method: 'put',
data
})

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function getWxBindInfos(query) {
export function getWxBindList(query) {
return request({
url: '/wxbind/info',
method: 'get',
@ -8,18 +8,24 @@ export function getWxBindInfos(query) {
})
}
export function updateWxBindInfo(data) {
export function getWxBindInfos(pk) {
return request({
url: '/wxbind/info',
url: '/wxbind/info/' + pk,
method: 'get'
})
}
export function updateWxBindInfo(pk,data) {
return request({
url: '/wxbind/info/' + pk,
method: 'put',
data
})
}
export function deleteWxBind(data) {
export function deleteWxBind(pk) {
return request({
url: '/wxbind/info',
method: 'delete',
data
url: '/wxbind/info/' + pk,
method: 'delete'
})
}

@ -264,29 +264,30 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {
},
created() {
if (this.isEdit) {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
}
},
methods: {
fetchData(id) {
getAppInfos({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getAppInfos(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateAppInfo(this.postForm).then(response => {
updateAppInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -161,28 +161,28 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {
},
created() {
const id = this.$route.params && this.$route.params.id
const app_id = this.$route.params && this.$route.params.app_id
this.fetchData(id, app_id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id, app_id) {
getAppReleaseInfos({ id: id, app_id: app_id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
fetchData(id) {
getAppReleaseInfos(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateReleaseAppInfo(this.postForm).then(response => {
updateReleaseAppInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -2,7 +2,7 @@
<div class="app-container">
<div class="filter-container">
<el-input v-model="listQuery.release_id" placeholder="release_id" style="width: 250px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -86,7 +86,7 @@
</template>
<script>
import { getAppReleaseInfos, downloadAppReleaseInfos } from '@/api/app'
import { downloadAppReleaseInfos, getAppReleaseList } from '@/api/app'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -135,11 +135,9 @@ export default {
app_id: undefined,
download_token: undefined,
release_id: undefined,
sort: '-created_time'
ordering: '-created_time'
},
sortOptions,
type_choices: [],
status_choices: []
sortOptions
}
},
created() {
@ -168,13 +166,9 @@ export default {
},
fetchData() {
this.listLoading = true
getAppReleaseInfos(this.listQuery).then(response => {
this.list = response.data
if (this.list && this.list.length > 0) {
this.type_choices = this.list[0].type_choices
this.status_choices = this.list[0].status_choices
}
this.total = response.total
getAppReleaseList(this.listQuery).then(response => {
this.list = response.data.results
this.total = response.data.count
this.listLoading = false
})
}

@ -4,7 +4,7 @@
<el-input v-model="listQuery.bundle_id" placeholder="Bundle_Id" style="width: 250px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.name" placeholder="应用名称" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.short" placeholder="短连接" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.domain_name" placeholder="应用专属访问域名" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<!-- <el-input v-model="listQuery.domain_name" placeholder="应用专属访问域名" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />-->
<el-select v-if="type_choices" v-model="listQuery.type" placeholder="应用类型" clearable class="filter-item" style="width: 120px" @change="handleFilter">
<el-option v-for="item in type_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
@ -12,7 +12,7 @@
<el-option v-for="item in status_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-input v-model="listQuery.user_id" placeholder="用户ID" style="width: 140px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -126,13 +126,13 @@
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
<pagination v-show="count>0" :total="count" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
</div>
</template>
<script>
import { getAppInfos, deleteApp } from '@/api/app'
import { deleteApp, getAppList } from '@/api/app'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -180,13 +180,13 @@ export default {
return {
list: null,
listLoading: true,
total: 0,
count: 0,
listQuery: {
page: 1,
limit: 10,
name: undefined,
bundle_id: undefined,
sort: '-count_hits',
ordering: '-count_hits',
type: undefined,
domain_name: undefined,
user_id: undefined
@ -209,7 +209,7 @@ export default {
type: 'warning'
}).then(() => {
this.listLoading = true
deleteApp({ id: app_id }).then(response => {
deleteApp(app_id).then(response => {
this.$message.success('删除成功')
this.fetchData()
this.listLoading = false
@ -227,13 +227,13 @@ export default {
},
fetchData() {
this.listLoading = true
getAppInfos(this.listQuery).then(response => {
this.list = response.data
getAppList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.type_choices = this.list[0].type_choices
this.status_choices = this.list[0].status_choices
}
this.total = response.total
this.count = response.data.count
this.listLoading = false
})
}

@ -107,26 +107,27 @@ export default {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false,
domain_state_choices
domain_state_choices,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getDomainInfos({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getDomainInfos(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateDomainInfo(this.postForm).then(response => {
updateDomainInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -10,7 +10,7 @@
<el-select v-model="listQuery.is_enable" placeholder="域名绑定状态" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in domain_state_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -85,7 +85,7 @@
</template>
<script>
import { getDomainInfos, deleteDomain } from '@/api/domain'
import { deleteDomain, getDomainList } from '@/api/domain'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -143,7 +143,7 @@ export default {
page: 1,
limit: 10,
user_id: undefined,
sort: '-created_time',
ordering: '-created_time',
domain_name: undefined,
app_name: undefined,
domain_type: undefined,
@ -164,13 +164,8 @@ export default {
},
methods: {
remove_domain(domain_id) {
deleteDomain({ id: domain_id }).then(response => {
this.list = response.data
if (this.list && this.list.length > 0) {
this.domain_type_choices = this.list[0].domain_type_choices
}
this.total = response.total
this.listLoading = false
deleteDomain(domain_id).then(response => {
this.fetchData()
})
},
handleFilter() {
@ -179,12 +174,12 @@ export default {
},
fetchData() {
this.listLoading = true
getDomainInfos(this.listQuery).then(response => {
this.list = response.data
getDomainList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.domain_type_choices = this.list[0].domain_type_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -142,26 +142,27 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getOrderInfo({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getOrderInfo(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateOrderInfo(this.postForm).then(response => {
updateOrderInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -14,7 +14,7 @@
<el-select v-model="listQuery.order_type" placeholder="订单类型" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in order_type_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -117,7 +117,7 @@
</template>
<script>
import { getOrderInfo, deleteOrderInfo } from '@/api/order'
import { deleteOrderInfo, getOrderList } from '@/api/order'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -126,7 +126,9 @@ const sortOptions = [
{ label: '创建时间 Ascending', key: 'created_time' },
{ label: '创建时间 Descending', key: '-created_time' },
{ label: '付款时间 Ascending', key: 'pay_time' },
{ label: '付款时间 Descending', key: '-pay_time' }
{ label: '付款时间 Descending', key: '-pay_time' },
{ label: '付款金额 Ascending', key: 'actual_amount' },
{ label: '付款金额 Descending', key: '-actual_amount' }
]
export default {
@ -190,7 +192,7 @@ export default {
page: 1,
limit: 10,
user_id: undefined,
sort: '-created_time',
ordering: '-created_time',
payment_type: undefined,
payment_name: undefined,
payment_number: undefined,
@ -213,7 +215,7 @@ export default {
},
methods: {
remove_order_info(order_info) {
deleteOrderInfo({ id: order_info.id }).then(response => {
deleteOrderInfo(order_info.id).then(response => {
this.list = response.data
if (response.code === 1000) {
this.fetchData()
@ -228,14 +230,14 @@ export default {
},
fetchData() {
this.listLoading = true
getOrderInfo(this.listQuery).then(response => {
this.list = response.data
getOrderList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.payment_type_choices = this.list[0].payment_type_choices
this.status_choices = this.list[0].status_choices
this.order_type_choices = this.list[0].order_type_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -119,26 +119,27 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getAppReportIfo({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getAppReportIfo(this.id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateAppReportIfo(this.postForm).then(response => {
updateAppReportIfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -13,7 +13,7 @@
<el-option v-for="item in status_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -103,7 +103,7 @@
</template>
<script>
import { getAppReportIfo, deleteAppReportIfo } from '@/api/report'
import { deleteAppReportIfo, getAppReportList } from '@/api/report'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -174,7 +174,7 @@ export default {
page: 1,
limit: 10,
app_id: undefined,
sort: '-created_time',
ordering: '-created_time',
report_type: undefined,
app_name: undefined,
bundle_id: undefined,
@ -197,7 +197,7 @@ export default {
},
methods: {
remove_order_info(order_info) {
deleteAppReportIfo({ id: order_info.id }).then(response => {
deleteAppReportIfo(order_info.id).then(response => {
this.list = response.data
if (response.code === 1000) {
this.fetchData()
@ -212,13 +212,13 @@ export default {
},
fetchData() {
this.listLoading = true
getAppReportIfo(this.listQuery).then(response => {
this.list = response.data
getAppReportList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.report_type_choices = this.list[0].report_type_choices
this.status_choices = this.list[0].status_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -147,26 +147,27 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getStorageInfo({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getStorageInfo(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateStorageInfo(this.postForm).then(response => {
updateStorageInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -9,7 +9,7 @@
<el-select v-model="listQuery.storage_type" placeholder="存储类型" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in storage_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -93,7 +93,7 @@
</template>
<script>
import { getStorageInfo } from '@/api/storage'
import { getStorageList } from '@/api/storage'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -160,12 +160,12 @@ export default {
page: 1,
limit: 10,
name: undefined,
sort: '-created_time',
bucket_name: undefined,
access_key: undefined,
storage_type: undefined,
domain_name: undefined,
used_id: undefined
user_id: undefined,
ordering: '-created_time'
},
sortOptions,
storage_choices: []
@ -186,12 +186,13 @@ export default {
},
fetchData() {
this.listLoading = true
getStorageInfo(this.listQuery).then(response => {
this.list = response.data
getStorageList(this.listQuery).then(response => {
this.list = response.data.results
console.log(this.list)
if (this.list && this.list.length > 0) {
this.storage_choices = this.list[0].storage_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -8,7 +8,7 @@
<el-select v-model="listQuery.action" placeholder="充值类型" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in action_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -96,7 +96,7 @@
<script>
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves'
import { getBillInfo, delBillInfo } from '@/api/developer'
import { delBillInfo, getBillList } from '@/api/developer'
const sortOptions = [
{ label: '创建时间 Ascending', key: 'created_time' },
@ -158,7 +158,7 @@ export default {
listQuery: {
page: 1,
limit: 10,
sort: '-created_time',
ordering: '-created_time',
action: undefined,
app_id: undefined,
to_user_id: undefined,
@ -179,22 +179,21 @@ export default {
this.listQuery.page = 1
this.fetchData()
},
delbill(app_id) {
delBillInfo({ id: app_id }).then(response => {
delbill(id) {
delBillInfo(id).then(response => {
this.$message.success('删除成功')
this.fetchData()
this.listLoading = false
})
},
fetchData() {
console.log(this.listQuery)
this.listLoading = true
getBillInfo(this.listQuery).then(response => {
this.list = response.data
getBillList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.action_choices = this.list[0].action_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -154,26 +154,27 @@ export default {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
is_edit: false,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getDeveloperInfo({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getDeveloperInfo(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updatedeveloperInfo(this.postForm).then(response => {
updatedeveloperInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -9,7 +9,7 @@
<el-select v-model="listQuery.auth_type" placeholder="账户类型" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in auth_type_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -73,7 +73,7 @@
<el-table-column class-name="status-col" label="是否激活" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.is_actived | statusFilter">{{ scope.row.is_actived }}</el-tag>
<el-tag :type="scope.row.is_actived | statusFilter">{{ scope.row |StatusNameFilter }}</el-tag>
</template>
</el-table-column>
@ -100,9 +100,9 @@
查看编辑
</el-button>
</router-link>
<el-button type="danger" size="mini" @click="deleteApp(scope.row.id)">
删除
</el-button>
<!-- <el-button type="danger" size="mini" @click="deleteApp(scope.row.id)">-->
<!-- 删除-->
<!-- </el-button>-->
</template>
</el-table-column>
</el-table>
@ -112,7 +112,7 @@
</template>
<script>
import { getDeveloperInfo } from '@/api/developer'
import { getDeveloperList } from '@/api/developer'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -156,7 +156,7 @@ export default {
}
return statusMap[status]
},
appStatusNameFilter(row) {
StatusNameFilter(row) {
for (const r of row.status_choices) {
if (r.id === row.status) {
return r.name
@ -180,7 +180,7 @@ export default {
listQuery: {
page: 1,
limit: 10,
sort: '-created_time',
ordering: '-created_time',
issuer_id: undefined,
private_key_id: undefined,
certid: undefined,
@ -189,7 +189,8 @@ export default {
auth_type: undefined
},
sortOptions,
auth_type_choices: []
auth_type_choices: [],
status_choices: []
}
},
created() {
@ -202,12 +203,13 @@ export default {
},
fetchData() {
this.listLoading = true
getDeveloperInfo(this.listQuery).then(response => {
this.list = response.data
getDeveloperList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.auth_type_choices = this.list[0].auth_type_choices
this.status_choices = this.list[0].status_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -8,7 +8,7 @@
<el-input v-model="listQuery.bundle_id" placeholder="BundleID" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.short" placeholder="短连接" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -94,7 +94,7 @@
</template>
<script>
import { getDevicesInfo } from '@/api/devices'
import { getDevicesList } from '@/api/devices'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -158,7 +158,7 @@ export default {
listQuery: {
page: 1,
limit: 10,
sort: '-created_time',
ordering: '-created_time',
issuer_id: undefined,
short: undefined,
bundle_id: undefined,
@ -180,14 +180,13 @@ export default {
this.fetchData()
},
fetchData() {
console.log(this.listQuery)
this.listLoading = true
getDevicesInfo(this.listQuery).then(response => {
this.list = response.data
getDevicesList(this.listQuery).then(response => {
this.list = response.data.results
if (this.list && this.list.length > 0) {
this.auth_type_choices = this.list[0].auth_type_choices
}
this.total = response.total
this.total = response.data.count
this.listLoading = false
})
}

@ -247,7 +247,7 @@
import { validURL } from '@/utils/validate'
import { getUserInfos, updateUserInfo } from '@/api/user'
import { createOrderInfo } from '@/api/order'
import { getStorageInfo, changeStorageInfo } from '@/api/storage'
import { changeStorageInfo, getStorageList } from '@/api/storage'
const defaultForm = {
email: undefined,
@ -378,9 +378,9 @@ export default {
})
},
fetchStorageData(user_id) {
getStorageInfo({ user_id: user_id }).then(response => {
if (response.storage_selection) {
this.storage_selection = response.storage_selection
getStorageList({ user_id: user_id }).then(response => {
if (response.data.storage_selection) {
this.storage_selection = response.data.storage_selection
}
}).catch(err => {
console.log(err)

@ -117,26 +117,27 @@ export default {
loading: false,
is_edit: false,
wxbind_state_choices,
wxbind_sex_choices
wxbind_sex_choices,
id: ''
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.id = this.$route.params && this.$route.params.id
this.fetchData(this.id)
},
methods: {
fetchData(id) {
getWxBindInfos({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
getWxBindInfos(id).then(response => {
if (response.data) {
this.postForm = response.data
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateWxBindInfo(this.postForm).then(response => {
updateWxBindInfo(this.id, this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {

@ -7,7 +7,7 @@
<el-select v-model="listQuery.subscribe" placeholder="玩家是否订阅" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in wxbind_state_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-select v-model="listQuery.ordering" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
@ -92,7 +92,7 @@
</template>
<script>
import { getWxBindInfos, deleteWxBind } from '@/api/wxbind'
import { getWxBindInfos, deleteWxBind, getWxBindList } from '@/api/wxbind'
import { baseFilter } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
@ -159,7 +159,7 @@ export default {
page: 1,
limit: 10,
user_id: undefined,
sort: '-created_time',
ordering: '-created_time',
openid: undefined,
nickname: undefined,
subscribe: undefined
@ -178,7 +178,7 @@ export default {
},
methods: {
remove_wxbind(wxbind_id) {
deleteWxBind({ id: wxbind_id }).then(response => {
deleteWxBind(wxbind_id).then(response => {
this.list = response.data
this.total = response.total
this.listLoading = false
@ -190,9 +190,9 @@ export default {
},
fetchData() {
this.listLoading = true
getWxBindInfos(this.listQuery).then(response => {
this.list = response.data
this.total = response.total
getWxBindList(this.listQuery).then(response => {
this.list = response.data.results
this.total = response.data.count
this.listLoading = false
})
}

@ -1,6 +1,5 @@
<template>
<el-main>
<h2 v-if="is_admin_storage">管理员存储您配置的存储将决定其他用户配置的默认存储请谨慎修改</h2>
<el-dialog :close-on-click-modal="false" :destroy-on-close="true" :title="title"
:visible.sync="dialogstorageVisible">
@ -341,7 +340,6 @@ export default {
isaddflag: false,
activeName: 'change',
storage_info_lists: [],
is_admin_storage: false,
loading: false,
}
}, methods: {
@ -525,7 +523,6 @@ export default {
this.org_storage_id = this.use_storage_id = data.storage;
this.storage_list = data.storage_list;
this.storage_info_lists = data.data;
this.is_admin_storage = data.is_admin_storage;
this.format_storage(data.data);
this.disabled = true;
this.isaddflag = false;

@ -13,7 +13,8 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.urls import re_path
from django.urls import re_path, include
from rest_framework.routers import SimpleRouter
from admin.views.app import AppInfoView, AppReleaseInfoView
from admin.views.domain import DomainNameInfoView
@ -24,25 +25,23 @@ from admin.views.storage import StorageInfoView, StorageChangeView
from admin.views.supersign import DeveloperInfoView, DevicesInfoView, SuperSignBillView, SuperSignBillUserInfoView
from admin.views.user import UserInfoView, UserCertificationInfoView, ThirdWxAccountView
router = SimpleRouter(False)
router.register('app/info', AppInfoView)
router.register('app/release/info', AppReleaseInfoView)
router.register('domain/info', DomainNameInfoView)
router.register('order/info', OrderInfoView)
router.register('report/info', AdminReportView)
router.register('storage/info', StorageInfoView)
router.register('developer/info', DeveloperInfoView)
router.register('devices/info', DevicesInfoView)
router.register('bill/info', SuperSignBillView)
router.register('wxbind/info', ThirdWxAccountView)
urlpatterns = [
# path("",include(router.urls)),
# re_path("^users$", CertificationView.as_view()),
# re_path("^apps$", CertificationView.as_view()),
re_path("^login", LoginView.as_view()),
re_path("^user/info", LoginUserView.as_view()),
re_path("^userinfo", UserInfoView.as_view()),
re_path("^app/info", AppInfoView.as_view()),
re_path("^app/release/info", AppReleaseInfoView.as_view()),
re_path("^certification/info", UserCertificationInfoView.as_view()),
re_path("^storage/info", StorageInfoView.as_view()),
re_path("^storage/change", StorageChangeView.as_view()),
re_path("^order/info", OrderInfoView.as_view()),
re_path("^developer/info", DeveloperInfoView.as_view()),
re_path("^devices/info", DevicesInfoView.as_view()),
re_path("^bill/info", SuperSignBillView.as_view()),
re_path("^bill/userinfo", SuperSignBillUserInfoView.as_view()),
re_path("^domain/info", DomainNameInfoView.as_view()),
re_path("^wxbind/info", ThirdWxAccountView.as_view()),
re_path("^report/info", AdminReportView.as_view()),
re_path('', include(router.urls))
]

@ -1,13 +0,0 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 1月
# author: NinEveN
# date: 2022/1/6
from rest_framework.pagination import PageNumberPagination
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制

@ -0,0 +1,5 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 1月
# author: NinEveN
# date: 2022/1/13

@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 1月
# author: NinEveN
# date: 2022/1/13
import logging
from rest_framework.views import exception_handler
from admin.utils.utils import ApiResponse
logger = logging.getLogger(__file__)
def common_exception_handler(exc, context):
logger.error(f'{context["view"].__class__.__name__} ERROR: {exc}')
# context['view'] 是TextView的对象,想拿出这个对象对应的类名
ret = exception_handler(exc, context) # 是Response对象,它内部有个data
if not ret: # drf内置处理不了,丢给django 的,我们自己来处理
return ApiResponse(msg='error', result=str(exc))
else:
return ApiResponse(msg='error', data=ret.data)

@ -0,0 +1,296 @@
import logging
import os
from rest_framework import serializers
from api import models
from api.utils.serializer import AppReleaseSerializer, UserInfoSerializer, AppsSerializer, StorageSerializer, \
DeveloperSerializer, SuperSignUsedSerializer, ThirdWxSerializer, DomainNameSerializer, BillInfoSerializer, \
AppReportSerializer
from api.utils.storage.storage import Storage
from common.base.baseutils import get_choices_dict, get_choices_name_from_key
logger = logging.getLogger(__name__)
def get_download_url_from_context(self, obj, key, url, force_new=False):
download_url = ""
if self.context.get("key", None) and self.context.get("key") != "undefined":
key = self.context.get("key", '')
if self.context.get("storage", None) and self.context.get("storage") != "undefined":
storage = self.context.get("storage", None)
else:
if isinstance(obj, models.Apps):
storage = Storage(obj.user_id)
elif isinstance(obj, models.AppReleaseInfo):
storage = Storage(obj.app_id.user_id)
elif isinstance(obj, models.UserAdDisplayInfo):
storage = Storage(obj.user_id)
elif isinstance(obj, models.UserInfo):
storage = Storage(obj)
elif isinstance(obj, models.UserCertificationInfo) or isinstance(obj, models.CertificationInfo):
storage = Storage(obj.user_id, None, True)
else:
storage = None
if storage:
download_url = storage.get_download_url(os.path.basename(url), 600, key, force_new)
logger.info(f'get {os.path.basename(url)} download_url {download_url} force_new:{force_new} key:{key}')
return download_url
def get_app_master_obj_from_context(self, obj):
master_release_obj = models.AppReleaseInfo.objects.filter(app_id=obj, is_master=True).first()
if self.context.get("release_id", None) and self.context.get("release_id") != "undefined":
master_release_obj = models.AppReleaseInfo.objects.filter(app_id=obj,
release_id=self.context.get("release_id")).first()
return master_release_obj
def get_screenshots_from_self(self, obj, force_new=False):
screenshots_list = []
for screenshot_obj in models.AppScreenShot.objects.filter(app_id=obj).all():
icon_url = get_download_url_from_context(self, obj, '', screenshot_obj.screenshot_url, force_new)
screenshots_list.append({'id': screenshot_obj.pk, 'url': icon_url})
return screenshots_list
class AdminUserInfoSerializer(UserInfoSerializer):
class Meta:
model = models.UserInfo
exclude = ["password", "api_token"]
read_only_fields = ["id", "head_img", "free_download_times", "last_login",
"is_superuser", "last_name", "is_staff", "uid",
"date_joined", "download_times", "all_download_times", "storage", "groups",
"user_permissions", "certification_id", " app_count"]
gender_choices = serializers.SerializerMethodField()
def get_gender_choices(self, obj):
return get_choices_dict(obj.gender_choices)
role_choices = serializers.SerializerMethodField()
def get_role_choices(self, obj):
return get_choices_dict(obj.role_choices)
storage_choices = serializers.SerializerMethodField()
def get_storage_choices(self, obj):
return get_choices_dict(models.AppStorage.storage_choices[1:])
certification_status_choices = serializers.SerializerMethodField()
def get_certification_status_choices(self, obj):
return get_choices_dict(models.UserCertificationInfo.status_choices)
certification_id = serializers.SerializerMethodField()
def get_certification_id(self, obj):
return models.UserCertificationInfo.objects.filter(user_id=obj).values('id').first()
app_count = serializers.SerializerMethodField()
def get_app_count(self, obj):
return models.Apps.objects.filter(user_id=obj).count()
def update(self, instance, validated_data):
return super(AdminUserInfoSerializer, self).update(instance, validated_data)
class AdminAppsSerializer(AppsSerializer):
class Meta:
model = models.Apps
fields = "__all__"
read_only_fields = ["id", "app_id", "user_id", "bundle_id", "count_hits", "updated_time", "created_time"]
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
type_choices = serializers.SerializerMethodField()
def get_type_choices(self, obj):
return get_choices_dict(obj.type_choices)
supersign_type_choices = serializers.SerializerMethodField()
def get_supersign_type_choices(self, obj):
return get_choices_dict(obj.supersign_type_choices)
release_count = serializers.SerializerMethodField()
def get_release_count(self, obj):
return models.AppReleaseInfo.objects.filter(app_id=obj).count()
def update(self, instance, validated_data):
return super(AdminAppsSerializer, self).update(instance, validated_data)
class AdminAppReleaseSerializer(AppReleaseSerializer):
class Meta:
model = models.AppReleaseInfo
fields = '__all__'
read_only_fields = ["id", "app_id", "release_id", "binary_size", "udid", "icon_url"]
release_choices = serializers.SerializerMethodField()
app_aid = serializers.CharField(source='app_id.app_id', read_only=True)
def get_release_choices(self, obj):
return get_choices_dict(obj.release_choices)
def update(self, instance, validated_data):
print(validated_data)
if validated_data.get("is_master", False):
models.AppReleaseInfo.objects.filter(app_id=instance.app_id).update(**{"is_master": False})
else:
if "is_master" in validated_data and validated_data.get("is_master") != True:
del validated_data["is_master"]
return super(AdminAppReleaseSerializer, self).update(instance, validated_data)
class AdminStorageSerializer(StorageSerializer):
class Meta:
model = models.AppStorage
fields = "__all__"
read_only_fields = ["id", "user_id", "updated_time", "created_time", "storage_type"]
storage_choices = serializers.SerializerMethodField()
def get_storage_choices(self, obj):
return get_choices_dict(obj.storage_choices[1:])
used_id = serializers.IntegerField(source="user_id.pk")
class AdminDeveloperSerializer(DeveloperSerializer):
class Meta:
model = models.AppIOSDeveloperInfo
# depth = 1
exclude = ["p8key", ]
auth_type_choices = serializers.SerializerMethodField()
def get_auth_type_choices(self, obj):
return get_choices_dict(obj.auth_type_choices)
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
class AdminSuperSignUsedSerializer(SuperSignUsedSerializer):
class Meta:
model = models.APPSuperSignUsedInfo
fields = ["created_time", "device_udid", "device_name", "developer_id", "bundle_id", "bundle_name", "app_id",
"id", "user_id", "short", "developer_pk"]
app_id = serializers.IntegerField(source="app_id.pk")
user_id = serializers.IntegerField(source="user_id.pk")
short = serializers.CharField(source="app_id.short")
developer_status = serializers.CharField(source="developerid.get_status_display")
developer_id = serializers.CharField(source="developerid.issuer_id")
developer_description = serializers.CharField(source="developerid.description")
developer_pk = serializers.IntegerField(source="developerid.pk")
class AdminOrdersSerializer(serializers.ModelSerializer):
class Meta:
model = models.Order
fields = "__all__"
read_only_fields = ["id", "user_id", "updated_time", "created_time", "payment_number", "order_number",
"payment_name", "actual_amount", "actual_download_times", "actual_download_gift_times"]
payment_type_choices = serializers.SerializerMethodField()
def get_payment_type_choices(self, obj):
return get_choices_dict(obj.payment_type_choices)
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
order_type_choices = serializers.SerializerMethodField()
def get_order_type_choices(self, obj):
return get_choices_dict(obj.order_type_choices)
class AdminUserCertificationSerializer(serializers.ModelSerializer):
class Meta:
model = models.UserCertificationInfo
fields = "__all__"
read_only_fields = ["id", "user_id", "reviewed_time", "created_time"]
certification_status_choices = serializers.SerializerMethodField()
def get_certification_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
certification_infos = serializers.SerializerMethodField()
def get_certification_infos(self, obj):
result = []
for c_info in models.CertificationInfo.objects.filter(user_id=obj.user_id).all():
result.append({
'name': get_choices_name_from_key(models.CertificationInfo.type_choices, c_info.type),
'certification_url': get_download_url_from_context(self, obj, '', c_info.certification_url)
})
return result
def update(self, instance, validated_data):
return super(AdminUserCertificationSerializer, self).update(instance, validated_data)
class AdminThirdWxSerializer(ThirdWxSerializer):
class Meta:
model = models.ThirdWeChatUserInfo
fields = "__all__"
read_only_fields = ["id", "openid", "user_id", "head_img_url"]
class AdminDomainNameSerializer(DomainNameSerializer):
class Meta:
model = models.UserDomainInfo
fields = "__all__"
read_only_fields = ["id", "app_id", "domain_type", "created_time", "cname_id"]
domain_type_choices = serializers.SerializerMethodField()
def get_domain_type_choices(self, obj):
return get_choices_dict(obj.domain_type_choices)
class AdminBillInfoSerializer(BillInfoSerializer):
class Meta:
model = models.IosDeveloperPublicPoolBill
fields = '__all__'
read_only_fields = ["id", "user_id", "to_user_id", "action", "number", "app_info", "udid",
"udid_sync_info", "app_id", "remote_addr"]
action_choices = serializers.SerializerMethodField()
def get_action_choices(self, obj):
return get_choices_dict(obj.action_choices)
class AdminAppReportSerializer(AppReportSerializer):
class Meta:
model = models.AppReportInfo
fields = '__all__'
read_only_fields = ["id", "app_id", "username", "created_time", "email", "report_reason", "report_type",
"remote_addr", "bundle_id", "app_name"]
report_type_choices = serializers.SerializerMethodField()
def get_report_type_choices(self, obj):
return get_choices_dict(obj.report_type_choices)
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)

@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 1月
# author: NinEveN
# date: 2022/1/6
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = 100 # 最大页码数限制
class BaseModelSet(ModelViewSet):
def retrieve(self, request, *args, **kwargs):
data = super().retrieve(request, *args, **kwargs).data
return ApiResponse(data=data)
def list(self, request, *args, **kwargs):
data = super().list(request, *args, **kwargs).data
return ApiResponse(data=data)
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
self.perform_destroy(instance)
return ApiResponse()
def update(self, request, *args, **kwargs):
data = super().update(request, *args, **kwargs).data
return ApiResponse(data=data)
class ApiResponse(Response):
def __init__(self, code=1000, msg='success', data=None, status=None, headers=None, content_type=None, **kwargs):
dic = {
'code': code,
'msg': msg
}
if data is not None:
dic['data'] = data
dic.update(kwargs)
self._data = data
# 对象来调用对象的绑定方法,会自动传值
super().__init__(data=dic, status=status, headers=headers, content_type=content_type)
# 类来调用对象的绑定方法,这个方法就是一个普通函数,有几个参数就要传几个参数
# Response.__init__(data=dic,status=status,headers=headers,content_type=content_type)

@ -6,126 +6,76 @@
import logging
from rest_framework.response import Response
from rest_framework.views import APIView
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from admin.utils import AppsPageNumber
from admin.utils.serializer import AdminAppsSerializer, AdminAppReleaseSerializer
from admin.utils.utils import AppsPageNumber, ApiResponse, BaseModelSet
from api.base_views import app_delete
from api.models import AppReleaseInfo, Apps
from api.utils.TokenManager import verify_token
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminAppsSerializer, AdminAppReleaseSerializer
from api.utils.storage.caches import del_cache_response_by_short, get_download_url_by_cache
from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class AppInfoView(APIView):
class AppsFilter(filters.FilterSet):
min_count_hits = filters.NumberFilter(field_name="count_hits", lookup_expr='gte')
max_count_hits = filters.NumberFilter(field_name="count_hits", lookup_expr='lte')
bundle_id_like = filters.CharFilter(field_name="bundle_id", lookup_expr='icontains')
class Meta:
model = Apps
fields = ["id", "type", "name", "short", "bundle_id", "user_id", "status"]
class AppInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = Apps.objects.all()
serializer_class = AdminAppsSerializer
pagination_class = AppsPageNumber
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "type", "name", "short", "bundle_id", "domain_name", "user_id", "status"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-updated_time")
page_obj = AppsPageNumber()
obj_list = Apps.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminAppsSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
app_obj = Apps.objects.filter(pk=pk).first()
if app_obj:
data['pk'] = pk
serializer_obj = AdminAppsSerializer(app_obj, data=data, partial=True)
if serializer_obj.is_valid():
serializer_obj.save()
res.data = serializer_obj.data
del_cache_response_by_short(app_obj.app_id)
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
else:
res = app_delete(Apps.objects.filter(pk=pk).first())
return Response(res.dict)
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['updated_time', 'count_hits', 'created_time']
filterset_class = AppsFilter
def update(self, request, *args, **kwargs):
data = super().update(request, *args, **kwargs).data
del_cache_response_by_short(data.get('app_id'))
return ApiResponse(**data)
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
app_delete(instance)
return ApiResponse()
class AppReleaseInfoView(APIView):
class AppReleaseInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "release_id", "app_id"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
if not filter_data.get('app_id', None):
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
page_obj = AppsPageNumber()
obj_list = AppReleaseInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminAppReleaseSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
app_id = data.get("app_id", None)
if not pk or not app_id:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
app_obj = AppReleaseInfo.objects.filter(pk=pk, app_id=app_id).first()
if app_obj:
data['pk'] = pk
serializer_obj = AdminAppReleaseSerializer(app_obj, data=data, partial=True)
if serializer_obj.is_valid():
serializer_obj.save()
res.data = serializer_obj.data
del_cache_response_by_short(app_obj.app_id.app_id)
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def post(self, request):
res = BaseResponse()
queryset = AppReleaseInfo.objects.all()
serializer_class = AdminAppReleaseSerializer
pagination_class = AppsPageNumber
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time']
filterset_fields = ("id", "release_id", "app_id")
def update(self, request, *args, **kwargs):
data = super().update(request, *args, **kwargs).data
del_cache_response_by_short(data.get('app_aid'))
return ApiResponse(**data)
def create(self, request, *args, **kwargs):
data = request.data
downtoken = data.get("token", None)
app_id = data.get("app_id", None)
release_id = data.get("release_id", None)
if not downtoken or not app_id or not release_id:
res.code = 1004
res.msg = "参数丢失"
return Response(res.dict)
return ApiResponse(code=1004, msg='参数丢失')
if verify_token(downtoken, release_id):
app_obj = Apps.objects.filter(pk=app_id).values("pk", 'user_id', 'type').first()
@ -136,12 +86,7 @@ class AppReleaseInfoView(APIView):
else:
app_type = '.ipa'
download_url, extra_url = get_download_url_by_cache(app_obj, release_id + app_type, 600)
res.data = {"download_url": download_url, "extra_url": extra_url}
return Response(res.dict)
return ApiResponse(data={"download_url": download_url, "extra_url": extra_url})
else:
res.code = 1004
res.msg = "token校验失败"
return Response(res.dict)
res.code = 1006
res.msg = "该应用不存在"
return Response(res.dict)
return ApiResponse(code=1004, msg='token校验失败')
return ApiResponse(code=1006, msg='该应用不存在')

@ -6,79 +6,46 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from admin.utils.serializer import AdminDomainNameSerializer
from admin.utils.utils import BaseModelSet, AppsPageNumber, ApiResponse
from api.models import UserDomainInfo
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminDomainNameSerializer
from api.utils.storage.caches import reset_app_wx_easy_type
from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class DomainNameFilter(filters.FilterSet):
app_name = filters.CharFilter(field_name="app_id__name", lookup_expr='icontains')
class Meta:
model = UserDomainInfo
fields = ["id", "domain_name", "domain_type", "user_id", "is_enable"]
class DomainNameInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "domain_name", "app_name", "domain_type", "user_id", "is_enable"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
app_name = filter_data.get('app_name', None)
if app_name:
filter_data["app_id__name__contains"] = filter_data['app_name']
del filter_data['app_name']
sort = request.query_params.get("sort", "-created_time")
page_obj = PageNumber()
obj_list = UserDomainInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminDomainNameSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = UserDomainInfo.objects.filter(pk=pk).first()
if obj:
data['pk'] = pk
serializer_obj = AdminDomainNameSerializer(obj, data=data, partial=True)
if serializer_obj.is_valid():
serializer_obj.save()
res.data = serializer_obj.data
reset_app_wx_easy_type(obj.user_id, obj.app_id)
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
else:
user_domain_obj = UserDomainInfo.objects.filter(pk=pk).first()
reset_app_wx_easy_type(user_domain_obj.user_id, user_domain_obj.app_id)
user_domain_obj.delete()
return self.get(request)
return Response(res.dict)
class DomainNameInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = UserDomainInfo.objects.all()
serializer_class = AdminDomainNameSerializer
pagination_class = AppsPageNumber
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time']
filterset_class = DomainNameFilter
def update(self, request, *args, **kwargs):
data = super().update(request, *args, **kwargs).data
instance = self.queryset.filter(pk=data.get('id')).first()
if instance:
reset_app_wx_easy_type(instance.user_id, instance.app_id)
return ApiResponse(**data)
def destroy(self, request, *args, **kwargs):
instance = self.get_object()
reset_app_wx_easy_type(instance.user_id, instance.app_id)
self.perform_destroy(instance)
return ApiResponse()

@ -7,11 +7,10 @@
import logging
from django.contrib import auth
from rest_framework.response import Response
from rest_framework.views import APIView
from admin.utils.utils import ApiResponse
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import UserInfoSerializer
from api.utils.storage.caches import login_auth_failed
from api.utils.throttle import VisitRegister1Throttle, VisitRegister2Throttle
@ -25,9 +24,11 @@ class LoginView(APIView):
throttle_classes = [VisitRegister1Throttle, VisitRegister2Throttle]
def post(self, request):
response = BaseResponse()
receive = request.data
username = receive.get("username", None)
code = 1000
msg = 'success'
data = None
if LOGIN.get("captcha"):
is_valid = valid_captcha(receive.get("captcha_key", None), receive.get("authcode", None), username)
else:
@ -42,36 +43,35 @@ class LoginView(APIView):
if user.role == 3:
login_auth_failed("del", username)
key, user_info = set_user_token(user, request)
response.data = {
data = {
"username": user_info.username,
"token": key
}
else:
response.msg = "权限拒绝"
response.code = 1003
msg = "权限拒绝"
code = 1003
else:
response.msg = "用户被禁用"
response.code = 1005
msg = "用户被禁用"
code = 1005
else:
login_auth_failed("set", username)
response.msg = "密码或者账户有误"
response.code = 1002
msg = "密码或者账户有误"
code = 1002
else:
response.code = 1006
code = 1006
logger.error(f"username:{username} failed too try , locked")
response.msg = "用户登录失败次数过多,已被锁定,请1小时之后再次尝试"
msg = "用户登录失败次数过多,已被锁定,请1小时之后再次尝试"
else:
response.code = 1001
response.msg = "验证码有误"
code = 1001
msg = "验证码有误"
return Response(response.dict)
return ApiResponse(code=code, msg=msg, data=data)
def get(self, request):
response = BaseResponse()
response.data = {}
data = {}
if LOGIN.get("captcha"):
response.data = get_captcha()
return Response(response.dict)
data = get_captcha()
return ApiResponse(data=data)
class LoginUserView(APIView):
@ -79,8 +79,5 @@ class LoginUserView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request):
response = BaseResponse()
serializer = UserInfoSerializer(request.user, )
data = serializer.data
response.data = data
return Response(response.dict)
return ApiResponse(data=serializer.data)

@ -6,99 +6,57 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from admin.utils.serializer import AdminOrdersSerializer
from admin.utils.utils import BaseModelSet, AppsPageNumber, ApiResponse
from api.models import UserInfo, Order
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminOrdersSerializer
from api.utils.storage.caches import update_order_info, admin_change_user_download_times
from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class OrderFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
class Meta:
model = Order
fields = ["id", "payment_type", "payment_name", "payment_number", "order_number", "status", "order_type"]
class OrderInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "payment_type", "payment_name", "payment_number", "order_number", "status",
"order_type"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = PageNumber()
obj_list = Order.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminOrdersSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = Order.objects.filter(pk=pk).first()
old_status = obj.status
new_status = data.get('status', -99)
if obj:
data['pk'] = pk
serializer = AdminOrdersSerializer(obj, data=data, partial=True)
if serializer.is_valid():
if old_status != new_status and new_status == 0:
update_order_info(obj.user_id.pk, obj.order_number, obj.order_number, obj.payment_type)
else:
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
else:
order_obj = Order.objects.filter(pk=pk).first()
order_obj.delete()
return Response(res.dict)
def post(self, request):
res = BaseResponse()
class OrderInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = Order.objects.all()
serializer_class = AdminOrdersSerializer
pagination_class = AppsPageNumber
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time', 'pay_time', 'actual_amount']
filterset_class = OrderFilter
def update(self, request, *args, **kwargs):
instance = self.get_object()
old_status = instance.status
data = super().update(request, *args, **kwargs).data
new_status = request.data.get('status', -99)
if old_status != new_status and new_status == 0:
update_order_info(instance.user_id.pk, instance.order_number, instance.order_number, instance.payment_type)
return ApiResponse(**data)
def create(self, request, *args, **kwargs):
data = request.data
pk = data.get("id", None)
amount = data.get("amount", 0)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
return ApiResponse(code=1003, msg="参数错误")
obj = UserInfo.objects.filter(pk=pk).first()
if obj:
if amount > 0:
if admin_change_user_download_times(obj, amount):
return Response(res.dict)
return ApiResponse()
else:
res.code = 1005
res.msg = "订单创建失败"
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
return ApiResponse(code=1005, msg="订单创建失败")
return ApiResponse(code=1004, msg="数据校验失败")

@ -6,64 +6,30 @@
import logging
from rest_framework.response import Response
from rest_framework.views import APIView
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from admin.utils import AppsPageNumber
from admin.utils.serializer import AdminAppReportSerializer
from admin.utils.utils import AppsPageNumber, BaseModelSet
from api.models import AppReportInfo
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminAppReportSerializer
from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class AdminReportView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
class ReportFilter(filters.FilterSet):
class Meta:
model = AppReportInfo
fields = ["id", "app_name", "bundle_id", "remote_addr", "report_type", "email", "status", "app_id"]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "app_name", "bundle_id", "remote_addr", "report_type", "email", "status", "app_id"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = AppsPageNumber()
obj_list = AppReportInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminAppReportSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = AppReportInfo.objects.filter(id=pk).first()
if obj:
data['pk'] = pk
serializer = AdminAppReportSerializer(obj, data=data, partial=True)
if serializer.is_valid():
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
class AdminReportView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = AppReportInfo.objects.all()
serializer_class = AdminAppReportSerializer
pagination_class = AppsPageNumber
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
else:
AppReportInfo.objects.filter(pk=pk).delete()
return self.get(request)
return Response(res.dict)
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time']
filterset_class = ReportFilter

@ -5,73 +5,58 @@
# date: 2021/4/11
import logging
from copy import deepcopy
from rest_framework.response import Response
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from admin.utils.serializer import AdminStorageSerializer
from admin.utils.utils import AppsPageNumber, BaseModelSet, ApiResponse
from api.base_views import storage_change
from api.models import UserInfo, AppStorage
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminStorageSerializer
from common.base.baseutils import format_storage_selection
from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class StorageInfoView(APIView):
class StorageFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
class Meta:
model = AppStorage
fields = ["id", "name", "storage_type", "access_key", "bucket_name", "domain_name"]
class StorageInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = AppStorage.objects.all()
serializer_class = AdminStorageSerializer
pagination_class = AppsPageNumber
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "name", "storage_type", "access_key", "bucket_name"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = AppsPageNumber()
obj_list = AppStorage.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminStorageSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
if res.total:
res.storage_selection = format_storage_selection(serializer.data, serializer.data[0].get('storage_choices'))
return Response(res.dict)
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time', 'updated_time']
filterset_class = StorageFilter
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = AppStorage.objects.filter(pk=pk).first()
if obj and obj.user_id_id != obj.pk:
data['pk'] = pk
serializer = AdminStorageSerializer(obj, data=data, partial=True)
if serializer.is_valid():
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def list(self, request, *args, **kwargs):
data = super().list(request, *args, **kwargs)._data
if data['results']:
data['storage_selection'] = format_storage_selection(deepcopy(data['results']),
data['results'][0].get('storage_choices'))
return ApiResponse(data=data)
class StorageChangeView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
return ApiResponse(code=1003, msg="参数错误")
obj = UserInfo.objects.filter(pk=pk).first()
if obj:
logger.info(f"user {obj} update storage data:{data}")
@ -79,10 +64,7 @@ class StorageChangeView(APIView):
force = data.get("force", None)
if use_storage_id:
if not storage_change(use_storage_id, obj, force):
res.code = 1006
res.msg = '修改失败'
return Response(res.dict)
ApiResponse(code=1006, msg="修改失败")
return ApiResponse()
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
return ApiResponse(code=1004, msg="数据校验失败")

@ -6,144 +6,84 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from admin.utils.serializer import AdminDeveloperSerializer, AdminSuperSignUsedSerializer, AdminBillInfoSerializer
from admin.utils.utils import AppsPageNumber, BaseModelSet, ApiResponse
from api.models import APPSuperSignUsedInfo, AppIOSDeveloperInfo, IosDeveloperPublicPoolBill
from api.utils.auth import AdminTokenAuthentication
from api.utils.modelutils import get_user_public_used_sign_num, get_user_public_sign_num, get_user_obj_from_epu
from api.utils.response import BaseResponse
from api.utils.serializer import AdminDeveloperSerializer, AdminSuperSignUsedSerializer, AdminBillInfoSerializer
from api.utils.utils import get_developer_devices
from common.base.baseutils import get_dict_from_filter_fields, get_real_ip_address, get_order_num
from common.base.baseutils import get_real_ip_address, get_order_num
logger = logging.getLogger(__name__)
class DeveloperInfoView(APIView):
class DeveloperFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
class Meta:
model = AppIOSDeveloperInfo
fields = ["id", "issuer_id", "private_key_id", "certid", "description", "auth_type"]
class DeveloperInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = AppIOSDeveloperInfo.objects.all()
serializer_class = AdminDeveloperSerializer
pagination_class = AppsPageNumber
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "issuer_id", "private_key_id", "certid", "description", "auth_type"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = AppsPageNumber()
obj_list = AppIOSDeveloperInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminDeveloperSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = AppIOSDeveloperInfo.objects.filter(pk=pk).first()
if obj:
data['pk'] = pk
serializer = AdminDeveloperSerializer(obj, data=data, partial=True)
if serializer.is_valid():
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
class DevicesInfoView(APIView):
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time', 'cert_expire_time', 'updated_time']
filterset_class = DeveloperFilter
class DevicesFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
issuer_id = filters.CharFilter(field_name="developerid__issuer_id")
udid = filters.CharFilter(field_name="udid__udid__udid")
name = filters.CharFilter(field_name="app_id__name")
bundle_id = filters.CharFilter(field_name="app_id__bundle_id")
short = filters.CharFilter(field_name="app_id__short")
class Meta:
model = APPSuperSignUsedInfo
fields = ["id", "user_id", "issuer_id", "udid", "name", "bundle_id", "short"]
class DevicesInfoView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = APPSuperSignUsedInfo.objects.all()
serializer_class = AdminSuperSignUsedSerializer
pagination_class = AppsPageNumber
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "issuer_id", "udid", "name", "bundle_id", "short"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = AppsPageNumber()
if 'udid' in filter_data:
filter_data["udid__udid__udid"] = filter_data['udid']
del filter_data['udid']
if 'name' in filter_data:
filter_data["app_id__name"] = filter_data['name']
del filter_data['name']
if 'bundle_id' in filter_data:
filter_data["app_id__bundle_id"] = filter_data['bundle_id']
del filter_data['bundle_id']
if 'short' in filter_data:
filter_data["app_id__short"] = filter_data['short']
del filter_data['short']
if 'issuer_id' in filter_data:
filter_data["developerid__issuer_id"] = filter_data['issuer_id']
del filter_data['issuer_id']
obj_list = APPSuperSignUsedInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminSuperSignUsedSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = AppIOSDeveloperInfo.objects.filter(pk=pk).first()
if obj:
data['pk'] = pk
serializer = AdminDeveloperSerializer(obj, data=data, partial=True)
if serializer.is_valid():
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
class PageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class SuperSignBillView(APIView):
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time', 'updated_time']
filterset_class = DevicesFilter
class SuperSignBillFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
class Meta:
model = IosDeveloperPublicPoolBill
fields = ["id", "user_id", "to_user_id", "action", "udid", "app_id"]
class SuperSignBillView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = IosDeveloperPublicPoolBill.objects.all()
serializer_class = AdminBillInfoSerializer
pagination_class = AppsPageNumber
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "to_user_id", "action", "udid", "app_id"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = PageNumber()
obj_list = IosDeveloperPublicPoolBill.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminBillInfoSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def post(self, request):
res = BaseResponse()
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time']
filterset_class = SuperSignBillFilter
def create(self, request, *args, **kwargs):
data = request.data
user_id = data.get('user_id')
to_user_id = data.get('to_user_id')
@ -160,46 +100,34 @@ class SuperSignBillView(APIView):
udid=f'oid:{get_order_num()}',
version=f'{user_obj.first_name} 后台转账 {number} 设备数',
)
return Response(res.dict)
return ApiResponse()
except Exception as e:
res.msg = str(e)
msg = str(e)
else:
res.msg = '用户不合法'
else:
res.msg = '数量和用户不能为空'
res.code = 1001
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
msg = '用户不合法'
else:
order_obj = IosDeveloperPublicPoolBill.objects.filter(pk=pk).first()
order_obj.delete()
return Response(res.dict)
msg = '数量和用户不能为空'
return ApiResponse(code=1001, msg=msg)
class SuperSignBillUserInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
user_id = request.query_params.get('user_id')
public_balance_info = {}
private_balance_info = {}
if user_id:
user_obj = get_user_obj_from_epu(user_id)
if user_obj:
res.public_balance_info = {
public_balance_info = {
'used_balance': get_user_public_used_sign_num(user_obj),
'all_balance': get_user_public_sign_num(user_obj)
}
use_num = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=user_obj))
res.private_balance_info = {
private_balance_info = {
'used_balance': use_num.get('flyapp_used_sum', 0) + use_num.get('other_used_sum', 0),
'all_balance': use_num.get('max_total', 0)
}
return Response(res.dict)
return ApiResponse(public_balance_info=public_balance_info, private_balance_info=private_balance_info)

@ -6,14 +6,15 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from rest_framework.views import APIView
from admin.utils.serializer import AdminUserInfoSerializer, AdminUserCertificationSerializer, AdminThirdWxSerializer
from admin.utils.utils import AppsPageNumber, BaseModelSet, ApiResponse
from api.models import UserInfo, UserCertificationInfo, ThirdWeChatUserInfo
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
from api.utils.serializer import AdminUserInfoSerializer, AdminUserCertificationSerializer, AdminThirdWxSerializer
from api.utils.storage.caches import auth_user_download_times_gift
from common.base.baseutils import get_dict_from_filter_fields
from fir_ser.settings import AUTH_USER_GIVE_DOWNLOAD_TIMES
@ -21,18 +22,10 @@ from fir_ser.settings import AUTH_USER_GIVE_DOWNLOAD_TIMES
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class UserInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "mobile", "username", "email", "first_name"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-date_joined")
@ -42,23 +35,20 @@ class UserInfoView(APIView):
filter_data["certification__status__isnull"] = True
else:
filter_data["certification__status"] = certification
page_obj = PageNumber()
page_obj = AppsPageNumber()
obj_list = UserInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminUserInfoSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
data = serializer.data
total = obj_list.count()
return ApiResponse(data=data, total=total)
def put(self, request):
res = BaseResponse()
data = request.data
id = data.get("id", None)
if not id:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
return ApiResponse(code=1003, msg="参数错误")
user_obj = UserInfo.objects.filter(id=id).first()
if user_obj:
data['pk'] = id
@ -73,38 +63,32 @@ class UserInfoView(APIView):
UserCertificationInfo.objects.filter(user_id=user_obj).update(status=data["certification"])
if status != 1 and UserCertificationInfo.objects.filter(user_id=user_obj).first().status == 1:
auth_user_download_times_gift(user_obj, AUTH_USER_GIVE_DOWNLOAD_TIMES)
res.data = users_serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
data = users_serializer.data
return ApiResponse(data=data)
return ApiResponse(code=1004, msg='数据校验失败')
class UserCertificationInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "card", "name", "status"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = PageNumber()
page_obj = AppsPageNumber()
obj_list = UserCertificationInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminUserCertificationSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
data = serializer.data
total = obj_list.count()
return ApiResponse(data=data, total=total)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
return ApiResponse(code=1003, msg='参数错误')
obj = UserCertificationInfo.objects.filter(id=pk).first()
if obj:
data['pk'] = pk
@ -114,58 +98,25 @@ class UserCertificationInfoView(APIView):
users_serializer.save()
if status != 1 and users_serializer.data.get('status') == 1:
auth_user_download_times_gift(obj.user_id, AUTH_USER_GIVE_DOWNLOAD_TIMES)
res.data = users_serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
data = users_serializer.data
return ApiResponse(data=data)
return ApiResponse(code=1004, msg='数据校验失败')
class ThirdWxAccountView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
class ThirdWxAccountFilter(filters.FilterSet):
user_id = filters.NumberFilter(field_name="user_id__id")
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "openid", "nickname", "subscribe", "user_id"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = PageNumber()
obj_list = ThirdWeChatUserInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminThirdWxSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
class Meta:
model = ThirdWeChatUserInfo
fields = ["id", "openid", "nickname", "subscribe", "user_id"]
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = ThirdWeChatUserInfo.objects.filter(pk=pk).first()
if obj:
data['pk'] = pk
serializer_obj = AdminThirdWxSerializer(obj, data=data, partial=True)
if serializer_obj.is_valid():
serializer_obj.save()
res.data = serializer_obj.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
else:
ThirdWeChatUserInfo.objects.filter(pk=pk).delete()
return self.get(request)
return Response(res.dict)
class ThirdWxAccountView(BaseModelSet):
authentication_classes = [AdminTokenAuthentication, ]
queryset = ThirdWeChatUserInfo.objects.all()
serializer_class = AdminThirdWxSerializer
pagination_class = AppsPageNumber
filter_backends = [DjangoFilterBackend, OrderingFilter]
ordering_fields = ['created_time']
filterset_class = ThirdWxAccountFilter

@ -262,4 +262,4 @@ class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
max_page_size = 100 # 最大页码数限制

@ -97,49 +97,6 @@ class UserInfoSerializer(serializers.ModelSerializer):
return get_user_domain_name(obj, 0)
class AdminUserInfoSerializer(UserInfoSerializer):
class Meta:
model = models.UserInfo
exclude = ["password", "api_token"]
read_only_fields = ["id", "head_img", "free_download_times", "last_login",
"is_superuser", "last_name", "is_staff", "uid",
"date_joined", "download_times", "all_download_times", "storage", "groups",
"user_permissions", "certification_id", " app_count"]
gender_choices = serializers.SerializerMethodField()
def get_gender_choices(self, obj):
return get_choices_dict(obj.gender_choices)
role_choices = serializers.SerializerMethodField()
def get_role_choices(self, obj):
return get_choices_dict(obj.role_choices)
storage_choices = serializers.SerializerMethodField()
def get_storage_choices(self, obj):
return get_choices_dict(models.AppStorage.storage_choices[1:])
certification_status_choices = serializers.SerializerMethodField()
def get_certification_status_choices(self, obj):
return get_choices_dict(models.UserCertificationInfo.status_choices)
certification_id = serializers.SerializerMethodField()
def get_certification_id(self, obj):
return models.UserCertificationInfo.objects.filter(user_id=obj).values('id').first()
app_count = serializers.SerializerMethodField()
def get_app_count(self, obj):
return models.Apps.objects.filter(user_id=obj).count()
def update(self, instance, validated_data):
return super(AdminUserInfoSerializer, self).update(instance, validated_data)
class AppsSerializer(serializers.ModelSerializer):
class Meta:
model = models.Apps
@ -280,36 +237,6 @@ class AppsQrListSerializer(AppsListSerializer):
return {}
class AdminAppsSerializer(AppsSerializer):
class Meta:
model = models.Apps
fields = "__all__"
read_only_fields = ["id", "app_id", "user_id", "bundle_id", "count_hits", "updated_time", "created_time"]
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
type_choices = serializers.SerializerMethodField()
def get_type_choices(self, obj):
return get_choices_dict(obj.type_choices)
supersign_type_choices = serializers.SerializerMethodField()
def get_supersign_type_choices(self, obj):
return get_choices_dict(obj.supersign_type_choices)
release_count = serializers.SerializerMethodField()
def get_release_count(self, obj):
return models.AppReleaseInfo.objects.filter(app_id=obj).count()
def update(self, instance, validated_data):
return super(AdminAppsSerializer, self).update(instance, validated_data)
class AppsShortSerializer(serializers.ModelSerializer):
class Meta:
model = models.Apps
@ -414,26 +341,6 @@ class AppReleaseSerializer(serializers.ModelSerializer):
return {"changelog": False, "binary_url": False}
class AdminAppReleaseSerializer(AppReleaseSerializer):
class Meta:
model = models.AppReleaseInfo
fields = "__all__"
read_only_fields = ["id", "app_id", "release_id", "binary_size"]
release_choices = serializers.SerializerMethodField()
def get_release_choices(self, obj):
return get_choices_dict(obj.release_choices)
def update(self, instance, validated_data):
if validated_data.get("is_master", False):
models.AppReleaseInfo.objects.filter(app_id=instance.app_id).update(**{"is_master": False})
else:
if "is_master" in validated_data and validated_data.get("is_master") != True:
del validated_data["is_master"]
return super(AdminAppReleaseSerializer, self).update(instance, validated_data)
class StorageSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppStorage
@ -471,20 +378,6 @@ class StorageSerializer(serializers.ModelSerializer):
return super().update(instance, validated_data)
class AdminStorageSerializer(StorageSerializer):
class Meta:
model = models.AppStorage
fields = "__all__"
read_only_fields = ["id", "user_id", "updated_time", "created_time", "storage_type"]
storage_choices = serializers.SerializerMethodField()
def get_storage_choices(self, obj):
return get_choices_dict(obj.storage_choices[1:])
used_id = serializers.IntegerField(source="user_id.pk")
class DeveloperSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppIOSDeveloperInfo
@ -561,18 +454,6 @@ class DeveloperSerializer(serializers.ModelSerializer):
return models.DeveloperAppID.objects.filter(developerid=obj).count()
class AdminDeveloperSerializer(DeveloperSerializer):
class Meta:
model = models.AppIOSDeveloperInfo
# depth = 1
exclude = ["p8key", ]
auth_type_choices = serializers.SerializerMethodField()
def get_auth_type_choices(self, obj):
return get_choices_dict(obj.auth_type_choices)
class SuperSignUsedSerializer(serializers.ModelSerializer):
class Meta:
model = models.APPSuperSignUsedInfo
@ -616,21 +497,6 @@ class SuperSignUsedSerializer(serializers.ModelSerializer):
return obj.user_id.uid
class AdminSuperSignUsedSerializer(SuperSignUsedSerializer):
class Meta:
model = models.APPSuperSignUsedInfo
fields = ["created_time", "device_udid", "device_name", "developer_id", "bundle_id", "bundle_name", "app_id",
"id", "user_id", "short", "developer_pk"]
app_id = serializers.IntegerField(source="app_id.pk")
user_id = serializers.IntegerField(source="user_id.pk")
short = serializers.CharField(source="app_id.short")
developer_pk = serializers.IntegerField(source="developerid.pk")
class DeveloperDeviceSerializer(serializers.ModelSerializer):
class Meta:
model = models.UDIDsyncDeveloper
@ -706,29 +572,6 @@ class OrdersSerializer(serializers.ModelSerializer):
exclude = ["id"]
class AdminOrdersSerializer(serializers.ModelSerializer):
class Meta:
model = models.Order
fields = "__all__"
read_only_fields = ["id", "user_id", "updated_time", "created_time", "payment_number", "order_number",
"payment_name", "actual_amount", "actual_download_times", "actual_download_gift_times"]
payment_type_choices = serializers.SerializerMethodField()
def get_payment_type_choices(self, obj):
return get_choices_dict(obj.payment_type_choices)
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
order_type_choices = serializers.SerializerMethodField()
def get_order_type_choices(self, obj):
return get_choices_dict(obj.order_type_choices)
class CertificationSerializer(serializers.ModelSerializer):
class Meta:
model = models.CertificationInfo
@ -746,45 +589,12 @@ class UserCertificationSerializer(serializers.ModelSerializer):
exclude = ["id", "user_id", "created_time"]
class AdminUserCertificationSerializer(serializers.ModelSerializer):
class Meta:
model = models.UserCertificationInfo
fields = "__all__"
read_only_fields = ["id", "user_id", "reviewed_time", "created_time"]
certification_status_choices = serializers.SerializerMethodField()
def get_certification_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
certification_infos = serializers.SerializerMethodField()
def get_certification_infos(self, obj):
result = []
for c_info in models.CertificationInfo.objects.filter(user_id=obj.user_id).all():
result.append({
'name': get_choices_name_from_key(models.CertificationInfo.type_choices, c_info.type),
'certification_url': get_download_url_from_context(self, obj, '', c_info.certification_url)
})
return result
def update(self, instance, validated_data):
return super(AdminUserCertificationSerializer, self).update(instance, validated_data)
class ThirdWxSerializer(serializers.ModelSerializer):
class Meta:
model = models.ThirdWeChatUserInfo
exclude = ["id", "sex", "address", "user_id"]
class AdminThirdWxSerializer(ThirdWxSerializer):
class Meta:
model = models.ThirdWeChatUserInfo
fields = "__all__"
read_only_fields = ["id", "openid", "user_id", "head_img_url"]
class DomainNameSerializer(serializers.ModelSerializer):
class Meta:
model = models.UserDomainInfo
@ -803,18 +613,6 @@ class DomainNameSerializer(serializers.ModelSerializer):
return {}
class AdminDomainNameSerializer(DomainNameSerializer):
class Meta:
model = models.UserDomainInfo
fields = "__all__"
read_only_fields = ["id", "app_id", "domain_type", "created_time", "cname_id"]
domain_type_choices = serializers.SerializerMethodField()
def get_domain_type_choices(self, obj):
return get_choices_dict(obj.domain_type_choices)
class UserAdInfoSerializer(serializers.ModelSerializer):
class Meta:
model = models.UserAdDisplayInfo
@ -896,43 +694,12 @@ class BillInfoSerializer(serializers.ModelSerializer):
return f"{obj.to_user_id.first_name} {self.get_action(obj)} -{obj.number} 设备数"
class AdminBillInfoSerializer(BillInfoSerializer):
class Meta:
model = models.IosDeveloperPublicPoolBill
fields = '__all__'
read_only_fields = ["id", "user_id", "to_user_id", "action", "number", "app_info", "udid",
"udid_sync_info", "app_id", "remote_addr"]
action_choices = serializers.SerializerMethodField()
def get_action_choices(self, obj):
return get_choices_dict(obj.action_choices)
class AppReportSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppReportInfo
exclude = ["id"]
class AdminAppReportSerializer(AppReportSerializer):
class Meta:
model = models.AppReportInfo
fields = '__all__'
read_only_fields = ["id", "app_id", "username", "created_time", "email", "report_reason", "report_type",
"remote_addr", "bundle_id", "app_name"]
report_type_choices = serializers.SerializerMethodField()
def get_report_type_choices(self, obj):
return get_choices_dict(obj.report_type_choices)
status_choices = serializers.SerializerMethodField()
def get_status_choices(self, obj):
return get_choices_dict(obj.status_choices)
class AppleDeveloperToAppUseSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppleDeveloperToAppUse

@ -10,7 +10,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from api.base_views import storage_change, app_delete
from api.models import AppStorage, UserInfo, Apps
from api.models import AppStorage, Apps
from api.utils.app.apputils import clean_history_apps
from api.utils.auth import ExpiringTokenAuthentication, StoragePermission
from api.utils.response import BaseResponse

@ -50,13 +50,14 @@ def invalid_short_cache(app_obj, key='ShortDownloadView'.lower()):
return
master_release_dict = AppReleaseInfo.objects.filter(app_id=app_obj, is_master=True).values('icon_url',
'release_id').first()
# 1.清理图片缓存
DownloadUrlCache(key, master_release_dict.get('icon_url')).del_storage_cache()
release_id = master_release_dict.get('release_id')
# 2.清理下载token缓存
TokenManagerCache(key, release_id).del_storage_cache()
TokenManagerCache('', f"{release_id}.plist").del_storage_cache()
if master_release_dict:
# 1.清理图片缓存
DownloadUrlCache(key, master_release_dict.get('icon_url')).del_storage_cache()
release_id = master_release_dict.get('release_id')
# 2.清理下载token缓存
TokenManagerCache(key, release_id).del_storage_cache()
TokenManagerCache('', f"{release_id}.plist").del_storage_cache()
# 3.清理广告缓存
invalid_ad_pic_cache(key, app_obj.short)

@ -45,6 +45,7 @@ INSTALLED_APPS = [
'django_celery_beat',
'django_celery_results',
'corsheaders',
'django_filters',
]
MIDDLEWARE = [
@ -137,15 +138,17 @@ AUTH_PASSWORD_VALIDATORS = [
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
),
'DEFAULT_THROTTLE_CLASSES': [
'api.utils.throttle.LoginUserThrottle',
],
'DEFAULT_THROTTLE_RATES': BASECONF.DEFAULT_THROTTLE_RATES
'DEFAULT_THROTTLE_RATES': BASECONF.DEFAULT_THROTTLE_RATES,
'EXCEPTION_HANDLER': 'admin.utils.exception.common_exception_handler',
}
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
@ -165,9 +168,13 @@ DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_URL = '/statics/'
# python manage.py collectstatic 收集到的静态文件
STATIC_ROOT = os.path.join(BASE_DIR, "api-static")
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
os.path.join(BASE_DIR, "statics")
]
# Media配置

@ -21,4 +21,5 @@ psutil==5.6.6
flower==1.0.0
django-proxy==1.2.1
uWSGI==2.0.20
django-cors-headers==3.10.1
django-cors-headers==3.10.1
django-filter==21.1
Loading…
Cancel
Save