operation_log.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. package v1
  2. import (
  3. "context"
  4. "git.getensh.com/common/gopkgs/logger"
  5. "go.uber.org/zap"
  6. "property-system-gateway/pb"
  7. "property-system-gateway/pb/v1"
  8. "time"
  9. )
  10. const (
  11. ModuleGarden = "楼盘管理"
  12. ModuleHousehold = "业主管理"
  13. ModulePermission = "权限管理"
  14. ModuleSelf = "个人账户管理"
  15. ModuleUser = "用户管理"
  16. ModulePark = "停车场管理"
  17. ModuleDepartment = "部门"
  18. ModuleCharge = "费用管理"
  19. ModuleRepair = "报事报修"
  20. ModuleSuggestion = "投诉与建议"
  21. ModuleAnnouncement = "公告"
  22. ModuleVehicle = "车辆"
  23. )
  24. const (
  25. ActionAnnouncementAdd = "新增公告"
  26. ActionAnnouncementDel = "删除公告"
  27. ActionAnnouncementUpdate = "更新公告"
  28. )
  29. const (
  30. ActionVehicleAdd = "添加车辆"
  31. ActionVehicleUpdate = "修改车辆"
  32. ActionVehicleDel = "删除车辆"
  33. )
  34. const (
  35. ActionRepairClassAdd = "添加分类"
  36. ActionRepairClassUpdate = "修改分类"
  37. ActionRepairClassDel = "删除分类"
  38. ActionRepairOrderAdd = "添加工单"
  39. ActionRepairOrderUpdate = "修改工单"
  40. ActionRepairOrderDel = "删除工单"
  41. ActionRepairOrderSend = "派单"
  42. ActionRepairOrderFinish = "结单"
  43. ActionRepairOrderBack = "退单"
  44. ActionRepairOrderReturnVisit = "回访"
  45. )
  46. const (
  47. ActionSuggestionOrderAdd = "添加工单"
  48. ActionSuggestionOrderUpdate = "修改工单"
  49. ActionSuggestionOrderDel = "删除工单"
  50. ActionSuggestionOrderSend = "派单"
  51. ActionSuggestionOrderFinish = "结单"
  52. ActionSuggestionOrderBack = "退单"
  53. ActionSuggestionOrderReturnVisit = "回访"
  54. )
  55. // 费用
  56. const (
  57. ActionChargeConfAdd = "新增费用配置"
  58. ActionChargeConfUpdate = "修改费用配置"
  59. ActionChargeConfDel = "删除费用配置"
  60. ActionChargeBind = "绑定对象"
  61. ActionChargeUnbind = "解绑对象"
  62. ActionChargeSetTime = "修改费用时间"
  63. ActionChargePowerRecordAdd = "新增抄表记录"
  64. ActionChargePowerRecordDel = "删除抄表记录"
  65. ActionChargePowerRecordUpdate = "修改抄表记录"
  66. ActionChargePay = "欠费缴费"
  67. ActionChargePrePay = "预存费用"
  68. ActionChargePropertyPackageAdd = "新增物业费套餐"
  69. ActionChargePropertyPackageUpdate = "修改物业费套餐"
  70. ActionChargePropertyPackageDel = "删除物业费套餐"
  71. )
  72. // 楼栋
  73. const (
  74. ActionGardenAddBuilding = "新增楼栋"
  75. ActionGardenAddUnit = "新增单元"
  76. ActionGardenAddHouse = "新增房屋"
  77. ActionGardenUpdateBuilding = "修改楼栋"
  78. ActionGardenUpdateUnit = "修改单元"
  79. ActionGardenUpdateHouse = "修改房屋"
  80. ActionGardenDelBuilding = "删除楼栋"
  81. ActionGardenDelUnit = "删除单元"
  82. ActionGardenDelHouse = "删除房屋"
  83. )
  84. // 权限
  85. const (
  86. ActionGroupAdd = "新增权限组"
  87. ActionGroupDel = "删除权限组"
  88. ActionGroupUpdate = "修改权限组"
  89. )
  90. // 用户
  91. const (
  92. ActionUserAdd = "新增用户"
  93. ActionUserDel = "删除用户"
  94. ActionUserUpdate = "修改用户"
  95. )
  96. // 个人账户
  97. const (
  98. ActionSelfResetPassword = "忘记密码重置密码"
  99. ActionSelfChangePassword = "修改密码"
  100. )
  101. // 业主
  102. const (
  103. ActionHouseholdApprove = "业主房屋绑定审核"
  104. )
  105. const (
  106. ActionParkAdd = "添加停车场"
  107. ActionParkDel = "删除停车场"
  108. ActionParkUpdate = "修改停车场"
  109. ActionParkSpaceAdd = "添加车位"
  110. ActionParkSpaceDel = "删除车位"
  111. ActionParkSpaceUpdate = "修改车位"
  112. )
  113. const (
  114. ActionDepartmentAdd = "添加部门"
  115. ActionDepartmentDel = "删除部门"
  116. ActionDepartmentUpdate = "修改部门"
  117. )
  118. type OperationLogRequest struct {
  119. Module string
  120. Action string
  121. UserName string
  122. Uid int64
  123. Origin interface{}
  124. Target interface{}
  125. Cid int64
  126. GardenId int64
  127. }
  128. func OperationLogAdd(req *OperationLogRequest) {
  129. return
  130. mreq := v1.SystemLogAddRequest{
  131. Module: req.Module,
  132. Action: req.Action,
  133. Username: req.UserName,
  134. Uid: req.Uid,
  135. Timestamp: time.Now().Unix(),
  136. Cid: req.Cid,
  137. GardenId: req.GardenId,
  138. }
  139. if req.Origin != nil {
  140. origin, _ := json.Marshal(req.Origin)
  141. mreq.Origin = string(origin)
  142. }
  143. if req.Target != nil {
  144. target, _ := json.Marshal(req.Target)
  145. mreq.Target = string(target)
  146. }
  147. _, err := pb.PropertyLog.SystemLogAdd(context.Background(), &mreq)
  148. if err != nil {
  149. s, _ := json.Marshal(mreq)
  150. logger.Error("func",
  151. zap.String("call", "pb.PropertyLog.SystemLogAdd"),
  152. zap.String("params", string(s)),
  153. zap.String("error", err.Error()))
  154. }
  155. }