service.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package main
  2. import (
  3. "app.yhyue.com/moapp/jybase/date"
  4. "go.mongodb.org/mongo-driver/bson"
  5. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  6. )
  7. type JyService struct {
  8. }
  9. type DelRequest struct {
  10. Eid int64
  11. InfoId int64
  12. }
  13. type DelResponse struct {
  14. Status int
  15. Msg string
  16. }
  17. func (j *JyService) InfoDel(req DelRequest, res *DelResponse) error {
  18. if req.InfoId <= 0 || req.Eid <= 0 {
  19. res.Status = -1
  20. res.Msg = "参数异常"
  21. }
  22. util.Debug(req)
  23. info := MysqlTool.FindOne("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, "", "")
  24. if info != nil && len(*info) > 0 {
  25. pid := util.ObjToString((*info)["projectId"])
  26. if c := MysqlTool.Count("customer_data", bson.M{"projectId": pid}); c > 1 {
  27. MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, bson.M{"projectId": nil})
  28. } else {
  29. MysqlTool.Delete("customer_data_yys_project", bson.M{"projectId": pid})
  30. MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, bson.M{"projectId": nil})
  31. }
  32. } else {
  33. res.Status = -1
  34. res.Msg = "信息不存在"
  35. }
  36. return nil
  37. }
  38. type RevRequest struct {
  39. Eid int64
  40. Pici int64 // 批次时间
  41. }
  42. type RevResponse struct {
  43. Status int
  44. Msg string
  45. }
  46. func (j *JyService) DelByP(req RevRequest, res *RevResponse) error {
  47. if req.Pici <= 0 || req.Eid <= 0 {
  48. res.Status = -1
  49. res.Msg = "参数异常"
  50. }
  51. util.Debug(req)
  52. query := make(map[string]interface{})
  53. query["pici"] = date.FormatDateByInt64(&req.Pici, date.Date_Full_Layout)
  54. query["entid"] = req.Eid
  55. binfo := MysqlTool.Find("customer_data", query, "id", "", -1, -1)
  56. for _, info := range *binfo {
  57. pid := util.ObjToString((info)["projectId"])
  58. if c := MysqlTool.Count("customer_data", bson.M{"projectId": pid}); c > 1 {
  59. MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": info["id"]}, bson.M{"projectId": nil})
  60. } else {
  61. MysqlTool.Delete("customer_data_yys_project", bson.M{"projectId": pid})
  62. MysqlTool.Delete("customer_data_yys_monitoring", bson.M{"projectId": pid})
  63. MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": info["id"]}, bson.M{"projectId": nil})
  64. }
  65. }
  66. return nil
  67. }