location.go 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package message
  2. import "spaceofcheng/services/models/model"
  3. // GetLocations 获取位置列表
  4. func (c *MessageController) GetLocations() {
  5. issys := c.GetString("issys")
  6. orgid := c.GetString("orgid")
  7. if orgid == "" {
  8. org := c.Context.Get("org").(model.SysOrg)
  9. orgid = org.OrgId
  10. }
  11. location, err := c.dao.GetLocationList(issys, orgid)
  12. if err != nil {
  13. c.ResponseError(err)
  14. }
  15. c.ResponseJSON(location)
  16. }
  17. // GetLocationById 根据id获取位置信息
  18. func (c *MessageController) GetLocationById() {
  19. locationid := c.GetString(":locationid")
  20. location, err := c.dao.GetLocationByID(locationid)
  21. if err != nil {
  22. c.ResponseError(err)
  23. }
  24. c.ResponseJSON(location)
  25. }
  26. // SaveLocation 保存位置信息
  27. func (c *MessageController) SaveLocation() {
  28. location := model.TdCmsImageLocation{}
  29. if err := c.ParseForm(&location); err != nil {
  30. c.ResponseError(err)
  31. }
  32. newInfo, err := c.dao.SaveLocation(location)
  33. if err != nil {
  34. c.ResponseError(err)
  35. }
  36. c.ResponseJSON(newInfo)
  37. }
  38. // DelLocation 删除位置信息
  39. func (c *MessageController) DelLocation() {
  40. locationID := c.GetString(":locationid")
  41. err := c.dao.DelLocation(locationID)
  42. if err != nil {
  43. c.ResponseError(err)
  44. }
  45. c.ResponseJSON("删除成功!")
  46. }
  47. // UpdateLocationSort 修改位置的排序
  48. func (c *MessageController) UpdateLocationSort() {
  49. locations := c.GetString("locations")
  50. err := c.dao.UpdateLocationSort(locations)
  51. if err != nil {
  52. c.ResponseError(err)
  53. }
  54. c.ResponseJSON("操作成功!")
  55. }
  56. // GetLocationInfoList 根据位置信息
  57. func (c *MessageController) GetLocationInfoList() {
  58. infos, err := c.dao.GetLocationInfoList()
  59. if err != nil {
  60. c.ResponseError(err)
  61. }
  62. c.ResponseJSON(infos)
  63. }