actionsService.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package actions
  2. import (
  3. "xorm.io/xorm"
  4. "dashoo.cn/base_common/utils"
  5. . "dashoo.cn/base_common/utils/db"
  6. )
  7. type ActionsService struct {
  8. ServiceBase
  9. }
  10. func GetActionsService(xormEngine *xorm.Engine) *ActionsService {
  11. s := new(ActionsService)
  12. s.DBE = xormEngine
  13. return s
  14. }
  15. func (s *ActionsService) GetAlertor(alertor string) Actions {
  16. var model Actions
  17. sql := "select * from Actions where AItem=4 and SPara4='" + alertor + "'"
  18. s.DBE.SQL(sql).Get(&model)
  19. return model
  20. }
  21. func (s *ActionsService) GetByWdid(wdid string) Actions {
  22. var model Actions
  23. sql := "select * from Actions where Wdid='" + wdid + "'"
  24. s.DBE.SQL(sql).Get(&model)
  25. return model
  26. }
  27. func (s *ActionsService) GetEntitiesWithOrderSearch(searchstring string) []Actions {
  28. sql := `select * from Actions where ` + searchstring
  29. List := make([]Actions, 0)
  30. utils.DBE.SQL(sql).Find(&List)
  31. return List
  32. }
  33. func (s *ActionsService) GetCIds(searchstring string) string {
  34. if searchstring == "" {
  35. searchstring = "1=1"
  36. }
  37. sql := `select Id from Actions a
  38. where ` + searchstring
  39. var cids = "-1"
  40. List := make([]Actions, 0)
  41. s.DBE.SQL(sql).Find(&List)
  42. for i, j := 0, len(List); i < j; i++ {
  43. cids += "," + utils.ToStr(List[i].Id)
  44. }
  45. return cids
  46. }
  47. func (s *ActionsService) IsUsed_TriggerAbnormal(aid string) bool {
  48. var idmodel Id_Int
  49. if aid == "" {
  50. aid = "-1"
  51. }
  52. sql := `select count(*) Id from Trigger_Abnormal where FIND_IN_SET(` + aid + `,AId)>0`
  53. s.DBE.SQL(sql).Get(&idmodel)
  54. return idmodel.Id > 0
  55. }