sys_notice.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # -*- coding: utf-8 -*-
  2. # @Author : YY
  3. from typing import List, Optional
  4. from ruoyi_common.sqlalchemy.transaction import Transactional
  5. from ruoyi_system.domain.entity import SysNotice
  6. from ruoyi_system.mapper.sys_notice import SysNoticeMapper
  7. from ruoyi_admin.ext import db
  8. class SysNoticeService:
  9. @classmethod
  10. def select_notice_by_id(cls,id:int) -> Optional[SysNotice]:
  11. """
  12. 查询公告信息
  13. Args:
  14. id(int): 公告ID
  15. Returns:
  16. Optional[SysNotice]: 公告信息
  17. """
  18. return SysNoticeMapper.select_notice_by_id(id)
  19. @classmethod
  20. def select_notice_list(cls,query:SysNotice)-> List[SysNotice]:
  21. """
  22. 查询公告列表
  23. Args:
  24. query(SysNotice): 包含查询条件的传输对象
  25. Returns:
  26. List[SysNotice]: 公告列表
  27. """
  28. return SysNoticeMapper.select_notice_list(query)
  29. @classmethod
  30. @Transactional(db.session)
  31. def insert_notice(cls,body:SysNotice) -> bool:
  32. """
  33. 新增公告
  34. Args:
  35. body(SysNotice): 公告信息
  36. Returns:
  37. bool: 操作结果
  38. """
  39. flag = SysNoticeMapper.insert_notice(body)
  40. return flag > 0
  41. @classmethod
  42. @Transactional(db.session)
  43. def update_notice(cls,body:SysNotice) -> bool:
  44. """
  45. 修改公告
  46. Args:
  47. body(SysNotice): 公告信息
  48. Returns:
  49. bool: 操作结果
  50. """
  51. return SysNoticeMapper.update_notice(body) > 0
  52. @classmethod
  53. @Transactional(db.session)
  54. def delete_notice_by_id(cls,id:int) -> bool:
  55. """
  56. 删除公告
  57. Args:
  58. id(int): 公告ID
  59. Returns:
  60. int: 操作结果
  61. """
  62. return SysNoticeMapper.delete_notice_by_id(id) > 0
  63. @classmethod
  64. @Transactional(db.session)
  65. def delete_notice_by_ids(cls,ids:List[int]) -> bool:
  66. """
  67. 批量删除公告
  68. Args:
  69. ids(List[int]): 公告ID列表
  70. Returns:
  71. bool: 操作结果
  72. """
  73. return SysNoticeMapper.delete_notice_by_ids(ids) > 0