error_code.go 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. package enums
  2. import "XT_Admin_Api/utils"
  3. const ( // ErrorCode
  4. // 登录注册错误 6000+
  5. ErrorCodeLoginTimeout = 6001
  6. ErrorCodeNotLogin = 6002
  7. ErrorCodePermissionDenied = 6003
  8. ErrorCodeMobileRegistered = 6004
  9. ErrorCodePasswordEmpty = 6005
  10. ErrorCodeVerificationCodeWrong = 6006
  11. ErrorCodeRegisterFail = 6007
  12. ErrorCodeInvalidToken = 6008
  13. ErrorCodeAccountOrPasswordWrong = 6009
  14. ErrorCodeMissingOrg = 6010
  15. ErrorCodeMissingOrgApp = 6011
  16. ErrorCodeAccountOrVerCodeWrong = 6012
  17. ErrorCodeMobileNotExit = 6013
  18. ErrorCodeUserNotExist = 6014
  19. ErrorCodeUserWasForbidden = 6015
  20. ErrorCodeNeverCreateTypeApp = 6016
  21. ErrorCodeContactSuperAdminCreateTypeApp = 6017
  22. // 数据验证错误 7000+
  23. ErrorCodeMobileFormat = 7001
  24. ErrorCodeTelphoneFormat = 7002
  25. ErrorCodeParamWrong = 7003
  26. ErrorCodeParamFormatWrong = 7004
  27. // 数据库操作错误 8000+
  28. ErrorCodeDBCreate = 8001
  29. ErrorCodeDBUpdate = 8002
  30. ErrorCodeDBDelete = 8003
  31. ErrorCodeDBSelectNoResult = 8004
  32. ErrorCodeDataException = 8005
  33. // 业务逻辑操作错误 9000+
  34. ErrorCodeRoleNotExist = 9001
  35. ErrorCodeAdminUserNotExist = 9002
  36. ErrorCodeMobileDidUsedInApp = 9003
  37. ErrorCodeMissingUserName = 9004
  38. ErrorCodeOldPasswordWrong = 9005
  39. ErrorCodeCannotRemoveRole = 9006
  40. ErrorCodeRoleMobileIsSuperAdmin = 9007
  41. ErrorCodeGetQiniuUpToken = 1001
  42. ErrorCodeCreatePatient = 1002
  43. ErrorCodeDialysisNoExist = 1003
  44. ErrorCodeIdCardNoExist = 1004
  45. ErrorCodePatientNoExist = 1005
  46. ErrorCodeUpdatePatient = 1006
  47. ErrorCodeDialysisSolutionExist = 1007
  48. ErrorCodeDialysisSolutionCreate = 1008
  49. ErrorCodeDialysisSolutionUpdate = 1009
  50. ErrorCodeDialysisSolutionNotExist = 1010
  51. ErrorCodeParentDialysisSolutionNotExist = 1011
  52. ErrorCodeAlReadyHadChildSolution = 1012
  53. ErrorCodeCanntCreateChildChildSolution = 1013
  54. ErrorCodeDialysisSolutionUsed = 1014
  55. ErrorCodeCreateDryWeightFail = 1015
  56. ErrorCodeCreateDoctorAdviceFail = 1016
  57. ErrorCodeDoctorAdviceNotExist = 1017
  58. ErrorCodeUpdateDoctorAdviceFail = 1018
  59. ErrorCodeLongTimeAdviceNotCanntEdit = 1019
  60. ErrorCodeAdviceStoped = 1020
  61. ErrorCodeParentAdviceNotExist = 1021
  62. ErrorCodeStopAdviceFail = 1022
  63. ErrorCodeDeleteAdviceFail = 1023
  64. ErrorCodeDialysisSolutionDelete = 1024
  65. ErrorCodeDeviceNumberNotTheZone = 1025
  66. ErrorCodeCreateScheduleFail = 1026
  67. ErrorCodeCantSetScheduleAgainOneDay = 1027
  68. ErrorCodeCantSetScheduleBeforeNow = 1028
  69. ErrorCodeScheduleNotExist = 1029
  70. ErrorCodeDeleteScheduleFail = 1030
  71. ErrorCodeChangeScheduleFail = 1031
  72. ErrorCodePatientPhoneUsed = 1032
  73. ErrorCodeAdviceExced = 1033
  74. ErrorCodeAdviceChecked = 1034
  75. ErrorCodePointScheduleExist = 1035
  76. ErrorCodeExceAndCheckNotOneUser = 1036
  77. ErrorCodeCanotEditOtherAdvice = 1037
  78. ErrorCodeEditLapsetoFail = 1038
  79. ErrorCodeAdviceCheckBeforeExce = 1039
  80. ErrorCodeAdviceExceBeforeStart = 1040
  81. ErrorCodeDelScheduleFailByDialysis = 1041
  82. ErrorCodeNotSelectLapsetoType = 1042
  83. ErrorCodeNotSelectLapsetoTime = 1043
  84. ErrorCodeInspectionDateExit = 1201
  85. ErrorCodeInspectionAddFail = 1202
  86. ErrorCodeInspectionEditFail = 1204
  87. ErrorCodeInspectionDateNotExit = 1203
  88. ErrorCodeInspectionDeleteFail = 1205
  89. ErrorCodeMonitorCreate = 1128
  90. ErrorCodeMonitorNotExist = 1129
  91. ErrorCodeMonitorUpdate = 1130
  92. ErrorDialysisOrderNoStart = 1132
  93. ErrorDialysisOrderNoEND = 1133
  94. ErrorDialysisOrderRepeatStart = 1134
  95. ErrorCodeDialysisPermissionDeniedModify = 1135
  96. ErrorCodeNotSubscibe = 4003
  97. ErrorCodeServeNotExist = 4004
  98. ErrorCodeInvoiceExist = 4005
  99. ErrorCodeApplyInvoiceFail = 4006
  100. ErrorCodeHetongHad = 4007
  101. ErrorCodeCreateHetongFail = 4008
  102. ErrorCodePatientReachLimit = 4009
  103. ErrorCodeDeviceZoneNotExist = 9021
  104. ErrorCodeDeviceZoneNameRepeat = 9022
  105. ErrorCodeDeviceGroupNotExist = 9023
  106. ErrorCodeDeviceGroupNameRepeat = 9024
  107. ErrorCodeDeviceNumberNotExist = 9025
  108. ErrorCodeDeviceNumberRepeat = 9026
  109. ErrorCodeDeviceNotExist = 9027
  110. ErrorCodeDeviceZoneCannotDisable = 9028
  111. ErrorCodeDeviceNumberCannotDisableCuzDevice = 9029
  112. ErrorCodeDeviceNumberCannotDisableCuzSchedule = 9030
  113. ErrorCodeDeviceNumberCannotDisableCuzSchTemplate = 9031
  114. ErrorCommitFail = 90000
  115. ErrorCodeCreateStockInFail = 20001
  116. ErrorCodeScheduleTemplateNotExist = 10001
  117. ErrorCodeSystemError = 6666
  118. ErrorCodeProductError = 6667
  119. ErrorCodeFieldExist = 100001
  120. ErrorCodeCreateConfig = 100002
  121. ErrorCodeUpdateConfig = 100003
  122. ErrorCodeDoubleCheckWrong = 200003
  123. ErrorCodeDoubleCheckUserWrong = 200004
  124. ErrorCodeGoodNoStockInError = 200005
  125. ErrorCodeCancelStockFail = 200006
  126. ErrorCodeDeleteGoodTypeFail = 200007
  127. ErrorCodeDeleteGoodInfoFail = 200008
  128. ErrorCodeDeleteFail = 200009
  129. ErrorCodeKeyFail = 200010
  130. ErrorCodeDeleteStockInRecordFail = 200011
  131. ErrorCodeNameWrong = 200012
  132. ErrorCodeParamEmptyWrong = 200013
  133. ErrorCodeParamAdviceEmptyWrong = 200014
  134. ErrorCodeParamTemplateNOEXISTWrong = 200015
  135. ErrorCodeDeleteDealerWrong = 200016
  136. ErrorCodeDeleteManufacturerWrong = 200017
  137. ErrorCodeGoodTypeNameExistError = 200018
  138. ErrorCodeGoodInfoNameExistError = 200019
  139. ErrorCodePrescriptionPermissionDeniedModify = 200020
  140. ErrorCodeAdvicePermissionDeniedModify = 200021
  141. ErrorCodePrescriptionException = 200022
  142. )
  143. var ErrCodeMsgs = map[int]string{
  144. // 登录注册错误
  145. ErrorCodeLoginTimeout: "登录超时",
  146. ErrorCodeNotLogin: "未登录",
  147. ErrorCodePermissionDenied: "权限不足",
  148. ErrorCodeMobileRegistered: "手机号已被注册",
  149. ErrorCodePasswordEmpty: "密码为空",
  150. ErrorCodeVerificationCodeWrong: "验证码错误",
  151. ErrorCodeRegisterFail: "注册失败",
  152. ErrorCodeInvalidToken: "令牌无效",
  153. ErrorCodeAccountOrPasswordWrong: "账号或密码错误",
  154. ErrorCodeMissingOrg: "未创建机构",
  155. ErrorCodeMissingOrgApp: "未创建任何应用",
  156. ErrorCodeAccountOrVerCodeWrong: "账号或验证码错误",
  157. ErrorCodeMobileNotExit: "手机号不存在",
  158. ErrorCodeUserNotExist: "用户不存在",
  159. ErrorCodeUserWasForbidden: "该用户被禁用",
  160. ErrorCodeNeverCreateTypeApp: "未创建此种应用",
  161. ErrorCodeContactSuperAdminCreateTypeApp: "请联系超级管理员开通此种应用",
  162. // 数据验证错误
  163. ErrorCodeMobileFormat: "手机号格式错误",
  164. ErrorCodeTelphoneFormat: "电话格式错误",
  165. ErrorCodeParamWrong: "参数错误",
  166. ErrorCodeParamFormatWrong: "参数格式错误",
  167. // 数据库操作错误
  168. ErrorCodeDBCreate: "数据库创建出错",
  169. ErrorCodeDBUpdate: "数据库更新出错",
  170. ErrorCodeDBDelete: "数据库删除出错",
  171. ErrorCodeDBSelectNoResult: "查询无结果",
  172. ErrorCodeDataException: "数据异常",
  173. // 业务逻辑操作错误
  174. ErrorCodeRoleNotExist: "角色不存在",
  175. ErrorCodeAdminUserNotExist: "管理员不存在",
  176. ErrorCodeMobileDidUsedInApp: "该手机号已在该应用中被注册为管理员",
  177. ErrorCodeMissingUserName: "缺少用户名",
  178. ErrorCodeOldPasswordWrong: "原密码不正确",
  179. ErrorCodeCannotRemoveRole: "存在该角色的管理员,不能删除该角色",
  180. ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
  181. ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
  182. ErrorCodeCreatePatient: "创建患者失败",
  183. ErrorCodeDialysisNoExist: "患者透析号重复!",
  184. ErrorCodeIdCardNoExist: "身份证号重复!",
  185. ErrorCodePatientNoExist: "患者信息不存在!",
  186. ErrorCodeUpdatePatient: "修改患者信息失败",
  187. ErrorCodeDialysisSolutionExist: "该处方已经存在",
  188. ErrorCodeDialysisSolutionCreate: "创建处方失败",
  189. ErrorCodeDialysisSolutionUpdate: "修改处方失败",
  190. ErrorCodeDialysisSolutionNotExist: "该处方不存在",
  191. ErrorCodeParentDialysisSolutionNotExist: "上级处方不存在",
  192. ErrorCodeAlReadyHadChildSolution: "所选处方已经存在子方案",
  193. ErrorCodeCanntCreateChildChildSolution: "子方案不能添加子方案",
  194. ErrorCodeDialysisSolutionUsed: "处方已被使用,不能删除",
  195. ErrorCodeCreateDryWeightFail: "添加干体重失败",
  196. ErrorCodeCreateDoctorAdviceFail: "添加医嘱失败",
  197. ErrorCodeUpdateDoctorAdviceFail: "修改医嘱信息失败",
  198. ErrorCodeDoctorAdviceNotExist: "医嘱不存在",
  199. ErrorCodeLongTimeAdviceNotCanntEdit: "长期医嘱不能修改!",
  200. ErrorCodeAdviceStoped: "所选医嘱已停止",
  201. ErrorCodeParentAdviceNotExist: "上级医嘱不存在",
  202. ErrorCodeDeleteAdviceFail: "删除医嘱失败",
  203. ErrorCodeStopAdviceFail: "停止医嘱失败",
  204. ErrorCodeDialysisSolutionDelete: "删除方案失败",
  205. ErrorCodeDeviceNumberNotTheZone: "所选机号不在选择分区中",
  206. ErrorCodeCreateScheduleFail: "添加排班失败",
  207. ErrorCodeCantSetScheduleAgainOneDay: "同一天不可有两次排班",
  208. ErrorCodeCantSetScheduleBeforeNow: "不能给今天之前的日期排班",
  209. ErrorCodeScheduleNotExist: "排班不存在",
  210. ErrorCodePointScheduleExist: "所先位置排班已经存在",
  211. ErrorCodeDeleteScheduleFail: "取消排班失败",
  212. ErrorCodeChangeScheduleFail: "修改排班失败",
  213. ErrorCodePatientPhoneUsed: "手机号已经存在",
  214. ErrorCodeAdviceExced: "医嘱已经执行",
  215. ErrorCodeAdviceCheckBeforeExce: "核对医嘱不能在执行医嘱之前",
  216. ErrorCodeAdviceExceBeforeStart: "执行医嘱不能在开始之前",
  217. ErrorCodeAdviceChecked: "医嘱已经核对",
  218. ErrorCodeExceAndCheckNotOneUser: "核对与执行不能是同一人",
  219. ErrorCodeCanotEditOtherAdvice: "不能修改非本人添加的医嘱",
  220. ErrorCodeEditLapsetoFail: "转归失败",
  221. ErrorCodeDelScheduleFailByDialysis: "已经上机透析,不能取消排班",
  222. ErrorCodeNotSelectLapsetoType: "请选择转归状态",
  223. ErrorCodeNotSelectLapsetoTime: "请选择转归时间",
  224. ErrorCodeInspectionDateExit: "当天已经存在检验检查记录",
  225. ErrorCodeInspectionAddFail: "添加记录失败",
  226. ErrorCodeInspectionDateNotExit: "当天不存在检验检查记录",
  227. ErrorCodeInspectionEditFail: "修改记录失败",
  228. ErrorCodeInspectionDeleteFail: "删除记录失败",
  229. ErrorCodeDeviceZoneNotExist: "设备分区不存在",
  230. ErrorCodeDeviceZoneNameRepeat: "该分区名已存在",
  231. ErrorCodeDeviceGroupNotExist: "设备分组不存在",
  232. ErrorCodeDeviceGroupNameRepeat: "该分组名已存在",
  233. ErrorCodeDeviceNumberNotExist: "机号不存在",
  234. ErrorCodeDeviceNumberRepeat: "该机号已存在",
  235. ErrorCodeDeviceNotExist: "该设备不存在",
  236. ErrorCodeDeviceZoneCannotDisable: "该分区存在床位号,不能删除",
  237. ErrorCodeDeviceNumberCannotDisableCuzDevice: "该床位存在设备,不能删除",
  238. ErrorCodeDeviceNumberCannotDisableCuzSchedule: "该床位尚有排班安排,不能删除",
  239. ErrorCodeDeviceNumberCannotDisableCuzSchTemplate: "排班模板在该床位尚有排班安排,不能删除",
  240. ErrorCodeNotSubscibe: "没有订阅服务或服务已过期,请先购买服务!",
  241. ErrorCodeServeNotExist: "服务订单不存在!",
  242. ErrorCodeInvoiceExist: "已经申请了发票!",
  243. ErrorCodeApplyInvoiceFail: "申请发票失败!",
  244. ErrorCodeHetongHad: "合同已经存在!",
  245. ErrorCodeCreateHetongFail: "合同创建失败",
  246. ErrorCodePatientReachLimit: "患者数已达到当前服务版本病人数,需要升级到更高的版本",
  247. ErrorCodeMonitorCreate: "创建监测失败",
  248. ErrorCodeMonitorNotExist: "监测记录不存在",
  249. ErrorCodeMonitorUpdate: "修改监测失败",
  250. ErrorCodeDialysisPermissionDeniedModify: "您没有权限修改其他医护的数据!",
  251. ErrorDialysisOrderNoStart: "尚未上机,无法执行下机操作",
  252. ErrorDialysisOrderNoEND: "已处于下机状态",
  253. ErrorDialysisOrderRepeatStart: "已上机",
  254. //ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
  255. ErrorCodeSystemError: "系统异常",
  256. ErrorCodeProductError: "该服务商品已丢失",
  257. ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
  258. ErrorCodeCreateStockInFail: "入库失败",
  259. //ErrorCodeSystemError: "系统异常",
  260. //ErrorCodeProductError: "该服务商品已丢失",
  261. ErrorCodeFieldExist: "配置字段已存在",
  262. ErrorCodeCreateConfig: "创建配置失败",
  263. ErrorCodeUpdateConfig: "修改配置失败",
  264. ErrorCommitFail: "提交失败",
  265. ErrorCodeDoubleCheckWrong: "核对已完成, 无法再次提交",
  266. ErrorCodeDoubleCheckUserWrong: "你已完成核对,不能重复核对",
  267. ErrorCodeGoodNoStockInError: "该商品尚未入库",
  268. ErrorCodeCancelStockFail: "出库退库失败",
  269. ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
  270. ErrorCodeDeleteGoodInfoFail: "该商品已经入库无法删除",
  271. ErrorCodeDeleteFail: "删除失败",
  272. ErrorCodeKeyFail: "关键字不能为空",
  273. ErrorCodeDeleteStockInRecordFail: "该记录已经有出库或退货操作,无法删除",
  274. ErrorCodeNameWrong: "该模版名字已存在",
  275. ErrorCodeParamEmptyWrong: "模版名称不能为空",
  276. ErrorCodeParamAdviceEmptyWrong: "医嘱名称不能为空",
  277. ErrorCodeDeleteDealerWrong: "该经销商所属商品已入库无法删除",
  278. ErrorCodeDeleteManufacturerWrong: "该厂商所属商品已入库无法删除",
  279. ErrorCodeGoodTypeNameExistError: "该商品类型名字已存在",
  280. ErrorCodeGoodInfoNameExistError: "该规格名称名字已存在",
  281. ErrorCodePrescriptionPermissionDeniedModify: "您没有权限修改透析处方数据",
  282. ErrorCodeAdvicePermissionDeniedModify: "您没有权限添加医嘱",
  283. ErrorCodePrescriptionException: "上机失败,请先开处方",
  284. }
  285. type SGJError struct {
  286. Code int
  287. }
  288. func (e *SGJError) Error() string {
  289. value, ok := ErrCodeMsgs[e.Code]
  290. if ok {
  291. return value
  292. } else {
  293. return "未知错误"
  294. }
  295. }
  296. func MakeSuccessResponseJSON(data map[string]interface{}) map[string]interface{} {
  297. json := make(map[string]interface{})
  298. if data != nil {
  299. json["data"] = data
  300. } else {
  301. json["data"] = make(map[string]interface{})
  302. }
  303. json["state"] = 1
  304. json["code"] = 0
  305. return json
  306. }
  307. func MakeFailResponseJSON(errMsg string, errCode int) map[string]interface{} {
  308. json := make(map[string]interface{})
  309. json["msg"] = errMsg
  310. json["code"] = errCode
  311. json["state"] = 0
  312. return json
  313. }
  314. func MakeFailResponseJSONWithSGJError(err *SGJError) map[string]interface{} {
  315. if err == nil {
  316. utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")
  317. return nil
  318. }
  319. return MakeFailResponseJSON(err.Error(), err.Code)
  320. }
  321. func MakeFailResponseJSONWithSGJErrorCode(code int) map[string]interface{} {
  322. err := &SGJError{Code: code}
  323. return MakeFailResponseJSON(err.Error(), err.Code)
  324. }