utilService.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package service
  2. import (
  3. "iot_manager_service/app/device/dao"
  4. )
  5. var UtilService = new(utilService)
  6. type utilService struct{}
  7. func (s *utilService) GetDeviceVendor(tenantId string, deviceType int) ([]dao.DeviceVendor, error) {
  8. // 创建查询实例
  9. device := &dao.DeviceVendor{
  10. TenantId: tenantId,
  11. DeviceType: deviceType,
  12. }
  13. vendors, err := device.GetVendor()
  14. if err != nil {
  15. return nil, err
  16. }
  17. return vendors, nil
  18. }
  19. func (s *utilService) GetDeviceBrand(tenantId string, deviceType int) ([]dao.DeviceVendor, error) {
  20. // 创建查询实例
  21. device := &dao.DeviceVendor{
  22. TenantId: tenantId,
  23. DeviceType: deviceType,
  24. }
  25. vendors, err := device.GetBrand()
  26. if err != nil {
  27. return nil, err
  28. }
  29. return vendors, nil
  30. }
  31. func (s *utilService) GetDeviceModel(tenantId string, deviceType, parentId int) ([]dao.DeviceVendor, error) {
  32. // 创建查询实例
  33. device := &dao.DeviceVendor{
  34. TenantId: tenantId,
  35. DeviceType: deviceType,
  36. ParentId: parentId,
  37. }
  38. vendors, err := device.GetModel()
  39. if err != nil {
  40. return nil, err
  41. }
  42. return vendors, nil
  43. }
  44. func (s *utilService) GetTenantCode(tenantId string) (*dao.TenantCode, error) {
  45. // 创建查询实例
  46. device := &dao.TenantCode{
  47. TenantId: tenantId,
  48. }
  49. tenantCode, err := device.GetTenantCode()
  50. if err != nil {
  51. return nil, err
  52. }
  53. return &tenantCode, nil
  54. }
  55. func (s *utilService) GetDeviceVendorList(tenantId string, venderValue string, deviceType, offset, limit int) ([]dao.DeviceVendor, int64, error) {
  56. device := dao.DeviceVendor{
  57. TenantId: tenantId,
  58. VendorValue: venderValue,
  59. DeviceType: deviceType,
  60. }
  61. return device.GetDeviceVendors(offset, limit)
  62. }
  63. func (s *utilService) GetRemoveVendor(id int) error {
  64. device := dao.DeviceVendor{
  65. ID: id,
  66. }
  67. return device.Remove()
  68. }