dhcpInfo.go 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package service
  2. import (
  3. "dhcp/code"
  4. "dhcp/internal/dao"
  5. "dhcp/model"
  6. "dhcp/result"
  7. )
  8. func AddDHCPInfo(dhcpInfo model.DHCP) result.Result {
  9. err := dao.AddDHCP(dhcpInfo)
  10. return result.Result{
  11. Status: err == nil,
  12. Code: code.SUCCESS,
  13. Msg: "添加成功",
  14. }
  15. }
  16. func GetDHCPInfoByMac(mac string) result.Result {
  17. dhcpInfo, err := dao.GetDHCPByMac(mac)
  18. return result.Result{
  19. Status: err == nil,
  20. Code: code.SUCCESS,
  21. Data: dhcpInfo,
  22. }
  23. }
  24. func GetDHCPInfo() result.Result {
  25. dhcpInfo, err := dao.GetDHCP()
  26. return result.Result{
  27. Status: err == nil,
  28. Code: code.SUCCESS,
  29. Data: dhcpInfo,
  30. }
  31. }
  32. func UpdateDHCPInfo(dhcpInfo model.DHCP) result.Result {
  33. err := dao.UpdateDHCP(dhcpInfo)
  34. return result.Result{
  35. Status: err == nil,
  36. Code: code.SUCCESS,
  37. Msg: "更新成功",
  38. }
  39. }
  40. func DeleteDHCPInfo(mac string) result.Result {
  41. err := dao.DeleteDHCP(mac)
  42. return result.Result{
  43. Status: err == nil,
  44. Code: code.SUCCESS,
  45. Msg: "删除成功",
  46. }
  47. }