Documentation ¶
Index ¶
- Constants
- Variables
- func BadRequestResponse(ctx echo.Context, message string) error
- func BuildCommonRequestFilterParams(filter string) map[string]interface{}
- func ContainsValueFunc(field, value string) (string, interface{})
- func EqualValueFunc(field, value string) (string, interface{})
- func ErrorResponse(ctx echo.Context, errorCode int, errorMessage string) error
- func ForbiddenResponse(ctx echo.Context) error
- func GetHTTPCustomMessage(code int) string
- func GetQueryIsDeleted(query map[string]interface{}) bool
- func HTTPErrorHandler(err error, c echo.Context)
- func HandleFunc(handler func(ctx *Context) error) func(ctx echo.Context) error
- func LikeValueFunc(field, value string) (string, interface{})
- func NotFoundResponse(ctx echo.Context) error
- func QuerySetAfterAddOrder(tx *gorm.DB, order ...string) *gorm.DB
- func QuerySetAfterAddPreload(tx *gorm.DB, preload ...string) *gorm.DB
- func Response(ctx echo.Context, code int, data CommonResponse) error
- func ServerInternalErrorResponse(ctx echo.Context, errMessage string) error
- func SuccessNoContentResponse(ctx echo.Context) error
- func SuccessResponse(ctx echo.Context, result interface{}) error
- func UnauthorizedResponse(ctx echo.Context) error
- type CommonRequestParams
- type CommonResponse
- type Context
- func (c *Context) BindValidBody(payload interface{}) error
- func (c *Context) CurrentUser() (*models.User, error)
- func (c *Context) CurrentUsername() string
- func (c *Context) GetCurrentUserId() (string, error)
- func (c *Context) GetParamInt(key string) (int64, error)
- func (c *Context) GetRequestBody() (map[string]interface{}, error)
- func (c *Context) GetRequestDomain() string
- func (c *Context) GetUserLoginKey() (string, error)
- func (c *Context) GetUserMap() map[string]interface{}
- func (c *Context) ParseInt(key string) int64
- type ResponseContent
- type Serializers
- type SerializersField
- type SerializersManager
- type SerializersParams
- type Validator
- type ValidatorHandFunc
Constants ¶
View Source
const ( HTTP200Code = 200 HTTP201Code = 201 HTTP204Code = 204 HTTP301Code = 301 HTTP302Code = 302 HTTP400Code = 400 HTTP401Code = 401 HTTP403Code = 403 HTTP404Code = 404 HTTP405Code = 405 HTTP500Code = 500 HTTP502Code = 502 HTTP503Code = 503 HTTP504Code = 504 )
View Source
const ( HTTP200Message = "Success" HTTP201Message = "Created" HTTP204Message = "No Content" HTTP301Message = "Permanent Redirect" HTTP302Message = "Temporary Redirect" HTTP400Message = "Bad Request" HTTP401Message = "Unauthorized" HTTP403Message = "Do not have permission to access this resource" HTTP404Message = "Not Found" HTTP405Message = "Request Method Not Allowed" HTTP500Message = "Internal Server Error" HTTP502Message = "Bad Gateway" HTTP503Message = "Service Is Not Available" HTTP504Message = "Gateway Timeout" UserAccountError = "Incorrect username or password" DataAlreadyExists = "Data already exists" InvalidInstanceId = "Invalid instance id" DataNotFound = "Data not retrieved in database" ProductLineListInvalid = "ProductLines id list invalid" InstanceAlreadyDelete = "The instance has been deleted and cannot be modified" CustomValidatorValidError = "Custom validator validation error" TicketStateFlowIsZero = "Ticket state flow count is zero" TicketStateFlowIncomplete = "Ticket state flow incomplete" TicketRecordIsDiscard = "Ticket record is discard" TicketInvalidApprovalType = "Invalid ticket node approval type" TicketWorkflowNodeStateNoComplete = "Not a complete workflow node" TicketRecordAlreadyUrge = "The current process node has been urged" TicketRecordNotAllowDiscard = "The current work order status does not allow abandonment" TicketRecordNoProcess = "The current work order is not in the process" DutyRosterMonthRangeError = "The month range exceeds the system-defined date" DutyRosterMonthCompareError = "Anomalies occur when comparing months" NoHistoryDrawLottery = "There is no historical lottery record" )
View Source
const ( LikeExpressionEnum = "LIKE" EqualExpressionEnum = "EQUAL" ContainsExpressionEnum = "IN" )
Variables ¶
View Source
var ( ProviderFieldFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "alias", Type: LikeExpressionEnum, }, { Field: "creator", Type: LikeExpressionEnum, }, } FactoryFieldFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "modeName", Type: LikeExpressionEnum, Column: "mode_name", }, { Field: "enName", Type: LikeExpressionEnum, Column: "en_name", }, { Field: "cnName", Type: LikeExpressionEnum, Column: "cn_name", }, } SuitFieldFilterCondition = []SerializersField{ { Field: "season", Type: LikeExpressionEnum, }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "name", Type: LikeExpressionEnum, }, } SuitNameFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, } AzFieldFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "cnName", Type: LikeExpressionEnum, Column: "cn_name", }, { Field: "region", Type: EqualExpressionEnum, }, { Field: "province", Type: EqualExpressionEnum, }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "multiSearchName", Type: ContainsExpressionEnum, Column: "name", }, { Field: "multiSearchCnName", Type: ContainsExpressionEnum, Column: "cn_name", }, } IdcFieldFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "cnName", Type: LikeExpressionEnum, Column: "cn_name", }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "address", Type: EqualExpressionEnum, }, { Field: "region", Type: EqualExpressionEnum, }, { Field: "city", Type: EqualExpressionEnum, }, { Field: "idcPhone", Type: LikeExpressionEnum, Column: "idc_phone", }, { Field: "idcMail", Type: LikeExpressionEnum, Column: "idc_mail", }, { Field: "virtualAzId", Type: EqualExpressionEnum, Column: "virtual_az_id", }, { Field: "physicsAzId", Type: EqualExpressionEnum, Column: "physics_az_id", }, } IdcRoomFilterCondition = []SerializersField{ { Field: "roomName", Type: LikeExpressionEnum, Column: "room_name", }, { Field: "idcId", Type: EqualExpressionEnum, Column: "idc_id", }, { Field: "pduStandard", Type: EqualExpressionEnum, Column: "pdu_standard", }, { Field: "powerMode", Type: EqualExpressionEnum, Column: "power_mode", }, { Field: "rackSize", Type: EqualExpressionEnum, Column: "rack_size", }, { Field: "bearerType", Type: EqualExpressionEnum, Column: "bearer_type", }, { Field: "bearWeight", Type: EqualExpressionEnum, Column: "bear_weight", }, { Field: "status", Type: EqualExpressionEnum, }, } IdcRackFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "idcRoomId", Type: EqualExpressionEnum, Column: "idc_room_id", }, { Field: "status", Type: EqualExpressionEnum, }, } IdcRackSlotFilterCondition = []SerializersField{ { Field: "idcRackId", Type: EqualExpressionEnum, Column: "idc_rack_id", }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "status", Type: EqualExpressionEnum, }, } AuditOperateFilterCondition = []SerializersField{ { Field: "username", Type: LikeExpressionEnum, }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "resourceName", Type: LikeExpressionEnum, Column: "resource_name", }, } AuditUserLoginFilterCondition = []SerializersField{ { Field: "username", Type: LikeExpressionEnum, }, { Field: "type", Type: EqualExpressionEnum, }, } ServerFilterCondition = []SerializersField{ { Field: "sn", Type: LikeExpressionEnum, }, { Field: "hostname", Type: LikeExpressionEnum, }, { Field: "type", Type: ContainsExpressionEnum, }, { Field: "suitId", Type: EqualExpressionEnum, Column: "suit_id", }, { Field: "role", Type: EqualExpressionEnum, }, { Field: "operator", Type: EqualExpressionEnum, }, { Field: "providerId", Type: EqualExpressionEnum, Column: "provider_id", }, { Field: "factoryId", Type: EqualExpressionEnum, Column: "factory_id", }, { Field: "nodeId", Type: EqualExpressionEnum, Column: "node_id", }, { Field: "idcRackSlotId", Type: EqualExpressionEnum, Column: "idc_rack_slot_id", }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "appEnv", Type: EqualExpressionEnum, Column: "app_env", }, { Field: "privNetIp", Type: LikeExpressionEnum, Column: "priv_net_ip", }, { Field: "pubNetIp", Type: LikeExpressionEnum, Column: "pub_net_ip", }, { Field: "mgmtPortIp", Type: LikeExpressionEnum, Column: "mgmt_port_ip", }, { Field: "creator", Type: LikeExpressionEnum, }, { Field: "isDeleted", Type: EqualExpressionEnum, Column: "is_deleted", }, { Field: "multiSearchFieldSn", Type: ContainsExpressionEnum, Column: "sn", }, { Field: "multiSearchFieldHostname", Type: ContainsExpressionEnum, Column: "hostname", }, { Field: "multiSearchFieldPubIp", Type: ContainsExpressionEnum, Column: "pub_net_ip", }, { Field: "multiSearchFieldPrivIp", Type: ContainsExpressionEnum, Column: "priv_net_ip", }, { Field: "multiSearchFieldMgmtIp", Type: ContainsExpressionEnum, Column: "mgmt_port_ip", }, } IpRangeFilterCondition = []SerializersField{ { Field: "cidr", Type: LikeExpressionEnum, }, { Field: "env", Type: EqualExpressionEnum, }, { Field: "version", Type: EqualExpressionEnum, }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "operator", Type: EqualExpressionEnum, }, { Field: "nodeId", Type: EqualExpressionEnum, Column: "node_id", }, { Field: "type", Type: EqualExpressionEnum, }, } NetIpFilterCondition = []SerializersField{ { Field: "ipRangeId", Type: EqualExpressionEnum, Column: "ip_range_id", }, { Field: "ip", Type: LikeExpressionEnum, }, { Field: "netmask", Type: LikeExpressionEnum, }, { Field: "gateway", Type: LikeExpressionEnum, }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "version", Type: EqualExpressionEnum, }, { Field: "env", Type: EqualExpressionEnum, }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "operator", Type: EqualExpressionEnum, }, { Field: "multiSearchFieldIp", Type: ContainsExpressionEnum, Column: "ip", }, } NetSwitchFilterCondition = []SerializersField{ { Field: "status", Type: EqualExpressionEnum, }, { Field: "sn", Type: LikeExpressionEnum, }, { Field: "rackSlotId", Type: EqualExpressionEnum, Column: "idc_rack_slot_id", }, { Field: "factoryId", Type: EqualExpressionEnum, Column: "factory_id", }, { Field: "ipNetId", Type: EqualExpressionEnum, Column: "ip_net_Id", }, { Field: "nodeId", Type: EqualExpressionEnum, Column: "node_id", }, { Field: "type", Type: EqualExpressionEnum, }, { Field: "name", Type: LikeExpressionEnum, }, } NetRouterFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "status", Type: EqualExpressionEnum, }, { Field: "sn", Type: LikeExpressionEnum, }, { Field: "rackSlotId", Type: EqualExpressionEnum, Column: "idc_rack_slot_id", }, { Field: "factoryId", Type: EqualExpressionEnum, Column: "factory_id", }, { Field: "ipNetId", Type: EqualExpressionEnum, Column: "ip_net_Id", }, { Field: "nodeId", Type: EqualExpressionEnum, Column: "node_id", }, } TicketNodeStateFilterCondition = []SerializersField{ { Field: "categoryId", Type: EqualExpressionEnum, Column: "category_id", }, { Field: "approvalType", Type: EqualExpressionEnum, Column: "approval_type", }, { Field: "stateName", Type: LikeExpressionEnum, Column: "state_name", }, { Field: "participantType", Type: LikeExpressionEnum, Column: "participant_type", }, { Field: "hiddenState", Type: EqualExpressionEnum, Column: "hidden_state", }, { Field: "participantType", Type: EqualExpressionEnum, Column: "participant_type", }, } TicketProductFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "allowedVisibilityGroups", Type: LikeExpressionEnum, Column: "allowed_visibility_groups", }, } TicketCategoryFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, { Field: "allowedVisibilityGroups", Type: LikeExpressionEnum, Column: "allowed_visibility_groups", }, { Field: "snRuleIdentifier", Type: LikeExpressionEnum, Column: "sn_rule_identifier", }, } TicketWorkflowWikiFilterCondition = []SerializersField{ { Field: "name", Type: LikeExpressionEnum, }, } TicketWorkflowCustomFormFilterCondition = []SerializersField{ { Field: "fieldType", Type: EqualExpressionEnum, Column: "field_type", }, { Field: "fieldKey", Type: LikeExpressionEnum, Column: "field_key", }, { Field: "fieldLabel", Type: LikeExpressionEnum, Column: "field_label", }, } TicketWorkflowTransitionFilterCondition = []SerializersField{ { Field: "buttonName", Type: EqualExpressionEnum, Column: "button_name", }, { Field: "buttonType", Type: EqualExpressionEnum, Column: "button_type", }, { Field: "targetWorkflowStateId", Type: EqualExpressionEnum, Column: "target_workflow_state_id", }, { Field: "currentWorkflowStateId", Type: EqualExpressionEnum, Column: "current_workflow_state_id", }, { Field: "categoryId", Type: EqualExpressionEnum, Column: "category_id", }, } TicketRecordFilterCondition = []SerializersField{ { Field: "sn", Type: LikeExpressionEnum, Column: "sn", }, { Field: "stateId", Type: EqualExpressionEnum, Column: "state_id", }, { Field: "categoryId", Type: EqualExpressionEnum, Column: "category_id", }, { Field: "status", Type: EqualExpressionEnum, Column: "status", }, { Field: "creator", Type: LikeExpressionEnum, Column: "creator", }, } TicketFlowLogFilterCondition = []SerializersField{ { Field: "id", Type: EqualExpressionEnum, }, { Field: "stateName", Type: ContainsExpressionEnum, Column: "workflow_node", }, { Field: "recordId", Type: EqualExpressionEnum, Column: "ticket_workflow_record_id", }, } )
View Source
var ExpressionValueMapping = map[string]func(field string, value string) (string, interface{}){ LikeExpressionEnum: LikeValueFunc, EqualExpressionEnum: EqualValueFunc, ContainsExpressionEnum: ContainsValueFunc, }
Functions ¶
func BadRequestResponse ¶
func ContainsValueFunc ¶
func EqualValueFunc ¶
func ErrorResponse ¶
func ForbiddenResponse ¶
func ForbiddenResponse(ctx echo.Context) error
func GetHTTPCustomMessage ¶
func GetQueryIsDeleted ¶
func HTTPErrorHandler ¶
func HTTPErrorHandler(err error, c echo.Context)
func HandleFunc ¶
func LikeValueFunc ¶
func NotFoundResponse ¶
func NotFoundResponse(ctx echo.Context) error
func QuerySetAfterAddPreload ¶
func Response ¶
func Response(ctx echo.Context, code int, data CommonResponse) error
func SuccessNoContentResponse ¶
func SuccessNoContentResponse(ctx echo.Context) error
func SuccessResponse ¶
func SuccessResponse(ctx echo.Context, result interface{}) error
func UnauthorizedResponse ¶
func UnauthorizedResponse(ctx echo.Context) error
Types ¶
type CommonRequestParams ¶
type CommonRequestParams struct { PageSize int `json:"pageSize" query:"pageSize"` PageNum int `json:"current" query:"pageNum"` Filter string `json:"filter" query:"filter"` }
func BuildCommonRequestParams ¶
func BuildCommonRequestParams(c echo.Context) (*CommonRequestParams, error)
type CommonResponse ¶
type CommonResponse struct { Success bool `json:"success"` Data ResponseContent `json:"data"` ErrorMessage string `json:"errorMessage"` }
type Context ¶
type Context struct {
echo.Context
}
func (*Context) BindValidBody ¶
func (*Context) CurrentUsername ¶
func (*Context) GetCurrentUserId ¶
func (*Context) GetRequestBody ¶
func (*Context) GetRequestDomain ¶
func (*Context) GetUserLoginKey ¶
func (*Context) GetUserMap ¶
type ResponseContent ¶
type ResponseContent struct { List interface{} `json:"list"` Current int `json:"current"` PageSize int `json:"pageSize"` Total int64 `json:"total"` }
func BuildCommonResponseParams ¶
func BuildCommonResponseParams(tx *gorm.DB, pageSize, pageNum int, model interface{}, preload, order []string) ResponseContent
type Serializers ¶
type Serializers interface { GetParams() SerializersParams Preload() []string Order() []string Response(data ResponseContent, query map[string]interface{}) ResponseContent ExtraFilter(query map[string]interface{}) map[string]interface{} QueryBeforeHook(ctx echo.Context, tx *gorm.DB, query map[string]interface{}) (*gorm.DB, error) }
type SerializersField ¶
type SerializersManager ¶
type SerializersManager struct {
// contains filtered or unexported fields
}
func NewSerializersManager ¶
func NewSerializersManager(ctx echo.Context, serializer Serializers) *SerializersManager
func (*SerializersManager) BuilderQuery ¶
func (c *SerializersManager) BuilderQuery() *gorm.DB
func (*SerializersManager) QuerySet ¶
func (c *SerializersManager) QuerySet() (CommonResponse, error)
type SerializersParams ¶
type SerializersParams struct { TableName string FilterCondition map[string]interface{} FilterConditionType []SerializersField Model interface{} }
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func NewValidator(c echo.Context) *Validator
func (*Validator) ParseMapByStruct ¶
func (*Validator) ParseStructByMap ¶
type ValidatorHandFunc ¶
type ValidatorHandFunc func(m interface{}) bool
Click to show internal directories.
Click to hide internal directories.