package
0.0.0-20200520060200-b5c70d1d571b
Repository: https://github.com/offcn-jl/go-common.git
Documentation: pkg.go.dev

# README

代码库

系统中的代码均在本库中进行定义,规范如下:

0. 原则上不允许对已经定义在库中的代码进行变更

  1. 代码库中需要分别定义代码及代码对应的文本内容

  2. 代码的名称应当是的简称

  3. 代码的类型应当是整型 ( int ) 的常量 ( const )

  4. 代码文本应当是下标为整型的一维数组

  5. 代码文本的数组下标应当直接引用代码常量

  6. 代码文本数组中的元素内容应当是的详细介绍

  7. 应当提供获取代码文本的函数,参数为代码

  8. 使用代码时,应当使用代码常量名,而不是直接使用代码

  9. 使用代码文本时,应当使用函数获取,而不是直接使用文本

采用如上规范的好处是:

a. 可以保证代码在系统内是唯一的

b. 可以保证代码不会在不同的模块中产生歧义

c. 如果代码的数值发生了变更,只需要更新代码库,即保证系统中所有模块都进行对应的变更

example:

// 代码
const (
	ExampleCodeA = 10000
	ExampleCodeB = 10001
)
// 代码文本
var codeText = map[int]string{
	ExampleCodeA: "代码 A 代表的含义",
	ExampleCodeB: "代码 A 代表的含义",
}
// 获取代码文本的函数
func CodeText(code int) string {
	return codeText[code]
}

错误代码表:

代码文本描述附加内容
10xxx系统内部错误-
10000Unknown Internal Error-
10001System Config Is MissingItem ( String )
10002Handler Return Error-
10003Get Raw Data Fail-
10004Decrypt XML Fail-
10005Unmarshal XML FailParameter ( String )
10006Save Authorized Info FailParameter ( String )
10007Get Authorizer Refresh Token Fail-
10008Get Authorizer Access Token Fail-
10009Save To ORM Fail-
10010Send Request Fail-
10011Got Invalid ResponseAction ( String )
10012Send GET Request Fail-
10013Send POST Request Fail-
10014Check SQL Injection Fail-
10015Send Get Json Request Fail-
10016Get MIS Token FailStatus, Message
10017Marshal Json Map To Json String FailParameter ( String )
10018Unmarshal Json String To Json Map FailParameter ( String )
10019Encode String To Base64 String failParameter ( String )
10020Decode String To Base64 String failParameter ( String )
10021Encryption String To RSA String failParameter ( String )
10022Decryption String To RSA String failParameter ( String )
10023Get Session Info From Context FailStage ( String ), Info ( String )
10024Get Wechat Open Platform Config Fail-
10025Get Pre Auth Code Fail-
10026Unescape Query ( IN URL ) Fail-
11xxx数据不合法-
11000Invalid DataType ( String )
11001Invalid Json Data-
11002Invalid Table Name-
11003Invalid Phone Number-
11004Invalid Query Url-
11005Invalid ParameterParameter ( String )
11006Did Not Pass The SQL Injection CheckParameter ( String )
12xxx数据不存在-
12000Data Is Not ExistData ( String )
12001Table Is Not ExistTableName ( String )
12002Page Is Not Exist-
12003Swiper Is Not Exist-
12004Class Is Not Exist-
13xxx授权错误-
13000Not Certified-
13001Not Certified ( CORS )-
13002User Has Been Banned Or Not Exist-
13003Password Not MatchFailCount ( Int )
13004User Has Been Login Failed More Than 5 Times In 24 Hour-
13005Session Has Been Expired-
13006MIS Token Has Been Expired-
13007User Does Not Have Permission For This OperationDetails
14xxx操作错误-
14000Wrong Operation-
14001Target Group has Child Group ( s )-
14002Target Group has Users ( s )-
14003Duplicate User Name-
14004Already Exist Page For This Group-
14005Swiper Exceed The Upper Limit-
14006Last Sms Code Was Not Expired-
14007Sms Code Was Expired-
14008Sms Code Was Mismatch Last One-
14009Already Exist This Group-