SystemController.go 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. package partial
  2. import (
  3. "git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
  4. sysmodel "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
  5. sysutils "git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
  6. "git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
  7. )
  8. // _GetNavTree
  9. // @Title _GetNavTree
  10. // @Description 获取导航菜单
  11. // @Param user string false "用户id"
  12. // @Success 200 {object} Account
  13. // @Failure 403 :id is empty
  14. func System_GetNavTree(c *entitys.CtrlContext) {
  15. user := c.Ctx.Query("user")
  16. ret := __none_func_system__(user)
  17. if ret {
  18. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  19. }else{
  20. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  21. }
  22. }
  23. // _GetMenuTree
  24. // @Title _GetMenuTree
  25. // @Description 获取系统菜单
  26. // @Param user string false "用户id"
  27. // @Success 200 {object} Account
  28. // @Failure 403 :id is empty
  29. func System_GetMenuTree(c *entitys.CtrlContext) {
  30. user := c.Ctx.Query("user")
  31. ret := __none_func_system__(user)
  32. if ret {
  33. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  34. }else{
  35. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  36. }
  37. }
  38. // _FindUserPage
  39. // @Title _FindUserPage
  40. // @Description 获取用户分页数
  41. // @Success 200 {object} Account
  42. // @Failure 403 :id is empty
  43. func System_FindUserPage(c *entitys.CtrlContext) {
  44. var page int64 = c.Ctx.GetInt64("page")
  45. var rows int64 = c.Ctx.GetInt64("rows")
  46. paramMap_i_t := map[string]interface{}{"page": page, "rows": rows}
  47. result, err := sysutils.PageSearch(c.Db,"system","find_user_page", "sys_user", paramMap_i_t)
  48. if err == nil {
  49. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", result})
  50. }else{
  51. c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
  52. }
  53. }
  54. // _GetOrgTree
  55. // @Title _GetOrgTree
  56. // @Description 获取组织架构树
  57. // @Success 200 {object} Account
  58. // @Failure 403 :id is empty
  59. func System_GetOrgTree(c *entitys.CtrlContext) {
  60. paramMap_i_t := map[string]interface{}{"sort": "name"}
  61. result, err := sysutils.TreeSearch(c.Db, "system","get_org_tree", "sys_org", paramMap_i_t)
  62. if err == nil {
  63. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", result})
  64. }else{
  65. c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
  66. }
  67. }
  68. // _AddUser
  69. // @Title _AddUser
  70. // @Description 添加用户
  71. // @Param login_id string false "登录ID"
  72. // @Param password string false "密码"
  73. // @Param org_id string false "组织ID"
  74. // @Param email string false "邮箱"
  75. // @Success 200 {object} Account
  76. // @Failure 403 :id is empty
  77. func System_AddUser(c *entitys.CtrlContext) {
  78. login_id := c.Ctx.Query("login_id")
  79. password := c.Ctx.Query("password")
  80. org_id := c.Ctx.Query("org_id")
  81. email := c.Ctx.Query("email")
  82. ret := __none_func_system__(login_id,password,org_id,email)
  83. if ret {
  84. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  85. }else{
  86. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  87. }
  88. }
  89. // _DelUser
  90. // @Title _DelUser
  91. // @Description 删除用户
  92. // @Param id string false "用户ID"
  93. // @Success 200 {object} Account
  94. // @Failure 403 :id is empty
  95. func System_DelUser(c *entitys.CtrlContext) {
  96. id := c.Ctx.Query("id")
  97. ret := __none_func_system__(id)
  98. if ret {
  99. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  100. }else{
  101. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  102. }
  103. }
  104. // _UpdateUser
  105. // @Title _UpdateUser
  106. // @Description 修改用户
  107. // @Param login_id string false "登录ID"
  108. // @Param password string false "密码"
  109. // @Param org_id string false "组织ID"
  110. // @Param email string false "邮箱"
  111. // @Success 200 {object} Account
  112. // @Failure 403 :id is empty
  113. func System_UpdateUser(c *entitys.CtrlContext) {
  114. login_id := c.Ctx.Query("login_id")
  115. password := c.Ctx.Query("password")
  116. org_id := c.Ctx.Query("org_id")
  117. email := c.Ctx.Query("email")
  118. ret := __none_func_system__(login_id,password,org_id,email)
  119. if ret {
  120. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  121. }else{
  122. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  123. }
  124. }
  125. // _AddRole
  126. // @Title _AddRole
  127. // @Description 添加角色
  128. // @Param name string false "角色名称"
  129. // @Param remark string false "备注"
  130. // @Success 200 {object} Account
  131. // @Failure 403 :id is empty
  132. func System_AddRole(c *entitys.CtrlContext) {
  133. name := c.Ctx.Query("name")
  134. remark := c.Ctx.Query("remark")
  135. ret := __none_func_system__(name,remark)
  136. if ret {
  137. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  138. }else{
  139. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  140. }
  141. }
  142. // _DelRole
  143. // @Title _DelRole
  144. // @Description 添加角色
  145. // @Param id string false "角色ID"
  146. // @Success 200 {object} Account
  147. // @Failure 403 :id is empty
  148. func System_DelRole(c *entitys.CtrlContext) {
  149. id := c.Ctx.Query("id")
  150. ret := __none_func_system__(id)
  151. if ret {
  152. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  153. }else{
  154. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  155. }
  156. }
  157. // _UpdateRole
  158. // @Title _UpdateRole
  159. // @Description 修改角色
  160. // @Param id string false "角色ID"
  161. // @Param name string false "角色名称"
  162. // @Param remark string false "备注"
  163. // @Success 200 {object} Account
  164. // @Failure 403 :id is empty
  165. func System_UpdateRole(c *entitys.CtrlContext) {
  166. id := c.Ctx.Query("id")
  167. name := c.Ctx.Query("name")
  168. remark := c.Ctx.Query("remark")
  169. ret := __none_func_system__(id,name,remark)
  170. if ret {
  171. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  172. }else{
  173. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  174. }
  175. }
  176. // _FindRolePage
  177. // @Title _FindRolePage
  178. // @Description 角色分页
  179. // @Param page false "分页参数"
  180. // @Success 200 {object} Account
  181. // @Failure 403 :id is empty
  182. func System_FindRolePage(c *entitys.CtrlContext) {
  183. var paramObj0 models.GetPageInfo
  184. c.Ctx.BindJSON(&paramObj0)
  185. ret := __none_func_system__(paramObj0)
  186. if ret {
  187. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  188. }else{
  189. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  190. }
  191. }
  192. // _FindRoleMenu
  193. // @Title _FindRoleMenu
  194. // @Description 查找角色权限
  195. // @Param role_id string false "角色id"
  196. // @Success 200 {object} Account
  197. // @Failure 403 :id is empty
  198. func System_FindRoleMenu(c *entitys.CtrlContext) {
  199. role_id := c.Ctx.Query("role_id")
  200. ret := __none_func_system__(role_id)
  201. if ret {
  202. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  203. }else{
  204. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  205. }
  206. }
  207. // _SaveRoleMenu
  208. // @Title _SaveRoleMenu
  209. // @Description 保存角色权限
  210. // @Param role_menu string false "角色权限"
  211. // @Success 200 {object} Account
  212. // @Failure 403 :id is empty
  213. func System_SaveRoleMenu(c *entitys.CtrlContext) {
  214. var paramObj0 []models.SaveRoleMenu
  215. c.Ctx.BindJSON(&paramObj0)
  216. ret := __none_func_system__(paramObj0)
  217. if ret {
  218. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  219. }else{
  220. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  221. }
  222. }
  223. // _RoleAll
  224. // @Title _RoleAll
  225. // @Description 查找所有角色
  226. // @Success 200 {object} Account
  227. // @Failure 403 :id is empty
  228. func System_RoleAll(c *entitys.CtrlContext) {
  229. ret := __none_func_system__()
  230. if ret {
  231. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  232. }else{
  233. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  234. }
  235. }
  236. // _FindPermissions
  237. // @Title _FindPermissions
  238. // @Description 查找用户权限
  239. // @Success 200 {object} Account
  240. // @Failure 403 :id is empty
  241. func System_FindPermissions(c *entitys.CtrlContext) {
  242. ret := __none_func_system__()
  243. if ret {
  244. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  245. }else{
  246. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  247. }
  248. }
  249. // _AddMenu
  250. // @Title _AddMenu
  251. // @Description 添加菜单
  252. // @Param string false "菜单"
  253. // @Success 200 {object} Account
  254. // @Failure 403 :id is empty
  255. func System_AddMenu(c *entitys.CtrlContext) {
  256. var paramObj0 models.SysMenu
  257. c.Ctx.BindJSON(&paramObj0)
  258. ret := __none_func_system__(paramObj0)
  259. if ret {
  260. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  261. }else{
  262. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  263. }
  264. }
  265. // _DelMenu
  266. // @Title _DelMenu
  267. // @Description 删除菜单
  268. // @Param id string false "菜单ID"
  269. // @Success 200 {object} Account
  270. // @Failure 403 :id is empty
  271. func System_DelMenu(c *entitys.CtrlContext) {
  272. id := c.Ctx.Query("id")
  273. ret := __none_func_system__(id)
  274. if ret {
  275. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  276. }else{
  277. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  278. }
  279. }
  280. // _UpdateMenu
  281. // @Title _UpdateMenu
  282. // @Description 更新菜单
  283. // @Param string false "菜单"
  284. // @Success 200 {object} Account
  285. // @Failure 403 :id is empty
  286. func System_UpdateMenu(c *entitys.CtrlContext) {
  287. var paramObj0 models.SysMenu
  288. c.Ctx.BindJSON(&paramObj0)
  289. ret := __none_func_system__(paramObj0)
  290. if ret {
  291. c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
  292. }else{
  293. c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
  294. }
  295. }
  296. func __none_func_system__(params ... interface{}) bool{
  297. return true
  298. }