作者 linmadan

添加素币相关功能

正在显示 23 个修改的文件 包含 1046 行增加75 行删除
... ... @@ -18,19 +18,61 @@
"application/xml"
],
"paths": {
"/config/bid-time-matchs": {
"get": {
"tags": [
"config"
],
"summary": "返回竞标时间字典列表(1全部,2已截止,3未截止)",
"description": "返回竞标时间字典列表(1全部,2已截止,3未截止)",
"operationId": "config#listBidTimeMatch",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListBidTimeMatchResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/config/customer-values": {
"get": {
"tags": [
"config"
],
"summary": "返回客户价值列表",
"description": "返回客户价值列表",
"operationId": "config#listCustomerValues",
"summary": "返回客户价值字典列表",
"description": "返回客户价值字典列表",
"operationId": "config#listCustomerValue",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListCustomerValuesResponseBody"
"$ref": "#/definitions/ConfigListCustomerValueResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/config/reference-resource-types": {
"get": {
"tags": [
"config"
],
"summary": "返回任务引用资源类型字典列表",
"description": "返回任务引用资源类型字典列表",
"operationId": "config#listReferenceResourceType",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListReferenceResourceTypeResponseBody"
}
}
},
... ... @@ -44,14 +86,14 @@
"tags": [
"config"
],
"summary": "返回任务性质列表",
"description": "返回任务性质列表",
"operationId": "config#listTaskNatures",
"summary": "返回任务性质字典列表",
"description": "返回任务性质字典列表",
"operationId": "config#listTaskNature",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListTaskNaturesResponseBody"
"$ref": "#/definitions/ConfigListTaskNatureResponseBody"
}
}
},
... ... @@ -65,8 +107,8 @@
"tags": [
"config"
],
"summary": "返回任务状态列表",
"description": "返回任务状态列表",
"summary": "返回任务状态字典列表",
"description": "返回任务状态字典列表",
"operationId": "config#listTaskStatus",
"responses": {
"200": {
... ... @@ -86,14 +128,14 @@
"tags": [
"config"
],
"summary": "返回任务类型列表",
"description": "返回任务类型列表",
"operationId": "config#listTaskTypes",
"summary": "返回任务类型字典列表",
"description": "返回任务类型字典列表",
"operationId": "config#listTaskType",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListTaskTypesResponseBody"
"$ref": "#/definitions/ConfigListTaskTypeResponseBody"
}
}
},
... ... @@ -262,6 +304,68 @@
]
}
},
"/su-money/exchange": {
"post": {
"tags": [
"suMoney"
],
"summary": "素币兑换",
"description": "素币兑换",
"operationId": "suMoney#exchangeSuMoney",
"parameters": [
{
"name": "ExchangeSuMoneyRequestBody",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SuMoneyExchangeSuMoneyRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/SuMoneyExchangeSuMoneyResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/su-money/search-su-money-transaction-record": {
"post": {
"tags": [
"suMoney"
],
"summary": "搜索素币事务记录",
"description": "搜索素币事务记录",
"operationId": "suMoney#searchSuMoneyTransactionRecord",
"parameters": [
{
"name": "SearchSuMoneyTransactionRecordRequestBody",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SuMoneySearchSuMoneyTransactionRecordRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/SuMoneySearchSuMoneyTransactionRecordResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/tasks": {
"get": {
"tags": [
... ... @@ -832,8 +936,20 @@
}
},
"definitions": {
"ConfigListCustomerValuesResponseBody": {
"title": "Mediatype identifier: ConfigListCustomerValuesResponseBody",
"ConfigListBidTimeMatchResponseBody": {
"title": "Mediatype identifier: ConfigListBidTimeMatchResponseBody",
"type": "object",
"properties": {
"bidTimeMatchs": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"ConfigListCustomerValueResponseBody": {
"title": "Mediatype identifier: ConfigListCustomerValueResponseBody",
"type": "object",
"properties": {
"customerValues": {
... ... @@ -844,8 +960,20 @@
}
}
},
"ConfigListTaskNaturesResponseBody": {
"title": "Mediatype identifier: ConfigListTaskNaturesResponseBody",
"ConfigListReferenceResourceTypeResponseBody": {
"title": "Mediatype identifier: ConfigListReferenceResourceTypeResponseBody",
"type": "object",
"properties": {
"referenceResourceTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"ConfigListTaskNatureResponseBody": {
"title": "Mediatype identifier: ConfigListTaskNatureResponseBody",
"type": "object",
"properties": {
"taskNatures": {
... ... @@ -868,8 +996,8 @@
}
}
},
"ConfigListTaskTypesResponseBody": {
"title": "Mediatype identifier: ConfigListTaskTypesResponseBody",
"ConfigListTaskTypeResponseBody": {
"title": "Mediatype identifier: ConfigListTaskTypeResponseBody",
"type": "object",
"properties": {
"taskTypes": {
... ... @@ -968,6 +1096,94 @@
}
}
},
"SuMoneyExchangeSuMoneyRequestBody": {
"title": "SuMoneyExchangeSuMoneyRequestBody",
"type": "object",
"properties": {
"exchangeDescription": {
"type": "string",
"description": "兑换描述",
"required": [
"exchangeDescription"
]
},
"operator": {
"type": "integer",
"description": "操作人UID(默认为系统操作)",
"format": "int64"
},
"suMoney": {
"type": "number",
"description": "素币值",
"required": [
"suMoney"
]
},
"uid": {
"type": "integer",
"description": "兑换人UID",
"required": [
"uid"
]
}
}
},
"SuMoneyExchangeSuMoneyResponseBody": {
"title": "Mediatype identifier: SuMoneyExchangeSuMoneyResponseBody",
"type": "object",
"properties": {
"suMoneyTransactionRecord": {
"$ref": "#/definitions/suMoneyTransactionRecordResponseBody"
}
}
},
"SuMoneySearchSuMoneyTransactionRecordRequestBody": {
"title": "SuMoneySearchSuMoneyTransactionRecordRequestBody",
"type": "object",
"properties": {
"limit": {
"type": "integer",
"description": "查询限制",
"format": "int64"
},
"offset": {
"type": "integer",
"description": "查询偏离量",
"format": "int64"
},
"recordType": {
"type": "integer",
"description": "记录类型(1兑换,2任务奖励)",
"required": [
"recordType"
]
},
"uid": {
"type": "integer",
"description": "统一用户UID",
"required": [
"uid"
]
}
}
},
"SuMoneySearchSuMoneyTransactionRecordResponseBody": {
"title": "Mediatype identifier: SuMoneySearchSuMoneyTransactionRecordResponseBody",
"type": "object",
"properties": {
"count": {
"type": "integer",
"description": "结果总数",
"format": "int64"
},
"suMoneyTransactionRecords": {
"type": "array",
"items": {
"$ref": "#/definitions/suMoneyTransactionRecordResponseBody"
}
}
}
},
"TaskAcceptanceTaskRequestBody": {
"title": "TaskAcceptanceTaskRequestBody",
"type": "object",
... ... @@ -1819,6 +2035,58 @@
},
"description": "抢单任务信息"
},
"suMoneyTransactionRecordResponseBody": {
"title": "suMoneyTransactionRecordResponseBody",
"type": "object",
"properties": {
"createTime": {
"type": "string",
"description": "创建时间",
"required": [
"createTime"
]
},
"employee": {
"$ref": "#/definitions/employeeInfoResponseBody"
},
"operator": {
"type": "integer",
"description": "操作人",
"required": [
"operator"
]
},
"recordDescription": {
"type": "string",
"description": "素币事务记录描述",
"required": [
"recordDescription"
]
},
"recordType": {
"type": "integer",
"description": "记录类型(1兑换,2任务奖励)",
"required": [
"recordType"
]
},
"suMoney": {
"type": "number",
"description": "事务素币值",
"required": [
"suMoney"
]
},
"suMoneyTransactionRecordId": {
"type": "integer",
"description": "素币事务记录ID",
"required": [
"suMoneyTransactionRecordId"
]
}
},
"description": "素币事务记录"
},
"taskPercentageItemRequestBody": {
"title": "taskPercentageItemRequestBody",
"type": "object",
... ...
... ... @@ -13,40 +13,68 @@ produces:
- application/json
- application/xml
paths:
/config/bid-time-matchs:
get:
tags:
- config
summary: 返回竞标时间字典列表(1全部,2已截止,3未截止)
description: 返回竞标时间字典列表(1全部,2已截止,3未截止)
operationId: config#listBidTimeMatch
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListBidTimeMatchResponseBody'
schemes:
- http
/config/customer-values:
get:
tags:
- config
summary: 返回客户价值列表
description: 返回客户价值列表
operationId: config#listCustomerValues
summary: 返回客户价值字典列表
description: 返回客户价值字典列表
operationId: config#listCustomerValue
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListCustomerValueResponseBody'
schemes:
- http
/config/reference-resource-types:
get:
tags:
- config
summary: 返回任务引用资源类型字典列表
description: 返回任务引用资源类型字典列表
operationId: config#listReferenceResourceType
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListCustomerValuesResponseBody'
$ref: '#/definitions/ConfigListReferenceResourceTypeResponseBody'
schemes:
- http
/config/task-natures:
get:
tags:
- config
summary: 返回任务性质列表
description: 返回任务性质列表
operationId: config#listTaskNatures
summary: 返回任务性质字典列表
description: 返回任务性质字典列表
operationId: config#listTaskNature
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListTaskNaturesResponseBody'
$ref: '#/definitions/ConfigListTaskNatureResponseBody'
schemes:
- http
/config/task-statuses:
get:
tags:
- config
summary: 返回任务状态列表
description: 返回任务状态列表
summary: 返回任务状态字典列表
description: 返回任务状态字典列表
operationId: config#listTaskStatus
responses:
"200":
... ... @@ -59,14 +87,14 @@ paths:
get:
tags:
- config
summary: 返回任务类型列表
description: 返回任务类型列表
operationId: config#listTaskTypes
summary: 返回任务类型字典列表
description: 返回任务类型字典列表
operationId: config#listTaskType
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListTaskTypesResponseBody'
$ref: '#/definitions/ConfigListTaskTypeResponseBody'
schemes:
- http
/employees:
... ... @@ -176,6 +204,46 @@ paths:
$ref: '#/definitions/EmployeeRemoveEmployeeResponseBody'
schemes:
- http
/su-money/exchange:
post:
tags:
- suMoney
summary: 素币兑换
description: 素币兑换
operationId: suMoney#exchangeSuMoney
parameters:
- name: ExchangeSuMoneyRequestBody
in: body
required: true
schema:
$ref: '#/definitions/SuMoneyExchangeSuMoneyRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/SuMoneyExchangeSuMoneyResponseBody'
schemes:
- http
/su-money/search-su-money-transaction-record:
post:
tags:
- suMoney
summary: 搜索素币事务记录
description: 搜索素币事务记录
operationId: suMoney#searchSuMoneyTransactionRecord
parameters:
- name: SearchSuMoneyTransactionRecordRequestBody
in: body
required: true
schema:
$ref: '#/definitions/SuMoneySearchSuMoneyTransactionRecordRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/SuMoneySearchSuMoneyTransactionRecordResponseBody'
schemes:
- http
/tasks:
get:
tags:
... ... @@ -557,16 +625,32 @@ paths:
schemes:
- http
definitions:
ConfigListCustomerValuesResponseBody:
title: 'Mediatype identifier: ConfigListCustomerValuesResponseBody'
ConfigListBidTimeMatchResponseBody:
title: 'Mediatype identifier: ConfigListBidTimeMatchResponseBody'
type: object
properties:
bidTimeMatchs:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListCustomerValueResponseBody:
title: 'Mediatype identifier: ConfigListCustomerValueResponseBody'
type: object
properties:
customerValues:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskNaturesResponseBody:
title: 'Mediatype identifier: ConfigListTaskNaturesResponseBody'
ConfigListReferenceResourceTypeResponseBody:
title: 'Mediatype identifier: ConfigListReferenceResourceTypeResponseBody'
type: object
properties:
referenceResourceTypes:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskNatureResponseBody:
title: 'Mediatype identifier: ConfigListTaskNatureResponseBody'
type: object
properties:
taskNatures:
... ... @@ -581,8 +665,8 @@ definitions:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskTypesResponseBody:
title: 'Mediatype identifier: ConfigListTaskTypesResponseBody'
ConfigListTaskTypeResponseBody:
title: 'Mediatype identifier: ConfigListTaskTypeResponseBody'
type: object
properties:
taskTypes:
... ... @@ -650,6 +734,69 @@ definitions:
properties:
employee:
$ref: '#/definitions/employeeResponseBody'
SuMoneyExchangeSuMoneyRequestBody:
title: SuMoneyExchangeSuMoneyRequestBody
type: object
properties:
exchangeDescription:
type: string
description: 兑换描述
required:
- exchangeDescription
operator:
type: integer
description: 操作人UID(默认为系统操作)
format: int64
suMoney:
type: number
description: 素币值
required:
- suMoney
uid:
type: integer
description: 兑换人UID
required:
- uid
SuMoneyExchangeSuMoneyResponseBody:
title: 'Mediatype identifier: SuMoneyExchangeSuMoneyResponseBody'
type: object
properties:
suMoneyTransactionRecord:
$ref: '#/definitions/suMoneyTransactionRecordResponseBody'
SuMoneySearchSuMoneyTransactionRecordRequestBody:
title: SuMoneySearchSuMoneyTransactionRecordRequestBody
type: object
properties:
limit:
type: integer
description: 查询限制
format: int64
offset:
type: integer
description: 查询偏离量
format: int64
recordType:
type: integer
description: 记录类型(1兑换,2任务奖励)
required:
- recordType
uid:
type: integer
description: 统一用户UID
required:
- uid
SuMoneySearchSuMoneyTransactionRecordResponseBody:
title: 'Mediatype identifier: SuMoneySearchSuMoneyTransactionRecordResponseBody'
type: object
properties:
count:
type: integer
description: 结果总数
format: int64
suMoneyTransactionRecords:
type: array
items:
$ref: '#/definitions/suMoneyTransactionRecordResponseBody'
TaskAcceptanceTaskRequestBody:
title: TaskAcceptanceTaskRequestBody
type: object
... ... @@ -1259,6 +1406,43 @@ definitions:
receiver:
$ref: '#/definitions/employeeInfoResponseBody'
description: 抢单任务信息
suMoneyTransactionRecordResponseBody:
title: suMoneyTransactionRecordResponseBody
type: object
properties:
createTime:
type: string
description: 创建时间
required:
- createTime
employee:
$ref: '#/definitions/employeeInfoResponseBody'
operator:
type: integer
description: 操作人
required:
- operator
recordDescription:
type: string
description: 素币事务记录描述
required:
- recordDescription
recordType:
type: integer
description: 记录类型(1兑换,2任务奖励)
required:
- recordType
suMoney:
type: number
description: 事务素币值
required:
- suMoney
suMoneyTransactionRecordId:
type: integer
description: 素币事务记录ID
required:
- suMoneyTransactionRecordId
description: 素币事务记录
taskPercentageItemRequestBody:
title: taskPercentageItemRequestBody
type: object
... ...
... ... @@ -6,12 +6,12 @@ import (
"github.com/astaxie/beego/validation"
)
type ListCustomerValuesQuery struct {
type ListBidTimeMatchQuery struct {
}
func (listCustomerValuesQuery *ListCustomerValuesQuery) ValidateQuery() error {
func (listBidTimeMatchQuery *ListBidTimeMatchQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listCustomerValuesQuery)
b, err := valid.Valid(listBidTimeMatchQuery)
if err != nil {
return err
}
... ...
... ... @@ -6,12 +6,12 @@ import (
"github.com/astaxie/beego/validation"
)
type ListTaskNaturesQuery struct {
type ListCustomerValueQuery struct {
}
func (listTaskNaturesQuery *ListTaskNaturesQuery) ValidateQuery() error {
func (listCustomerValueQuery *ListCustomerValueQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskNaturesQuery)
b, err := valid.Valid(listCustomerValueQuery)
if err != nil {
return err
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListReferenceResourceTypeQuery struct {
}
func (listReferenceResourceTypeQuery *ListReferenceResourceTypeQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listReferenceResourceTypeQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -6,12 +6,12 @@ import (
"github.com/astaxie/beego/validation"
)
type ListTaskTypesQuery struct {
type ListTaskNatureQuery struct {
}
func (listTaskTypesQuery *ListTaskTypesQuery) ValidateQuery() error {
func (listTaskNatureQuery *ListTaskNatureQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskTypesQuery)
b, err := valid.Valid(listTaskNatureQuery)
if err != nil {
return err
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListTaskTypeQuery struct {
}
func (listTaskTypeQuery *ListTaskTypeQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskTypeQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -14,55 +14,76 @@ func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.Li
if err := listTaskStatusQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskStatuses := map[int]string{
taskStatusMap := map[int]string{
1: "待发布",
2: "待领取",
3: "进行中",
4: "待验收",
5: "已完成",
}
var list []map[string]interface{}
for key, value := range taskStatusMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"taskStatuses": taskStatuses,
"taskStatuses": list,
}, nil
}
// 返回任务类型列表
func (configService *ConfigService) ListTaskTypes(listTaskTypesQuery *query.ListTaskTypesQuery) (interface{}, error) {
if err := listTaskTypesQuery.ValidateQuery(); err != nil {
func (configService *ConfigService) ListTaskType(listTaskTypeQuery *query.ListTaskTypeQuery) (interface{}, error) {
if err := listTaskTypeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskTypes := map[int]string{
taskTypeMap := map[int]string{
1: "抢单任务",
2: "竞标任务",
}
var list []map[string]interface{}
for key, value := range taskTypeMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"taskTypes": taskTypes,
"taskTypes": list,
}, nil
}
// 返回任务性质列表
func (configService *ConfigService) ListTaskNatures(listTaskNaturesQuery *query.ListTaskNaturesQuery) (interface{}, error) {
if err := listTaskNaturesQuery.ValidateQuery(); err != nil {
func (configService *ConfigService) ListTaskNature(listTaskNatureQuery *query.ListTaskNatureQuery) (interface{}, error) {
if err := listTaskNatureQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskNatures := map[int]string{
taskNatureMap := map[int]string{
1: "点",
2: "线",
3: "面",
4: "链",
5: "网",
}
var list []map[string]interface{}
for key, value := range taskNatureMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"taskNatures": taskNatures,
"taskNatures": list,
}, nil
}
// 返回客户价值列表
func (configService *ConfigService) ListCustomerValues(listCustomerValuesQuery *query.ListCustomerValuesQuery) (interface{}, error) {
if err := listCustomerValuesQuery.ValidateQuery(); err != nil {
func (configService *ConfigService) ListCustomerValue(listCustomerValueQuery *query.ListCustomerValueQuery) (interface{}, error) {
if err := listCustomerValueQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
customerValues := map[int]string{
customerValueMap := map[int]string{
1: "口味",
2: "口感",
3: "色泽",
... ... @@ -87,8 +108,58 @@ func (configService *ConfigService) ListCustomerValues(listCustomerValuesQuery *
22: "品牌",
23: "合同",
}
var list []map[string]interface{}
for key, value := range customerValueMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"customerValues": list,
}, nil
}
// 返回任务引用资源类型字典列表
func (configService *ConfigService) ListReferenceResourceType(listReferenceResourceTypeQuery *query.ListReferenceResourceTypeQuery) (interface{}, error) {
if err := listReferenceResourceTypeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
referenceResourceTypeMap := map[int]string{
1: "问题",
2: "机会",
}
var list []map[string]interface{}
for key, value := range referenceResourceTypeMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"referenceResourceTypes": list,
}, nil
}
// 返回竞标时间字典列表(1全部,2已截止,3未截止)
func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *query.ListBidTimeMatchQuery) (interface{}, error) {
if err := listBidTimeMatchQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
bidTimeMatchMap := map[int]string{
1: "全部",
2: "已截止",
3: "未截止",
}
var list []map[string]interface{}
for key, value := range bidTimeMatchMap {
list = append(list, map[string]interface{}{
"id": key,
"name": value,
})
}
return map[string]interface{}{
"customerValues": customerValues,
"bidTimeMatchs": list,
}, nil
}
... ...
... ... @@ -29,3 +29,11 @@ func CreateOffTaskRecordRepository(options map[string]interface{}) (domain.OffTa
}
return repository.NewOffTaskRecordRepository(transactionContext)
}
func CreateSuMoneyTransactionRecordRepository(options map[string]interface{}) (domain.SuMoneyTransactionRecordRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewSuMoneyTransactionRecordRepository(transactionContext)
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ExchangeSuMoneyCommand struct {
// 兑换人UID
Uid int64 `json:"uid" valid:"Required"`
// 素币值
SuMoney float64 `json:"suMoney" valid:"Required"`
// 操作人UID(默认为系统操作)
Operator int64 `json:"operator,omitempty"`
// 兑换描述
ExchangeDescription string `json:"exchangeDescription" valid:"Required"`
}
func (exchangeSuMoneyCommand *ExchangeSuMoneyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(exchangeSuMoneyCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchSuMoneyTransactionRecordCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
// 记录类型(1兑换,2任务奖励)
RecordType int `json:"recordType" valid:"Required"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
Limit int `json:"limit,omitempty"`
}
func (searchSuMoneyTransactionRecordCommand *SearchSuMoneyTransactionRecordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchSuMoneyTransactionRecordCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
)
// 素币服务
type SuMoneyService struct {
}
// 素币兑换
func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *command.ExchangeSuMoneyCommand) (interface{}, error) {
if err := exchangeSuMoneyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 搜索素币事务记录
func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand *command.SearchSuMoneyTransactionRecordCommand) (interface{}, error) {
if err := searchSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
func NewSuMoneyService(options map[string]interface{}) *SuMoneyService {
newSuMoneyService := &SuMoneyService{}
return newSuMoneyService
}
... ...
package domain
import "time"
// 素币事务记录
type SuMoneyTransactionRecord struct {
// 素币事务记录ID
SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"`
// 记录类型
RecordType int `json:"recordType"`
// 记录关联员工
Employee *EmployeeInfo `json:"employeeInfo"`
// 事务素币值
SuMoney float64 `json:"suMoney"`
// 操作人
Operator int64 `json:"operator"`
// 素币事务记录描述
RecordDescription string `json:"recordDescription"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
type SuMoneyTransactionRecordRepository interface {
Save(suMoneyTransactionRecord *SuMoneyTransactionRecord) (*SuMoneyTransactionRecord, error)
Remove(suMoneyTransactionRecord *SuMoneyTransactionRecord) (*SuMoneyTransactionRecord, error)
FindOne(queryOptions map[string]interface{}) (*SuMoneyTransactionRecord, error)
Find(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error)
}
func (suMoneyTransactionRecord *SuMoneyTransactionRecord) Identify() interface{} {
if suMoneyTransactionRecord.SuMoneyTransactionRecordId == 0 {
return nil
}
return suMoneyTransactionRecord.SuMoneyTransactionRecordId
}
\ No newline at end of file
... ...
... ... @@ -29,6 +29,7 @@ func init() {
(*models.BidInfo)(nil),
(*models.Task)(nil),
(*models.OffTaskRecord)(nil),
(*models.SuMoneyTransactionRecord)(nil),
} {
err := DB.CreateTable(model, &orm.CreateTableOptions{
Temp: false,
... ...
package models
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type SuMoneyTransactionRecord struct {
TableName string `pg:"su_money_transaction_records,alias:su_money_transaction_record"`
// 素币事务记录ID
Id int64 `pg:",pk"`
// 记录类型
RecordType int
// 记录关联员工
Employee *domain.EmployeeInfo
// 事务素币值
SuMoney float64
// 操作人
Operator int64
// 素币事务记录描述
RecordDescription string
// 创建时间
CreateTime time.Time
}
... ...
package repository
import (
"fmt"
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
)
type SuMoneyTransactionRecordRepository struct {
transactionContext *pgTransaction.TransactionContext
}
func (repository *SuMoneyTransactionRecordRepository) nextIdentify() (int64, error) {
return 0, nil
}
func (repository *SuMoneyTransactionRecordRepository) Save(suMoneyTransactionRecord *domain.SuMoneyTransactionRecord) (*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
if suMoneyTransactionRecord.Identify() == nil {
_, err := repository.nextIdentify()
if err != nil {
return suMoneyTransactionRecord, err
}
if _, err := tx.QueryOne(
pg.Scan(&suMoneyTransactionRecord.SuMoneyTransactionRecordId, &suMoneyTransactionRecord.RecordType, &suMoneyTransactionRecord.Employee, &suMoneyTransactionRecord.SuMoney, &suMoneyTransactionRecord.Operator, &suMoneyTransactionRecord.RecordDescription, &suMoneyTransactionRecord.CreateTime),
"INSERT INTO su_money_transaction_records (id, record_type, employee, su_money, operator, record_description, create_time) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING su_money_transaction_record_id, record_type, employee, su_money, operator, record_description, create_time",
suMoneyTransactionRecord.SuMoneyTransactionRecordId, suMoneyTransactionRecord.RecordType, suMoneyTransactionRecord.Employee, suMoneyTransactionRecord.SuMoney, suMoneyTransactionRecord.Operator, suMoneyTransactionRecord.RecordDescription, suMoneyTransactionRecord.CreateTime); err != nil {
return suMoneyTransactionRecord, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&suMoneyTransactionRecord.SuMoneyTransactionRecordId, &suMoneyTransactionRecord.RecordType, &suMoneyTransactionRecord.Employee, &suMoneyTransactionRecord.SuMoney, &suMoneyTransactionRecord.Operator, &suMoneyTransactionRecord.RecordDescription, &suMoneyTransactionRecord.CreateTime),
"UPDATE su_money_transaction_records SET record_type=?, employee=?, su_money=?, operator=?, record_description=?, create_time=? WHERE id=? RETURNING su_money_transaction_record_id, record_type, employee, su_money, operator, record_description, create_time",
suMoneyTransactionRecord.RecordType, suMoneyTransactionRecord.Employee, suMoneyTransactionRecord.SuMoney, suMoneyTransactionRecord.Operator, suMoneyTransactionRecord.RecordDescription, suMoneyTransactionRecord.CreateTime, suMoneyTransactionRecord.SuMoneyTransactionRecordId); err != nil {
return suMoneyTransactionRecord, err
}
}
return suMoneyTransactionRecord, nil
}
func (repository *SuMoneyTransactionRecordRepository) Remove(suMoneyTransactionRecord *domain.SuMoneyTransactionRecord) (*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
suMoneyTransactionRecordModel.Id = suMoneyTransactionRecord.Identify().(int64)
if _, err := tx.Model(suMoneyTransactionRecordModel).WherePK().Delete(); err != nil {
return suMoneyTransactionRecord, err
}
return suMoneyTransactionRecord, nil
}
func (repository *SuMoneyTransactionRecordRepository) FindOne(queryOptions map[string]interface{}) (*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
query := tx.Model(suMoneyTransactionRecordModel)
if suMoneyTransactionRecordId, ok := queryOptions["suMoneyTransactionRecordId"]; ok {
query = query.Where("su_money_transaction_record.id = ?", suMoneyTransactionRecordId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
} else {
return nil, err
}
}
if suMoneyTransactionRecordModel.Id == 0 {
return nil, nil
} else {
return repository.transformPgModelToDomainModel(suMoneyTransactionRecordModel)
}
}
func (repository *SuMoneyTransactionRecordRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
var suMoneyTransactionRecordModels []*models.SuMoneyTransactionRecord
suMoneyTransactionRecords := make([]*domain.SuMoneyTransactionRecord, 0)
query := tx.Model(&suMoneyTransactionRecordModels)
if employeeUid, ok := queryOptions["employeeUid"]; ok && (employeeUid != int64(0)) {
query = query.Where(`task.employee @> '{"uid":?}'`, employeeUid)
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
query = query.Offset(offset)
}
} else {
query = query.Offset(0)
}
if limit, ok := queryOptions["limit"]; ok {
limit := limit.(int)
if limit > -1 {
query = query.Limit(limit)
}
} else {
query = query.Limit(20)
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
return 0, suMoneyTransactionRecords, err
} else {
for _, suMoneyTransactionRecordModel := range suMoneyTransactionRecordModels {
if suMoneyTransactionRecord, err := repository.transformPgModelToDomainModel(suMoneyTransactionRecordModel); err != nil {
return 0, suMoneyTransactionRecords, err
} else {
suMoneyTransactionRecords = append(suMoneyTransactionRecords, suMoneyTransactionRecord)
}
suMoneyTransactionRecords = append(suMoneyTransactionRecords, &domain.SuMoneyTransactionRecord{})
}
return int64(count), suMoneyTransactionRecords, nil
}
}
func (repository *SuMoneyTransactionRecordRepository) transformPgModelToDomainModel(suMoneyTransactionRecordModel *models.SuMoneyTransactionRecord) (*domain.SuMoneyTransactionRecord, error) {
return &domain.SuMoneyTransactionRecord{
SuMoneyTransactionRecordId: suMoneyTransactionRecordModel.Id,
RecordType: suMoneyTransactionRecordModel.RecordType,
Employee: suMoneyTransactionRecordModel.Employee,
SuMoney: suMoneyTransactionRecordModel.SuMoney,
Operator: suMoneyTransactionRecordModel.Operator,
RecordDescription: suMoneyTransactionRecordModel.RecordDescription,
CreateTime: suMoneyTransactionRecordModel.CreateTime,
}, nil
}
func NewSuMoneyTransactionRecordRepository(transactionContext *pgTransaction.TransactionContext) (*SuMoneyTransactionRecordRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &SuMoneyTransactionRecordRepository{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -25,10 +25,10 @@ func (controller *ConfigController) ListTaskStatus() {
controller.ServeJSON()
}
func (controller *ConfigController) ListTaskTypes() {
func (controller *ConfigController) ListTaskType() {
configService := service.NewConfigService(nil)
listTaskTypesQuery := &query.ListTaskTypesQuery{}
data, err := configService.ListTaskTypes(listTaskTypesQuery)
listTaskTypeQuery := &query.ListTaskTypeQuery{}
data, err := configService.ListTaskType(listTaskTypeQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
... ... @@ -39,10 +39,10 @@ func (controller *ConfigController) ListTaskTypes() {
controller.ServeJSON()
}
func (controller *ConfigController) ListTaskNatures() {
func (controller *ConfigController) ListTaskNature() {
configService := service.NewConfigService(nil)
listTaskNaturesQuery := &query.ListTaskNaturesQuery{}
data, err := configService.ListTaskNatures(listTaskNaturesQuery)
listTaskNatureQuery := &query.ListTaskNatureQuery{}
data, err := configService.ListTaskNature(listTaskNatureQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
... ... @@ -53,10 +53,38 @@ func (controller *ConfigController) ListTaskNatures() {
controller.ServeJSON()
}
func (controller *ConfigController) ListCustomerValues() {
func (controller *ConfigController) ListCustomerValue() {
configService := service.NewConfigService(nil)
listCustomerValuesQuery := &query.ListCustomerValuesQuery{}
data, err := configService.ListCustomerValues(listCustomerValuesQuery)
listCustomerValueQuery := &query.ListCustomerValueQuery{}
data, err := configService.ListCustomerValue(listCustomerValueQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
func (controller *ConfigController) ListReferenceResourceType() {
configService := service.NewConfigService(nil)
listReferenceResourceTypeQuery := &query.ListReferenceResourceTypeQuery{}
data, err := configService.ListReferenceResourceType(listReferenceResourceTypeQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
func (controller *ConfigController) ListBidTimeMatch() {
configService := service.NewConfigService(nil)
listBidTimeMatchQuery := &query.ListBidTimeMatchQuery{}
data, err := configService.ListBidTimeMatch(listBidTimeMatchQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
... ...
... ... @@ -7,7 +7,9 @@ import (
func init() {
beego.Router("/config/task-statuses", &controllers.ConfigController{}, "Get:ListTaskStatus")
beego.Router("/config/task-types", &controllers.ConfigController{}, "Get:ListTaskTypes")
beego.Router("/config/task-natures", &controllers.ConfigController{}, "Get:ListTaskNatures")
beego.Router("/config/customer-values", &controllers.ConfigController{}, "Get:ListCustomerValues")
beego.Router("/config/task-types", &controllers.ConfigController{}, "Get:ListTaskType")
beego.Router("/config/task-natures", &controllers.ConfigController{}, "Get:ListTaskNature")
beego.Router("/config/customer-values", &controllers.ConfigController{}, "Get:ListCustomerValue")
beego.Router("/config/reference-resource-types", &controllers.ConfigController{}, "Get:ListReferenceResourceType")
beego.Router("/config/bid-time-matchs", &controllers.ConfigController{}, "Get:ListBidTimeMatch")
}
... ...
package config
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
)
var _ = Describe("返回竞标时间字典列表(1全部,2已截止,3未截止)", func() {
Describe("返回竞标时间字典列表(1全部,2已截止,3未截止)", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/config/bid-time-matchs").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
})
... ...
package config
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
)
var _ = Describe("返回任务引用资源类型字典列表", func() {
Describe("返回任务引用资源类型字典列表", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/config/reference-resource-types").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
})
... ...