error_code.go 18KB

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