SystemController.go 9.0 KB

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