作者 linmadan

添加配置字典api

... ... @@ -18,6 +18,90 @@
"application/xml"
],
"paths": {
"/config/customer-values": {
"get": {
"tags": [
"config"
],
"summary": "返回客户价值列表",
"description": "返回客户价值列表",
"operationId": "config#listCustomerValues",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListCustomerValuesResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/config/task-natures": {
"get": {
"tags": [
"config"
],
"summary": "返回任务性质列表",
"description": "返回任务性质列表",
"operationId": "config#listTaskNatures",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListTaskNaturesResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/config/task-statuses": {
"get": {
"tags": [
"config"
],
"summary": "返回任务状态列表",
"description": "返回任务状态列表",
"operationId": "config#listTaskStatus",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListTaskStatusResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/config/task-types": {
"get": {
"tags": [
"config"
],
"summary": "返回任务类型列表",
"description": "返回任务类型列表",
"operationId": "config#listTaskTypes",
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/ConfigListTaskTypesResponseBody"
}
}
},
"schemes": [
"http"
]
}
},
"/employees": {
"get": {
"tags": [
... ... @@ -714,9 +798,88 @@
"http"
]
}
},
"/tasks/search-off-task-record": {
"post": {
"tags": [
"task"
],
"summary": "搜索关闭任务记录",
"description": "搜索关闭任务记录",
"operationId": "task#searchOffTaskRecord",
"parameters": [
{
"name": "SearchOffTaskRecordRequestBody",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TaskSearchOffTaskRecordRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK response.",
"schema": {
"$ref": "#/definitions/TaskSearchOffTaskRecordResponseBody"
}
}
},
"schemes": [
"http"
]
}
}
},
"definitions": {
"ConfigListCustomerValuesResponseBody": {
"title": "Mediatype identifier: ConfigListCustomerValuesResponseBody",
"type": "object",
"properties": {
"customerValues": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"ConfigListTaskNaturesResponseBody": {
"title": "Mediatype identifier: ConfigListTaskNaturesResponseBody",
"type": "object",
"properties": {
"taskNatures": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"ConfigListTaskStatusResponseBody": {
"title": "Mediatype identifier: ConfigListTaskStatusResponseBody",
"type": "object",
"properties": {
"taskStatuses": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"ConfigListTaskTypesResponseBody": {
"title": "Mediatype identifier: ConfigListTaskTypesResponseBody",
"type": "object",
"properties": {
"taskTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/configResponseBody"
}
}
}
},
"EmployeeCreateEmployeeRequestBody": {
"title": "EmployeeCreateEmployeeRequestBody",
"type": "object",
... ... @@ -1133,6 +1296,73 @@
}
}
},
"TaskSearchOffTaskRecordRequestBody": {
"title": "TaskSearchOffTaskRecordRequestBody",
"type": "object",
"properties": {
"companyId": {
"type": "integer",
"description": "公司ID",
"required": [
"companyId"
]
},
"customerValue": {
"type": "string",
"description": "客户价值"
},
"limit": {
"type": "integer",
"description": "查询限制",
"format": "int64"
},
"offEndTime": {
"type": "string",
"description": "关闭任务时间区间-截止时间",
"format": "datetime"
},
"offStartTime": {
"type": "string",
"description": "关闭任务时间区间-开始时间",
"format": "datetime"
},
"offset": {
"type": "integer",
"description": "查询偏离量",
"format": "int64"
},
"taskContentMatch": {
"type": "string",
"description": "任务内容匹配"
},
"taskNature": {
"type": "string",
"description": "任务性质"
},
"taskType": {
"type": "integer",
"description": "任务类型",
"format": "int64"
}
}
},
"TaskSearchOffTaskRecordResponseBody": {
"title": "Mediatype identifier: TaskSearchOffTaskRecordResponseBody",
"type": "object",
"properties": {
"count": {
"type": "integer",
"description": "结果总数",
"format": "int64"
},
"offTaskRecords": {
"type": "array",
"items": {
"$ref": "#/definitions/offTaskRecordResponseBody"
}
}
}
},
"TaskSearchTaskRequestBody": {
"title": "TaskSearchTaskRequestBody",
"type": "object",
... ... @@ -1341,6 +1571,27 @@
},
"description": "竞标人员信息"
},
"configResponseBody": {
"title": "configResponseBody",
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "ID",
"required": [
"id"
]
},
"name": {
"type": "string",
"description": "名称",
"required": [
"name"
]
}
},
"description": "配置字典"
},
"employeeInfoRequestBody": {
"title": "employeeInfoRequestBody",
"type": "object",
... ... @@ -1427,6 +1678,40 @@
},
"description": "员工"
},
"offTaskRecordResponseBody": {
"title": "offTaskRecordResponseBody",
"type": "object",
"properties": {
"createTime": {
"type": "string",
"description": "创建时间",
"required": [
"createTime"
]
},
"offReason": {
"type": "string",
"description": "关闭理由",
"required": [
"offReason"
]
},
"offTaskRecordId": {
"type": "integer",
"description": "关闭任务记录ID",
"required": [
"offTaskRecordId"
]
},
"operator": {
"$ref": "#/definitions/employeeInfoResponseBody"
},
"task": {
"$ref": "#/definitions/taskResponseBody"
}
},
"description": "关闭任务记录"
},
"referenceResourceItemRequestBody": {
"title": "referenceResourceItemRequestBody",
"type": "object",
... ...
... ... @@ -5,7 +5,6 @@ info:
contact:
name: linmadan
email: 772181827@qq.com
home: www.madannet.com
version: 0.0.1
consumes:
- application/json
... ... @@ -14,6 +13,62 @@ produces:
- application/json
- application/xml
paths:
/config/customer-values:
get:
tags:
- config
summary: 返回客户价值列表
description: 返回客户价值列表
operationId: config#listCustomerValues
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListCustomerValuesResponseBody'
schemes:
- http
/config/task-natures:
get:
tags:
- config
summary: 返回任务性质列表
description: 返回任务性质列表
operationId: config#listTaskNatures
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListTaskNaturesResponseBody'
schemes:
- http
/config/task-statuses:
get:
tags:
- config
summary: 返回任务状态列表
description: 返回任务状态列表
operationId: config#listTaskStatus
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListTaskStatusResponseBody'
schemes:
- http
/config/task-types:
get:
tags:
- config
summary: 返回任务类型列表
description: 返回任务类型列表
operationId: config#listTaskTypes
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/ConfigListTaskTypesResponseBody'
schemes:
- http
/employees:
get:
tags:
... ... @@ -481,7 +536,59 @@ paths:
$ref: '#/definitions/TaskSearchTaskResponseBody'
schemes:
- http
/tasks/search-off-task-record:
post:
tags:
- task
summary: 搜索关闭任务记录
description: 搜索关闭任务记录
operationId: task#searchOffTaskRecord
parameters:
- name: SearchOffTaskRecordRequestBody
in: body
required: true
schema:
$ref: '#/definitions/TaskSearchOffTaskRecordRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/TaskSearchOffTaskRecordResponseBody'
schemes:
- http
definitions:
ConfigListCustomerValuesResponseBody:
title: 'Mediatype identifier: ConfigListCustomerValuesResponseBody'
type: object
properties:
customerValues:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskNaturesResponseBody:
title: 'Mediatype identifier: ConfigListTaskNaturesResponseBody'
type: object
properties:
taskNatures:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskStatusResponseBody:
title: 'Mediatype identifier: ConfigListTaskStatusResponseBody'
type: object
properties:
taskStatuses:
type: array
items:
$ref: '#/definitions/configResponseBody'
ConfigListTaskTypesResponseBody:
title: 'Mediatype identifier: ConfigListTaskTypesResponseBody'
type: object
properties:
taskTypes:
type: array
items:
$ref: '#/definitions/configResponseBody'
EmployeeCreateEmployeeRequestBody:
title: EmployeeCreateEmployeeRequestBody
type: object
... ... @@ -772,6 +879,56 @@ definitions:
properties:
task:
$ref: '#/definitions/taskResponseBody'
TaskSearchOffTaskRecordRequestBody:
title: TaskSearchOffTaskRecordRequestBody
type: object
properties:
companyId:
type: integer
description: 公司ID
required:
- companyId
customerValue:
type: string
description: 客户价值
limit:
type: integer
description: 查询限制
format: int64
offEndTime:
type: string
description: 关闭任务时间区间-截止时间
format: datetime
offStartTime:
type: string
description: 关闭任务时间区间-开始时间
format: datetime
offset:
type: integer
description: 查询偏离量
format: int64
taskContentMatch:
type: string
description: 任务内容匹配
taskNature:
type: string
description: 任务性质
taskType:
type: integer
description: 任务类型
format: int64
TaskSearchOffTaskRecordResponseBody:
title: 'Mediatype identifier: TaskSearchOffTaskRecordResponseBody'
type: object
properties:
count:
type: integer
description: 结果总数
format: int64
offTaskRecords:
type: array
items:
$ref: '#/definitions/offTaskRecordResponseBody'
TaskSearchTaskRequestBody:
title: TaskSearchTaskRequestBody
type: object
... ... @@ -925,6 +1082,21 @@ definitions:
bidder:
$ref: '#/definitions/employeeInfoResponseBody'
description: 竞标人员信息
configResponseBody:
title: configResponseBody
type: object
properties:
id:
type: integer
description: ID
required:
- id
name:
type: string
description: 名称
required:
- name
description: 配置字典
employeeInfoRequestBody:
title: employeeInfoRequestBody
type: object
... ... @@ -987,6 +1159,30 @@ definitions:
required:
- suMoney
description: 员工
offTaskRecordResponseBody:
title: offTaskRecordResponseBody
type: object
properties:
createTime:
type: string
description: 创建时间
required:
- createTime
offReason:
type: string
description: 关闭理由
required:
- offReason
offTaskRecordId:
type: integer
description: 关闭任务记录ID
required:
- offTaskRecordId
operator:
$ref: '#/definitions/employeeInfoResponseBody'
task:
$ref: '#/definitions/taskResponseBody'
description: 关闭任务记录
referenceResourceItemRequestBody:
title: referenceResourceItemRequestBody
type: object
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListCustomerValuesQuery struct {
}
func (listCustomerValuesQuery *ListCustomerValuesQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listCustomerValuesQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListTaskNaturesQuery struct {
}
func (listTaskNaturesQuery *ListTaskNaturesQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskNaturesQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListTaskStatusQuery struct {
}
func (listTaskStatusQuery *ListTaskStatusQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskStatusQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListTaskTypesQuery struct {
}
func (listTaskTypesQuery *ListTaskTypesQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listTaskTypesQuery)
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/config/query"
)
// 配置服务
type ConfigService struct {
}
// 返回任务状态列表
func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.ListTaskStatusQuery) (interface{}, error) {
if err := listTaskStatusQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskStatuses := map[int]string{
1: "待发布",
2: "待领取",
3: "进行中",
4: "待验收",
5: "已完成",
}
return map[string]interface{}{
"taskStatuses": taskStatuses,
}, nil
}
// 返回任务类型列表
func (configService *ConfigService) ListTaskTypes(listTaskTypesQuery *query.ListTaskTypesQuery) (interface{}, error) {
if err := listTaskTypesQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskTypes := map[int]string{
1: "抢单任务",
2: "竞标任务",
}
return map[string]interface{}{
"taskTypes": taskTypes,
}, nil
}
// 返回任务性质列表
func (configService *ConfigService) ListTaskNatures(listTaskNaturesQuery *query.ListTaskNaturesQuery) (interface{}, error) {
if err := listTaskNaturesQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
taskNatures := map[int]string{
1: "点",
2: "线",
3: "面",
4: "链",
5: "网",
}
return map[string]interface{}{
"taskNatures": taskNatures,
}, nil
}
// 返回客户价值列表
func (configService *ConfigService) ListCustomerValues(listCustomerValuesQuery *query.ListCustomerValuesQuery) (interface{}, error) {
if err := listCustomerValuesQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
customerValues := map[int]string{
1: "口味",
2: "口感",
3: "色泽",
4: "卖相",
5: "包装",
6: "储存",
7: "运输",
8: "价格",
9: "应用",
10: "便利",
11: "交期",
12: "数量",
13: "账期",
14: "品质",
15: "新鲜度",
16: "推广",
17: "规格",
18: "人情关系",
19: "商务服务",
20: "售后服务",
21: "新品",
22: "品牌",
23: "合同",
}
return map[string]interface{}{
"customerValues": customerValues,
}, nil
}
func NewConfigService(options map[string]interface{}) *ConfigService {
newConfigService := &ConfigService{}
return newConfigService
}
... ...
package controllers
import (
"github.com/astaxie/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/config/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/config/service"
)
type ConfigController struct {
beego.Controller
}
func (controller *ConfigController) ListTaskStatus() {
configService := service.NewConfigService(nil)
listTaskStatusQuery := &query.ListTaskStatusQuery{}
data, err := configService.ListTaskStatus(listTaskStatusQuery)
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) ListTaskTypes() {
configService := service.NewConfigService(nil)
listTaskTypesQuery := &query.ListTaskTypesQuery{}
data, err := configService.ListTaskTypes(listTaskTypesQuery)
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) ListTaskNatures() {
configService := service.NewConfigService(nil)
listTaskNaturesQuery := &query.ListTaskNaturesQuery{}
data, err := configService.ListTaskNatures(listTaskNaturesQuery)
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) ListCustomerValues() {
configService := service.NewConfigService(nil)
listCustomerValuesQuery := &query.ListCustomerValuesQuery{}
data, err := configService.ListCustomerValues(listCustomerValuesQuery)
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()
}
... ...
package routers
import (
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego/controllers"
)
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")
}
... ...
package config
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/astaxie/beego"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
)
func TestConfig(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port Config Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = beego.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
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/customer-values").
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/task-natures").
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/task-statuses").
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/task-types").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
})
... ...