1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package main
- import (
- "app.yhyue.com/moapp/jybase/date"
- "go.mongodb.org/mongo-driver/bson"
- util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- )
- type JyService struct {
- }
- type DelRequest struct {
- Eid int64
- InfoId int64
- }
- type DelResponse struct {
- Status int
- Msg string
- }
- func (j *JyService) InfoDel(req DelRequest, res *DelResponse) error {
- if req.InfoId <= 0 || req.Eid <= 0 {
- res.Status = -1
- res.Msg = "参数异常"
- }
- util.Debug(req)
- info := MysqlTool.FindOne("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, "", "")
- if info != nil && len(*info) > 0 {
- pid := util.ObjToString((*info)["projectId"])
- if c := MysqlTool.Count("customer_data", bson.M{"projectId": pid}); c > 1 {
- MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, bson.M{"projectId": nil})
- } else {
- MysqlTool.Delete("customer_data_yys_project", bson.M{"projectId": pid})
- MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": req.InfoId}, bson.M{"projectId": nil})
- }
- } else {
- res.Status = -1
- res.Msg = "信息不存在"
- }
- return nil
- }
- type RevRequest struct {
- Eid int64
- Pici int64 // 批次时间
- }
- type RevResponse struct {
- Status int
- Msg string
- }
- func (j *JyService) DelByP(req RevRequest, res *RevResponse) error {
- if req.Pici <= 0 || req.Eid <= 0 {
- res.Status = -1
- res.Msg = "参数异常"
- }
- util.Debug(req)
- query := make(map[string]interface{})
- query["pici"] = date.FormatDateByInt64(&req.Pici, date.Date_Full_Layout)
- query["entid"] = req.Eid
- binfo := MysqlTool.Find("customer_data", query, "id", "", -1, -1)
- for _, info := range *binfo {
- pid := util.ObjToString((info)["projectId"])
- if c := MysqlTool.Count("customer_data", bson.M{"projectId": pid}); c > 1 {
- MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": info["id"]}, bson.M{"projectId": nil})
- } else {
- MysqlTool.Delete("customer_data_yys_project", bson.M{"projectId": pid})
- MysqlTool.Delete("customer_data_yys_monitoring", bson.M{"projectId": pid})
- MysqlTool.Update("customer_data", bson.M{"eid": req.Eid, "id": info["id"]}, bson.M{"projectId": nil})
- }
- }
- return nil
- }
|