dept_service.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package service
  2. import (
  3. "ulink-admin/modules/system/dao"
  4. "ulink-admin/modules/system/models/model"
  5. "ulink-admin/modules/system/models/req"
  6. )
  7. type DeptService struct {
  8. DeptDao *dao.DeptDao `inject:""`
  9. RoleDao *dao.RoleDao `inject:""`
  10. }
  11. // TreeSelect 根据条件查询部门树
  12. func (s DeptService) TreeSelect(query req.DeptQuery) *[]model.SysDept {
  13. treeSelect := s.DeptDao.TreeSelect(query)
  14. return treeSelect
  15. }
  16. // SelectDeptListByRoleId 根据角色ID查询部门树信息
  17. func (s DeptService) SelectDeptListByRoleId(id int64) *[]int64 {
  18. role := s.RoleDao.SelectRoleByRoleId(id)
  19. return s.DeptDao.SelectDeptListByRoleId(id, role.DeptCheckStrictly)
  20. }
  21. // GetList 查询部门列表
  22. func (s DeptService) GetList(query req.DeptQuery) *[]model.SysDept {
  23. return s.DeptDao.GetList(query)
  24. }
  25. // GetDeptById 根据部门编号获取详细信息
  26. func (s DeptService) GetDeptById(id int64) *model.SysDept {
  27. return s.DeptDao.GetDeptById(id)
  28. }
  29. // Insert 添加部门数据
  30. func (s DeptService) Insert(dept model.SysDept) int64 {
  31. return s.DeptDao.Insert(dept)
  32. }
  33. // Insert 添加部门数据
  34. func (s DeptService) Update(dept model.SysDept) int64 {
  35. return s.DeptDao.Update(dept)
  36. }
  37. // CheckDeptNameUnique 校验部门名称是否唯一
  38. func (s DeptService) CheckDeptNameUnique(dept model.SysDept) bool {
  39. if s.DeptDao.CheckDeptNameUnique(dept) > 0 {
  40. return true
  41. }
  42. return false
  43. }
  44. // Remove 删除部门
  45. func (s DeptService) Remove(id int64) int64 {
  46. return s.DeptDao.Delete(id)
  47. }
  48. // HasChildByDeptId 是否存在部门子节点
  49. func (s DeptService) HasChildByDeptId(id int64) int64 {
  50. return s.DeptDao.HasChildByDeptId(id)
  51. }
  52. // CheckDeptExistUser 查询部门是否存在用户
  53. func (s DeptService) CheckDeptExistUser(id int64) int64 {
  54. return s.DeptDao.CheckDeptExistUser(id)
  55. }