role_controller.go 52KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  1. package controllers
  2. import (
  3. "fmt"
  4. "github.com/jinzhu/gorm"
  5. "strconv"
  6. "strings"
  7. "time"
  8. "XT_New/enums"
  9. "XT_New/models"
  10. "XT_New/service"
  11. "github.com/astaxie/beego"
  12. )
  13. func RoleAPIControllerRegistRouters() {
  14. beego.Router("/api/roles", &RoleAPIController{}, "get:GetRoles")
  15. beego.Router("/api/role/create", &RoleAPIController{}, "post:CreateRole")
  16. beego.Router("/api/role/modify", &RoleAPIController{}, "post:ModifyRole")
  17. beego.Router("/api/role/setstatus", &RoleAPIController{}, "post:ModifyRoleStatus")
  18. beego.Router("/role/purview/editinit", &RoleAPIController{}, "get:EditPurviewInitData")
  19. beego.Router("/role/purview/edit", &RoleAPIController{}, "post:EditPurview")
  20. beego.Router("/api/adminmain", &RoleAPIController{}, "get:AdminMainView")
  21. beego.Router("/api/admins", &RoleAPIController{}, "get:Admins")
  22. beego.Router("/api/admin/addinit", &RoleAPIController{}, "get:AddAdminInitData")
  23. beego.Router("/api/admin/add", &RoleAPIController{}, "get:AddAdmin")
  24. beego.Router("/api/admin/editinit", &RoleAPIController{}, "get:EditAdminInitData")
  25. beego.Router("/api/admin/edit", &RoleAPIController{}, "get:EditAdmin")
  26. beego.Router("/api/admin/setstatus", &RoleAPIController{}, "post:AdminSetStatus")
  27. beego.Router("/api/admin/specialpermission/initdata", &RoleAPIController{}, "get:SpecialPermissionInitData")
  28. beego.Router("/api/admin/specialpermission/dialysisrecord/submit", &RoleAPIController{}, "post:SubmitDialysisRecordPermission")
  29. beego.Router("/api/roles/list", &RoleAPIController{}, "get:GetAllOrgRole")
  30. beego.Router("/api/staff", &RoleAPIController{}, "get:GetAllOrgUser")
  31. beego.Router("/api/role/addStaff", &RoleAPIController{}, "post:AddRoleStaff")
  32. beego.Router("/api/role/staff", &RoleAPIController{}, "get:GetRoleStaff")
  33. beego.Router("/api/role", &RoleAPIController{}, "get:GetRoleInfo")
  34. }
  35. type RoleAPIController struct {
  36. BaseAuthAPIController
  37. }
  38. // /api/roles [get]
  39. // @param page?:int
  40. func (this *RoleAPIController) GetRoles() {
  41. page, _ := this.GetInt("page")
  42. adminUserInfo := this.GetAdminUserInfo()
  43. //beego.Alert(adminUserInfo.AdminUser)
  44. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  45. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  46. // return
  47. //}
  48. if page <= 0 {
  49. page = 1
  50. }
  51. roles, total, getRoleErr := service.GetRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 100)
  52. if getRoleErr != nil {
  53. //beego.Error("获取角色列表失败:", getRoleErr)
  54. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  55. } else {
  56. this.ServeSuccessJSON(map[string]interface{}{
  57. "roles": roles,
  58. "total_count": total,
  59. })
  60. }
  61. }
  62. // /api/role/create [post]
  63. // @param name:string
  64. // @param intro:string
  65. func (this *RoleAPIController) CreateRole() {
  66. name := this.GetString("name")
  67. intro := this.GetString("intro")
  68. if len(name) == 0 {
  69. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  70. return
  71. }
  72. adminUserInfo := this.GetAdminUserInfo()
  73. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  74. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  75. // return
  76. //}
  77. total := service.FindRoleRecordByRoleName(name, adminUserInfo.CurrentOrgId)
  78. if total > 0 {
  79. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNameIsExist)
  80. return
  81. }
  82. role, createErr := service.CreateRole(adminUserInfo.AdminUser.Id, adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, name, intro)
  83. if createErr != nil {
  84. //beego.Error("创建角色失败:", createErr)
  85. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
  86. } else {
  87. this.ServeSuccessJSON(map[string]interface{}{
  88. "id": role.Id,
  89. "name": role.RoleName,
  90. "intro": role.RoleIntro,
  91. "status": role.Status,
  92. })
  93. }
  94. }
  95. // /api/role/modify
  96. // @param role_id:int
  97. // @param name:string
  98. // @param intro:string
  99. func (this *RoleAPIController) ModifyRole() {
  100. roleID, _ := this.GetInt64("role_id")
  101. name := this.GetString("name")
  102. intro := this.GetString("intro")
  103. if roleID <= 0 || len(name) == 0 || len(intro) == 0 {
  104. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  105. return
  106. }
  107. //adminUserInfo := this.GetAdminUserInfo()
  108. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  109. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  110. // return
  111. //}
  112. role, getRoleErr := service.GetRoleByRoleID(roleID)
  113. if getRoleErr != nil {
  114. //beego.Error("获取角色失败:", getRoleErr)
  115. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  116. return
  117. } else if role == nil {
  118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
  119. return
  120. }
  121. role.RoleName = name
  122. role.RoleIntro = intro
  123. role.ModifyTime = time.Now().Unix()
  124. saveErr := service.ModifyRole(role)
  125. if saveErr != nil {
  126. //beego.Error("修改角色失败:", role.Id, saveErr)
  127. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  128. } else {
  129. this.ServeSuccessJSON(nil)
  130. }
  131. }
  132. // /api/role/setstatus
  133. // @param role_id:int
  134. // @param enable:bool
  135. func (this *RoleAPIController) ModifyRoleStatus() {
  136. roleID, _ := this.GetInt64("role_id")
  137. enable, _ := this.GetBool("enable")
  138. if roleID <= 0 {
  139. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  140. return
  141. }
  142. adminUserInfo := this.GetAdminUserInfo()
  143. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  144. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  145. // return
  146. //}
  147. role, getRoleErr := service.GetRoleByRoleID(roleID)
  148. if getRoleErr != nil {
  149. //beego.Error("获取角色失败:", getRoleErr)
  150. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  151. return
  152. } else if role == nil {
  153. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
  154. return
  155. }
  156. if enable == false {
  157. if count, _ := service.RoleAdminUserCountTwo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleID); count != 0 {
  158. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCannotRemoveRole)
  159. return
  160. }
  161. }
  162. if enable {
  163. role.Status = 1
  164. } else {
  165. role.Status = 2
  166. }
  167. role.ModifyTime = time.Now().Unix()
  168. saveErr := service.ModifyRole(role)
  169. if saveErr != nil {
  170. //beego.Error("修改角色失败:", role.Id, saveErr)
  171. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  172. } else {
  173. this.ServeSuccessJSON(nil)
  174. }
  175. }
  176. // /role/purview/editinit [get]
  177. // @param role_id:int
  178. func (this *RoleAPIController) EditPurviewInitData() {
  179. //adminUserInfo := this.GetAdminUserInfo()
  180. //if
  181. //}
  182. roleId, _ := this.GetInt64("role_id")
  183. if roleId <= 0 {
  184. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  185. return
  186. }
  187. role, _ := service.GetRoleByRoleID(roleId)
  188. //purviews_xt, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed(3)
  189. purviews_scrm, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed(6)
  190. purviews_cdm, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed(4)
  191. purviews_mall, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed(7)
  192. purviews_ky_mall, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed(8)
  193. purviews_func, _ := service.GetAllGeneralFuncPurviewVMsProcessed()
  194. //门诊
  195. outpatientRegistration, _, _ := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientRegistration/manage")
  196. //电子病历
  197. _, _, originEle := service.GetOtherAllGeneralPurviewVMsProcessed("/patinets/ele")
  198. //透析管理
  199. _, _, originDialysis := service.GetOtherAllGeneralPurviewVMsProcessed("/dialysis/manage")
  200. //库房管理
  201. _, _, originStock := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/manange")
  202. //配置管理
  203. //_, _, orginConfig := service.GetOtherAllGeneralPurviewVMsProcessed("/config/manage")
  204. //门诊管理
  205. _, _, outpatientRegistrationPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientRegistration/index")
  206. _, _, outpatientRegistrationPurviewTwo := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientDoctorStation")
  207. _, _, outpatientRegistrationPurviewThree := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientCharges")
  208. _, _, outpatientRegistrationPurviewFour := service.GetOtherAllGeneralPurviewVMsProcessed("/hospitalStation")
  209. //透析管理
  210. _, _, originDialysisWatchPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/dialysis/watch")
  211. _, _, originWorkforcePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/workforce/patient")
  212. _, _, originSignPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/sign/lineup")
  213. _, _, originMedicalSchedulingPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/medicalScheduling/index")
  214. _, _, originQcdPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/qcd/manage")
  215. _, _, originDevicePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/device/manage")
  216. _, _, originDataUploadPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/data/upload")
  217. _, _, originConsumablesPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/consumablesManagement")
  218. _, _, originDrugsPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/drugs")
  219. _, _, originSelfPreparedMedicinePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/selfPreparedMedicineIndex")
  220. _, _, originOtherPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/other")
  221. _, _, originCkPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/stock/warehousequery")
  222. _, _, originIntegrationPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/integration/manage")
  223. _, _, originTemplatePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/template/manage")
  224. _, _, originDictMedicinePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/dict/manage")
  225. _, _, originBedPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/bed/manage")
  226. //采购管理
  227. _, _, purchaseManagerPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/supply/query")
  228. //门诊管理
  229. subPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  230. subPurviewTreeViewModelTwo := []*service.PurviewTreeViewModel{}
  231. subPurviewTreeViewModelThree := []*service.PurviewTreeViewModel{}
  232. subPurviewTreeViewModelFour := []*service.PurviewTreeViewModel{}
  233. subPurviewTreeViewModelFive := []*service.PurviewTreeViewModel{}
  234. for _, item := range outpatientRegistrationPurview {
  235. temp := &service.PurviewTreeViewModel{
  236. ID: item.Id,
  237. PID: item.Parentid,
  238. Name: item.Name,
  239. Number: 1,
  240. }
  241. subPurviewTreeViewModel = append(subPurviewTreeViewModel, temp)
  242. }
  243. for _, item := range outpatientRegistrationPurviewTwo {
  244. temp := &service.PurviewTreeViewModel{
  245. ID: item.Id,
  246. PID: item.Parentid,
  247. Name: item.Name,
  248. Number: 1,
  249. }
  250. subPurviewTreeViewModelTwo = append(subPurviewTreeViewModelTwo, temp)
  251. }
  252. for _, item := range outpatientRegistrationPurviewThree {
  253. temp := &service.PurviewTreeViewModel{
  254. ID: item.Id,
  255. PID: item.Parentid,
  256. Name: item.Name,
  257. Number: 1,
  258. }
  259. subPurviewTreeViewModelThree = append(subPurviewTreeViewModelThree, temp)
  260. }
  261. for _, item := range outpatientRegistrationPurviewFour {
  262. temp := &service.PurviewTreeViewModel{
  263. ID: item.Id,
  264. PID: item.Parentid,
  265. Name: item.Name,
  266. Number: 1,
  267. }
  268. subPurviewTreeViewModelFour = append(subPurviewTreeViewModelFour, temp)
  269. }
  270. //采购管理
  271. for _, item := range purchaseManagerPurview {
  272. temp := &service.PurviewTreeViewModel{
  273. ID: item.Id,
  274. PID: item.Parentid,
  275. Name: item.Name,
  276. Number: 1,
  277. }
  278. subPurviewTreeViewModelFive = append(subPurviewTreeViewModelFive, temp)
  279. }
  280. for _, item := range outpatientRegistration {
  281. if item.Name == "门诊挂号" {
  282. item.Childs = append(item.Childs, subPurviewTreeViewModel...)
  283. }
  284. if item.Name == "门诊医生站" {
  285. item.Childs = append(item.Childs, subPurviewTreeViewModelTwo...)
  286. }
  287. if item.Name == "门诊收费" {
  288. item.Childs = append(item.Childs, subPurviewTreeViewModelThree...)
  289. }
  290. if item.Name == "住院工作站" {
  291. item.Childs = append(item.Childs, subPurviewTreeViewModelFour...)
  292. }
  293. }
  294. //电子病历
  295. subElePurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  296. for _, item := range originEle {
  297. temp := &service.PurviewTreeViewModel{
  298. ID: item.Id,
  299. PID: item.Parentid,
  300. Name: item.Name,
  301. Number: 1,
  302. }
  303. subElePurviewTreeViewModel = append(subElePurviewTreeViewModel, temp)
  304. }
  305. //透析管理
  306. subDialysisPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  307. for _, item := range originDialysis {
  308. temp := &service.PurviewTreeViewModel{
  309. ID: item.Id,
  310. PID: item.Parentid,
  311. Name: item.Name,
  312. Number: 1,
  313. }
  314. subDialysisPurviewTreeViewModel = append(subDialysisPurviewTreeViewModel, temp)
  315. }
  316. //库存管理
  317. subStockPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  318. for _, item := range originStock {
  319. temp := &service.PurviewTreeViewModel{
  320. ID: item.Id,
  321. PID: item.Parentid,
  322. Name: item.Name,
  323. Number: 1,
  324. }
  325. subStockPurviewTreeViewModel = append(subStockPurviewTreeViewModel, temp)
  326. }
  327. ////配置管理
  328. //subConfigPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  329. //for _, item := range orginConfig {
  330. // temp := &service.PurviewTreeViewModel{
  331. // ID: item.Id,
  332. // PID: item.Parentid,
  333. // Name: item.Name,
  334. // Number: 1,
  335. // }
  336. // subConfigPurviewTreeViewModel = append(subConfigPurviewTreeViewModel, temp)
  337. //}
  338. //
  339. //
  340. //监测管理
  341. subWatchPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  342. for _, item := range originDialysisWatchPurview {
  343. temp := &service.PurviewTreeViewModel{
  344. ID: item.Id,
  345. PID: item.Parentid,
  346. Name: item.Name,
  347. Number: 1,
  348. }
  349. subWatchPurviewTreeViewModel = append(subWatchPurviewTreeViewModel, temp)
  350. }
  351. //排班管理
  352. subWorkforcePurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  353. for _, item := range originWorkforcePurview {
  354. temp := &service.PurviewTreeViewModel{
  355. ID: item.Id,
  356. PID: item.Parentid,
  357. Name: item.Name,
  358. Number: 1,
  359. }
  360. subWorkforcePurviewTreeViewModel = append(subWorkforcePurviewTreeViewModel, temp)
  361. }
  362. //签到排队
  363. subSignPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  364. for _, item := range originSignPurview {
  365. temp := &service.PurviewTreeViewModel{
  366. ID: item.Id,
  367. PID: item.Parentid,
  368. Name: item.Name,
  369. Number: 1,
  370. }
  371. subSignPurviewTreeViewModel = append(subSignPurviewTreeViewModel, temp)
  372. }
  373. //医护排班
  374. subMedicalSchedulingPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  375. for _, item := range originMedicalSchedulingPurview {
  376. temp := &service.PurviewTreeViewModel{
  377. ID: item.Id,
  378. PID: item.Parentid,
  379. Name: item.Name,
  380. Number: 1,
  381. }
  382. subMedicalSchedulingPurviewTreeViewModel = append(subMedicalSchedulingPurviewTreeViewModel, temp)
  383. }
  384. subQCDPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  385. for _, item := range originQcdPurview {
  386. temp := &service.PurviewTreeViewModel{
  387. ID: item.Id,
  388. PID: item.Parentid,
  389. Name: item.Name,
  390. Number: 1,
  391. }
  392. subQCDPurviewTreeViewModel = append(subQCDPurviewTreeViewModel, temp)
  393. }
  394. subDevicePurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  395. for _, item := range originDevicePurview {
  396. temp := &service.PurviewTreeViewModel{
  397. ID: item.Id,
  398. PID: item.Parentid,
  399. Name: item.Name,
  400. Number: 1,
  401. }
  402. subDevicePurviewTreeViewModel = append(subDevicePurviewTreeViewModel, temp)
  403. }
  404. subDataUploadPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  405. for _, item := range originDataUploadPurview {
  406. temp := &service.PurviewTreeViewModel{
  407. ID: item.Id,
  408. PID: item.Parentid,
  409. Name: item.Name,
  410. Number: 1,
  411. }
  412. subDataUploadPurviewTreeViewModel = append(subDataUploadPurviewTreeViewModel, temp)
  413. }
  414. subConsumablesPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  415. for _, item := range originConsumablesPurview {
  416. temp := &service.PurviewTreeViewModel{
  417. ID: item.Id,
  418. PID: item.Parentid,
  419. Name: item.Name,
  420. Number: 1,
  421. }
  422. subConsumablesPurviewTreeViewModel = append(subConsumablesPurviewTreeViewModel, temp)
  423. }
  424. subDrugPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  425. for _, item := range originDrugsPurview {
  426. temp := &service.PurviewTreeViewModel{
  427. ID: item.Id,
  428. PID: item.Parentid,
  429. Name: item.Name,
  430. Number: 1,
  431. }
  432. subDrugPurviewTreeViewModel = append(subDrugPurviewTreeViewModel, temp)
  433. }
  434. subSelfPreparedMedicinePurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  435. for _, item := range originSelfPreparedMedicinePurview {
  436. temp := &service.PurviewTreeViewModel{
  437. ID: item.Id,
  438. PID: item.Parentid,
  439. Name: item.Name,
  440. Number: 1,
  441. }
  442. subSelfPreparedMedicinePurviewTreeViewModel = append(subSelfPreparedMedicinePurviewTreeViewModel, temp)
  443. }
  444. subOtherPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  445. for _, item := range originOtherPurview {
  446. temp := &service.PurviewTreeViewModel{
  447. ID: item.Id,
  448. PID: item.Parentid,
  449. Name: item.Name,
  450. Number: 1,
  451. }
  452. subOtherPurviewTreeViewModel = append(subOtherPurviewTreeViewModel, temp)
  453. }
  454. subCkPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  455. for _, item := range originCkPurview {
  456. temp := &service.PurviewTreeViewModel{
  457. ID: item.Id,
  458. PID: item.Parentid,
  459. Name: item.Name,
  460. Number: 1,
  461. }
  462. subCkPurviewTreeViewModel = append(subCkPurviewTreeViewModel, temp)
  463. }
  464. subIntegrationPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  465. for _, item := range originIntegrationPurview {
  466. temp := &service.PurviewTreeViewModel{
  467. ID: item.Id,
  468. PID: item.Parentid,
  469. Name: item.Name,
  470. Number: 1,
  471. }
  472. subIntegrationPurviewTreeViewModel = append(subIntegrationPurviewTreeViewModel, temp)
  473. }
  474. subTemplatePurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  475. for _, item := range originTemplatePurview {
  476. temp := &service.PurviewTreeViewModel{
  477. ID: item.Id,
  478. PID: item.Parentid,
  479. Name: item.Name,
  480. Number: 1,
  481. }
  482. subTemplatePurviewTreeViewModel = append(subTemplatePurviewTreeViewModel, temp)
  483. }
  484. subDictPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
  485. for _, item := range originDictMedicinePurview {
  486. temp := &service.PurviewTreeViewModel{
  487. ID: item.Id,
  488. PID: item.Parentid,
  489. Name: item.Name,
  490. Number: 1,
  491. }
  492. subDictPurviewTreeViewModel = append(subDictPurviewTreeViewModel, temp)
  493. }
  494. subBedPrviewTreeViewModel := []*service.PurviewTreeViewModel{}
  495. for _, item := range originBedPurview {
  496. temp := &service.PurviewTreeViewModel{
  497. ID: item.Id,
  498. PID: item.Parentid,
  499. Name: item.Name,
  500. Number: 1,
  501. }
  502. subBedPrviewTreeViewModel = append(subBedPrviewTreeViewModel, temp)
  503. }
  504. for _, item := range subDialysisPurviewTreeViewModel {
  505. if item.Name == "透析记录" {
  506. item.Childs = append(item.Childs, purviews_func...)
  507. }
  508. if item.Name == "透析监控" {
  509. item.Childs = append(item.Childs, subWatchPurviewTreeViewModel...)
  510. }
  511. if item.Name == "患者排班" {
  512. item.Childs = append(item.Childs, subWorkforcePurviewTreeViewModel...)
  513. }
  514. if item.Name == "签到排队" {
  515. item.Childs = append(item.Childs, subSignPurviewTreeViewModel...)
  516. }
  517. if item.Name == "医护排班" {
  518. item.Childs = append(item.Childs, subMedicalSchedulingPurviewTreeViewModel...)
  519. }
  520. if item.Name == "质控管理" {
  521. item.Childs = append(item.Childs, subQCDPurviewTreeViewModel...)
  522. }
  523. if item.Name == "院感管理" {
  524. item.Childs = append(item.Childs, subDevicePurviewTreeViewModel...)
  525. }
  526. if item.Name == "质控上报" {
  527. item.Childs = append(item.Childs, subDataUploadPurviewTreeViewModel...)
  528. }
  529. }
  530. for _, item := range subStockPurviewTreeViewModel {
  531. if item.Name == "耗材管理" {
  532. item.Childs = append(item.Childs, subConsumablesPurviewTreeViewModel...)
  533. }
  534. if item.Name == "药库管理" {
  535. item.Childs = append(item.Childs, subDrugPurviewTreeViewModel...)
  536. }
  537. if item.Name == "自备药管理" {
  538. item.Childs = append(item.Childs, subSelfPreparedMedicinePurviewTreeViewModel...)
  539. }
  540. if item.Name == "其他管理" {
  541. item.Childs = append(item.Childs, subOtherPurviewTreeViewModel...)
  542. }
  543. if item.Name == "仓库管理" {
  544. item.Childs = append(item.Childs, subCkPurviewTreeViewModel...)
  545. }
  546. }
  547. //for _, item := range subConfigPurviewTreeViewModel {
  548. // if item.Name == "集成管理" {
  549. // item.Childs = append(item.Childs, subIntegrationPurviewTreeViewModel...)
  550. // }
  551. // if item.Name == "模版管理" {
  552. // item.Childs = append(item.Childs, subTemplatePurviewTreeViewModel...)
  553. // }
  554. // if item.Name == "字典管理" {
  555. // item.Childs = append(item.Childs, subDictPurviewTreeViewModel...)
  556. // }
  557. // if item.Name == "床位管理" {
  558. // item.Childs = append(item.Childs, subBedPrviewTreeViewModel...)
  559. // }
  560. //
  561. //}
  562. purviews := []*service.PurviewTreeViewModel{}
  563. menzhen := &service.PurviewTreeViewModel{
  564. ID: 0,
  565. PID: 0,
  566. Name: "门诊管理",
  567. Number: 3,
  568. Childs: outpatientRegistration,
  569. }
  570. purviews = append(purviews, menzhen)
  571. dianzi := &service.PurviewTreeViewModel{
  572. ID: 0,
  573. PID: 0,
  574. Name: "电子病历",
  575. Number: 3,
  576. Childs: subElePurviewTreeViewModel,
  577. }
  578. purviews = append(purviews, dianzi)
  579. caigou := &service.PurviewTreeViewModel{
  580. ID: 0,
  581. PID: 0,
  582. Name: "采购管理",
  583. Number: 3,
  584. Childs: subPurviewTreeViewModelFive,
  585. }
  586. purviews = append(purviews, caigou)
  587. touxi := &service.PurviewTreeViewModel{
  588. ID: 0,
  589. PID: 0,
  590. Name: "透析管理",
  591. Number: 3,
  592. Childs: subDialysisPurviewTreeViewModel,
  593. }
  594. purviews = append(purviews, touxi)
  595. kufang := &service.PurviewTreeViewModel{
  596. ID: 0,
  597. PID: 0,
  598. Name: "库房管理",
  599. Number: 3,
  600. Childs: subStockPurviewTreeViewModel,
  601. }
  602. purviews = append(purviews, kufang)
  603. ky_mall := &service.PurviewTreeViewModel{
  604. ID: 0,
  605. PID: 0,
  606. Name: "酷医商城",
  607. Number: 3,
  608. Childs: purviews_ky_mall,
  609. }
  610. purviews = append(purviews, ky_mall)
  611. cdm := &service.PurviewTreeViewModel{
  612. ID: 0,
  613. PID: 0,
  614. Number: 3,
  615. Name: "慢病管理",
  616. Childs: purviews_cdm,
  617. }
  618. purviews = append(purviews, cdm)
  619. scrm := &service.PurviewTreeViewModel{
  620. ID: 0,
  621. PID: 0,
  622. Name: "营销管理",
  623. Number: 3,
  624. Childs: purviews_scrm,
  625. }
  626. purviews = append(purviews, scrm)
  627. mall := &service.PurviewTreeViewModel{
  628. ID: 0,
  629. PID: 0,
  630. Name: "分销商城",
  631. Number: 3,
  632. Childs: purviews_mall,
  633. }
  634. purviews = append(purviews, mall)
  635. //peizhi := &service.PurviewTreeViewModel{
  636. // ID: 0,
  637. // PID: 0,
  638. // Name: "配置管理",
  639. // Number: 3,
  640. // Childs: subConfigPurviewTreeViewModel,
  641. //}
  642. //purviews = append(purviews, peizhi)
  643. if getPurviewsErr != nil {
  644. //beego.Error("获取所有权限时出错:", getPurviewsErr)
  645. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  646. return
  647. }
  648. rolePurviewIdStr, getRPIdsErr := service.GetRolePurviewIds(roleId)
  649. if getRPIdsErr != nil {
  650. //beego.Error("获取角色的权限时出错:", getRPIdsErr)
  651. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  652. return
  653. }
  654. roleFuncPurview, getFuncRPIdsErr := service.GetRoleFuncPurview(roleId)
  655. if getFuncRPIdsErr == gorm.ErrRecordNotFound {
  656. //beego.Error("获取角色的权限时出错:", getRPIdsErr)
  657. if roleFuncPurview.ID == 0 {
  658. rolePurviewIdStr = rolePurviewIdStr
  659. } else {
  660. rolePurviewIdStr = rolePurviewIdStr + "," + roleFuncPurview.PurviewIds
  661. }
  662. } else if getFuncRPIdsErr != nil {
  663. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. } else {
  666. if roleFuncPurview.ID == 0 {
  667. rolePurviewIdStr = rolePurviewIdStr
  668. } else {
  669. rolePurviewIdStr = rolePurviewIdStr + "," + roleFuncPurview.PurviewIds
  670. }
  671. }
  672. this.ServeSuccessJSON(map[string]interface{}{
  673. "purviews": purviews,
  674. "role": role,
  675. "role_purview_ids": rolePurviewIdStr + "," + roleFuncPurview.PurviewIds,
  676. })
  677. }
  678. // /role/purview/edit [post]
  679. // @param role_id:int
  680. // @param purview_ids:string
  681. func (this *RoleAPIController) EditPurview() {
  682. adminUserInfo := this.GetAdminUserInfo()
  683. roleId, _ := this.GetInt64("role_id")
  684. purviewIds := this.GetString("purview_ids")
  685. funcPurviewIds := this.GetString("func_purview_ids")
  686. if roleId <= 0 {
  687. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  688. return
  689. }
  690. redis := service.RedisClient()
  691. defer redis.Close()
  692. users := service.GetAllUserRole(adminUserInfo.CurrentOrgId)
  693. for _, item := range users {
  694. key := "purviews_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + strconv.FormatInt(item.AdminUserId, 10)
  695. redis.Set(key, "", time.Second)
  696. }
  697. err := service.SaveRolePurviewIds(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId, purviewIds)
  698. err = service.SaveFuncRolePurviewIds(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId, funcPurviewIds)
  699. if err != nil {
  700. //beego.Error("设置角色的权限时出错:", err)
  701. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  702. } else {
  703. this.ServeSuccessJSON(nil)
  704. }
  705. }
  706. // func (this *RoleAPIController) doesUserHaveAccess(userID int64) bool {
  707. // adminUser, getAdminUserErr := service.GetAdminUserByUserID(userID)
  708. // if getAdminUserErr != nil {
  709. // beego.Error("获取用户信息失败:%v", getAdminUserErr)
  710. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  711. // return false
  712. // } else if adminUser == nil {
  713. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
  714. // return false
  715. // } else if adminUser.Status == 2 {
  716. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUserWasForbidden)
  717. // return false
  718. // } else if adminUser.IsSuperAdmin == false {
  719. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  720. // return false
  721. // }
  722. // return true
  723. // }
  724. // func (this *RoleAPIController) isAppRoleExist(orgID int64, appID int64, userID int64) bool {
  725. // appRole, getAppRoleErr := service.GetAppRole(orgID, appID, userID)
  726. // if getAppRoleErr != nil {
  727. // beego.Error("检查用户和机构应用对应关系时失败:%v", getAppRoleErr)
  728. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. // return false
  730. // } else if appRole == nil {
  731. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  732. // return false
  733. // }
  734. // return true
  735. // }
  736. // /api/adminmain [get]
  737. func (this *RoleAPIController) AdminMainView() {
  738. adminUserInfo := this.GetAdminUserInfo()
  739. var isSubSuperAdmin bool = false
  740. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  741. if len(adminUserRole.RoleIds) > 0 {
  742. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  743. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  744. if adminUserInfo.AdminUser.Id != org.Creator {
  745. for _, item := range role_ids {
  746. id, _ := strconv.ParseInt(item, 10, 64)
  747. if id != 0 {
  748. role, _ := service.GetRoleByRoleID(id)
  749. if role != nil {
  750. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  751. isSubSuperAdmin = true
  752. }
  753. }
  754. }
  755. }
  756. }
  757. }
  758. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  759. viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
  760. if getAdminsErr != nil {
  761. //beego.Error("获取管理员列表失败:", getAdminsErr)
  762. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. this.ServeSuccessJSON(map[string]interface{}{
  766. "admins": viewModels,
  767. "org": org,
  768. "isSubSuperAdmin": isSubSuperAdmin,
  769. })
  770. }
  771. // /api/admins [get]
  772. // @param page?:int
  773. func (this *RoleAPIController) Admins() {
  774. adminUserInfo := this.GetAdminUserInfo()
  775. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  776. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  777. // return
  778. //}
  779. page, _ := this.GetInt("page")
  780. viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 100)
  781. if getAdminsErr != nil {
  782. //beego.Error("获取管理员列表失败:", getAdminsErr)
  783. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  784. } else {
  785. this.ServeSuccessJSON(map[string]interface{}{
  786. "admins": viewModels,
  787. "total_count": total,
  788. })
  789. }
  790. }
  791. // /api/admin/addinit [get]
  792. func (this *RoleAPIController) AddAdminInitData() {
  793. adminUserInfo := this.GetAdminUserInfo()
  794. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  795. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  796. // return
  797. //}
  798. var isSubSuperAdmin bool = false
  799. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  800. if len(adminUserRole.RoleIds) > 0 {
  801. //app_role, _ := service.GetAppRoleById(adminUserInfo.)
  802. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  803. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  804. if adminUserInfo.AdminUser.Id != org.Creator {
  805. for _, item := range role_ids {
  806. id, _ := strconv.ParseInt(item, 10, 64)
  807. if id != 0 {
  808. role, _ := service.GetRoleByRoleID(id)
  809. if role != nil {
  810. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  811. isSubSuperAdmin = true
  812. }
  813. }
  814. }
  815. }
  816. }
  817. }
  818. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  819. roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  820. if getRoleErr != nil {
  821. //beego.Error("获取所有角色失败:", getRoleErr)
  822. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  823. return
  824. }
  825. redisClient := service.RedisClient()
  826. defer redisClient.Close()
  827. qntoken, _ := redisClient.Get("qn_token").Result()
  828. this.ServeSuccessJSON(map[string]interface{}{
  829. "roles": roles,
  830. "qntoken": qntoken,
  831. "isSubSuperAdmin": isSubSuperAdmin,
  832. "org": org,
  833. })
  834. }
  835. // /api/admin/add [post]
  836. // @param mobile:string
  837. // @param name:string
  838. // @param type:int 管理员类型:2.医生 3.护士 4.运营
  839. // @param title:int 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
  840. // @param role:int
  841. // @param intro?:string
  842. func (this *RoleAPIController) AddAdmin() {
  843. adminUserInfo := this.GetAdminUserInfo()
  844. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  845. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  846. // return
  847. //}
  848. mobile := this.GetString("mobile")
  849. name := this.GetString("name")
  850. userType, _ := this.GetInt("type")
  851. userTitle, _ := this.GetInt("title")
  852. roleIds := this.GetString("role")
  853. user_title_name := this.GetString("user_title_name")
  854. department := this.GetString("department")
  855. department_id, _ := this.GetInt64("department_id")
  856. sex, _ := this.GetInt64("sex")
  857. age, _ := this.GetInt64("age")
  858. nation := this.GetString("nation")
  859. card_type, _ := this.GetInt64("card_type")
  860. id_card := this.GetString("id_card")
  861. education, _ := this.GetInt64("education")
  862. study_major_name := this.GetString("study_major_name")
  863. work_major_name := this.GetString("work_major_name")
  864. role_type, _ := this.GetInt64("role_type")
  865. medical_code := this.GetString("medical_code")
  866. doctor_code := this.GetString("doctor_code")
  867. licensing, _ := this.GetInt64("licensing")
  868. job_number := this.GetString("job_number")
  869. prescription_qualification_identification, _ := this.GetInt64("prescription_qualification_identification")
  870. identification_outpatients, _ := this.GetInt64("identification_outpatients")
  871. timeLayout := "2006-01-02"
  872. loc, _ := time.LoadLocation("Local")
  873. start_time := this.GetString("start_time")
  874. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  875. medical_range_code, _ := this.GetInt64("medical_range_code")
  876. medical_level, _ := this.GetInt64("medical_level")
  877. medical_type_job, _ := this.GetInt64("medical_type_job")
  878. pharmacist_registration_number := this.GetString("pharmacist_registration_number")
  879. doctor_range_code, _ := this.GetInt64("doctor_range_code")
  880. doctor_level, _ := this.GetInt64("doctor_level")
  881. doctor_type_job, _ := this.GetInt64("doctor_type_job")
  882. doctor_number := this.GetString("doctor_number")
  883. outpatient_illnessCategory := this.GetString("outpatient_illnessCategory")
  884. is_active, _ := this.GetInt64("is_active")
  885. active_status, _ := this.GetInt64("active_status")
  886. fmt.Println("active_status", active_status)
  887. if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
  888. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  889. return
  890. }
  891. // 判断是否已存在该手机号
  892. if adminUser, err := service.GetValidAdminUserByMobileReturnErr(mobile); err != nil {
  893. //beego.Error("查询用户是否已被添加为管理员时失败:", err)
  894. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  895. return
  896. } else {
  897. if adminUser == nil { //新增账号和用户
  898. _, password, createErr := service.CreateGeneralAdminUserOne(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle, department_id, department, sex, age, nation, card_type, id_card, education, study_major_name, work_major_name, role_type, medical_code, doctor_code, licensing, job_number, prescription_qualification_identification, identification_outpatients, theStartTime.Unix(), medical_range_code, medical_level, medical_type_job, pharmacist_registration_number, doctor_range_code, doctor_level, doctor_type_job, doctor_number, outpatient_illnessCategory, is_active, active_status)
  899. if createErr != nil {
  900. //beego.Error("创建管理员失败:", createErr)
  901. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
  902. return
  903. } else {
  904. sendSMSErr := service.SMSSendInviteMobileToJoinOrgAdmin(name, mobile, password)
  905. if sendSMSErr != nil {
  906. }
  907. this.ServeSuccessJSON(nil)
  908. return
  909. }
  910. } else {
  911. total, _ := service.FindAdminUserByID(adminUser.Id, adminUserInfo.CurrentOrgId)
  912. if total <= 0 {
  913. //新增用户
  914. app_role := &models.App_Role{
  915. AdminUserId: adminUser.Id,
  916. OrgId: adminUserInfo.CurrentOrgId,
  917. AppId: adminUserInfo.CurrentAppId,
  918. Avatar: "",
  919. UserName: name,
  920. UserTitleName: user_title_name,
  921. Status: 1,
  922. UserType: int8(userType),
  923. UserTitle: int8(userTitle),
  924. CreateTime: time.Now().Unix(),
  925. ModifyTime: time.Now().Unix(),
  926. RoleIds: roleIds,
  927. Department: department,
  928. DepartmentId: department_id,
  929. Sex: sex,
  930. Age: age,
  931. Nation: nation,
  932. CardType: card_type,
  933. IdCard: id_card,
  934. Education: education,
  935. StudyMajorName: study_major_name,
  936. WorkMajorName: work_major_name,
  937. RoleType: role_type,
  938. MedicalCode: medical_code,
  939. DoctorCode: doctor_code,
  940. Licensing: licensing,
  941. JobNumber: job_number,
  942. PrescriptionQualificationIdentification: prescription_qualification_identification,
  943. IdentificationOutpatients: identification_outpatients,
  944. StartTime: theStartTime.Unix(),
  945. MedicalRangeCode: medical_range_code,
  946. MedicalLevel: medical_level,
  947. MedicalTypeJob: medical_type_job,
  948. PharmacistRegistrationNumber: pharmacist_registration_number,
  949. DoctorRangeCode: doctor_range_code,
  950. DoctorLevel: doctor_level,
  951. DoctorTypeJob: doctor_type_job,
  952. DoctorNumber: doctor_number,
  953. OutpatientIllnesscategory: outpatient_illnessCategory,
  954. IsActive: is_active,
  955. ActiveStatus: active_status,
  956. }
  957. err := service.CreateUserRole(app_role)
  958. if err != nil {
  959. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
  960. return
  961. }
  962. this.ServeSuccessJSON(nil)
  963. } else {
  964. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRepeatCreateStaffException)
  965. return
  966. }
  967. return
  968. }
  969. }
  970. }
  971. // /api/admin/editinit [get]
  972. // @param uid:int
  973. func (this *RoleAPIController) EditAdminInitData() {
  974. adminUserInfo := this.GetAdminUserInfo()
  975. admin_user_id, _ := this.GetInt64("uid")
  976. if admin_user_id <= 0 {
  977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  978. return
  979. }
  980. appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, admin_user_id)
  981. if getAppRoleErr != nil {
  982. //beego.Error("查询管理员信息时失败:", getAppRoleErr)
  983. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. if appRole == nil {
  987. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
  988. return
  989. }
  990. roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  991. if getRoleErr != nil {
  992. //beego.Error("获取所有角色失败:", getRoleErr)
  993. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  994. return
  995. }
  996. var isSubSuperAdmin bool = false
  997. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  998. if len(adminUserRole.RoleIds) > 0 {
  999. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  1000. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1001. if adminUserInfo.AdminUser.Id != org.Creator {
  1002. for _, item := range role_ids {
  1003. id, _ := strconv.ParseInt(item, 10, 64)
  1004. if id != 0 {
  1005. role, _ := service.GetRoleByRoleID(id)
  1006. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  1007. isSubSuperAdmin = true
  1008. }
  1009. }
  1010. }
  1011. }
  1012. }
  1013. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1014. redisClient := service.RedisClient()
  1015. defer redisClient.Close()
  1016. qntoken, _ := redisClient.Get("qn_token").Result()
  1017. this.ServeSuccessJSON(map[string]interface{}{
  1018. "admin": appRole,
  1019. "roles": roles,
  1020. "qntoken": qntoken,
  1021. "isSubSuperAdmin": isSubSuperAdmin,
  1022. "org": org,
  1023. })
  1024. }
  1025. // /api/admin/edit [post]
  1026. // @param uid:int
  1027. // @param name:string
  1028. // @param type:int
  1029. // @param title:int
  1030. // @param role:int
  1031. // @param intro?:string
  1032. func (this *RoleAPIController) EditAdmin() {
  1033. adminUserInfo := this.GetAdminUserInfo()
  1034. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  1035. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  1036. // return
  1037. //}
  1038. adminUserId, _ := this.GetInt64("uid")
  1039. name := this.GetString("name")
  1040. userType, _ := this.GetInt("type")
  1041. userTitle, _ := this.GetInt("title")
  1042. roleIds := this.GetString("role")
  1043. intro := this.GetString("intro")
  1044. user_title_name := this.GetString("user_title_name")
  1045. department := this.GetString("department")
  1046. department_id, _ := this.GetInt64("department_id")
  1047. sort, _ := this.GetInt64("sort")
  1048. sex, _ := this.GetInt64("sex")
  1049. age, _ := this.GetInt64("age")
  1050. nation := this.GetString("nation")
  1051. card_type, _ := this.GetInt64("card_type")
  1052. id_card := this.GetString("id_card")
  1053. education, _ := this.GetInt64("education")
  1054. study_major_name := this.GetString("study_major_name")
  1055. work_major_name := this.GetString("work_major_name")
  1056. role_type, _ := this.GetInt64("role_type")
  1057. medical_code := this.GetString("medical_code")
  1058. doctor_code := this.GetString("doctor_code")
  1059. licensing, _ := this.GetInt64("licensing")
  1060. job_number := this.GetString("job_number")
  1061. prescription_qualification_identification, _ := this.GetInt64("prescription_qualification_identification")
  1062. identification_outpatients, _ := this.GetInt64("identification_outpatients")
  1063. timeLayout := "2006-01-02"
  1064. loc, _ := time.LoadLocation("Local")
  1065. start_time := this.GetString("start_time")
  1066. fmt.Println("start_time22222222222", start_time)
  1067. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1068. medical_range_code, _ := this.GetInt64("medical_range_code")
  1069. medical_level, _ := this.GetInt64("medical_level")
  1070. medical_type_job, _ := this.GetInt64("medical_type_job")
  1071. pharmacist_registration_number := this.GetString("pharmacist_registration_number")
  1072. doctor_range_code, _ := this.GetInt64("doctor_range_code")
  1073. doctor_level, _ := this.GetInt64("doctor_level")
  1074. doctor_type_job, _ := this.GetInt64("doctor_type_job")
  1075. doctor_number := this.GetString("doctor_number")
  1076. outpatient_illnessCategory := this.GetString("outpatient_illnessCategory")
  1077. is_active, _ := this.GetInt64("is_active")
  1078. active_status, _ := this.GetInt64("active_status")
  1079. _, titleExist := models.UserTitle[userTitle]
  1080. fmt.Println(titleExist)
  1081. if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || len(roleIds) <= 0 {
  1082. fmt.Println("进来了吗")
  1083. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1084. return
  1085. }
  1086. appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserId)
  1087. if getAppRoleErr != nil {
  1088. //beego.Error("查询管理员信息时失败:", getAppRoleErr)
  1089. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1090. return
  1091. }
  1092. if appRole == nil {
  1093. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
  1094. return
  1095. }
  1096. appRole.OrgId = this.GetAdminUserInfo().CurrentOrgId
  1097. appRole.Department = department
  1098. appRole.DepartmentId = department_id
  1099. appRole.UserName = name
  1100. appRole.UserType = int8(userType)
  1101. appRole.UserTitle = int8(userTitle)
  1102. appRole.RoleIds = roleIds
  1103. appRole.Intro = intro
  1104. appRole.UserTitleName = user_title_name
  1105. appRole.ModifyTime = time.Now().Unix()
  1106. appRole.Sort = sort
  1107. appRole.Age = age
  1108. appRole.Nation = nation
  1109. appRole.CardType = card_type
  1110. appRole.IdCard = id_card
  1111. appRole.Education = education
  1112. appRole.StudyMajorName = study_major_name
  1113. appRole.WorkMajorName = work_major_name
  1114. appRole.RoleType = role_type
  1115. appRole.MedicalCode = medical_code
  1116. appRole.DoctorCode = doctor_code
  1117. appRole.Licensing = licensing
  1118. appRole.JobNumber = job_number
  1119. appRole.PrescriptionQualificationIdentification = prescription_qualification_identification
  1120. appRole.IdentificationOutpatients = identification_outpatients
  1121. appRole.StartTime = theStartTime.Unix()
  1122. appRole.MedicalCode = medical_code
  1123. appRole.MedicalRangeCode = medical_range_code
  1124. appRole.MedicalLevel = medical_level
  1125. appRole.MedicalTypeJob = medical_type_job
  1126. appRole.PharmacistRegistrationNumber = pharmacist_registration_number
  1127. appRole.DoctorRangeCode = doctor_range_code
  1128. appRole.DoctorLevel = doctor_level
  1129. appRole.DoctorTypeJob = doctor_type_job
  1130. appRole.DoctorNumber = doctor_number
  1131. appRole.OutpatientIllnesscategory = outpatient_illnessCategory
  1132. appRole.IsActive = is_active
  1133. appRole.ActiveStatus = active_status
  1134. appRole.Sex = sex
  1135. saveErr := service.SaveAppRole(appRole)
  1136. if saveErr != nil {
  1137. //beego.Error("修改App_Role失败:", saveErr)
  1138. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  1139. } else {
  1140. //判断当前角色是否为机构管理员
  1141. this.ServeSuccessJSON(map[string]interface{}{
  1142. "approle": appRole,
  1143. })
  1144. this.ServeSuccessJSON(nil)
  1145. }
  1146. }
  1147. // /api/admin/setstatus [post]
  1148. // @param uid:int
  1149. // @param enable:bool
  1150. func (this *RoleAPIController) AdminSetStatus() {
  1151. adminUserInfo := this.GetAdminUserInfo()
  1152. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  1153. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  1154. // return
  1155. //}
  1156. userID, _ := this.GetInt64("uid")
  1157. if userID <= 0 {
  1158. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1159. return
  1160. }
  1161. appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, userID)
  1162. if getAppRoleErr != nil {
  1163. //beego.Error("查询管理员信息失败:", getAppRoleErr)
  1164. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. } else if appRole == nil {
  1167. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
  1168. return
  1169. }
  1170. enable, _ := this.GetBool("enable")
  1171. if enable {
  1172. appRole.Status = 1
  1173. } else {
  1174. appRole.Status = 0
  1175. }
  1176. appRole.ModifyTime = time.Now().Unix()
  1177. saveErr := service.SaveAppRole(appRole)
  1178. if saveErr != nil {
  1179. //beego.Error("保存AppRole失败:", saveErr)
  1180. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  1181. } else {
  1182. this.ServeSuccessJSON(nil)
  1183. }
  1184. }
  1185. // /api/admin/specialpermission/initdata [get]
  1186. func (this *RoleAPIController) SpecialPermissionInitData() {
  1187. adminUserInfo := this.GetAdminUserInfo()
  1188. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  1189. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  1190. // return
  1191. //}
  1192. adminUsers, getAdminUsersErr := service.GetAllGeneralAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  1193. if getAdminUsersErr != nil {
  1194. this.ErrorLog("获取所有普通用户失败:%v", getAdminUsersErr)
  1195. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1196. return
  1197. }
  1198. headNurses, getAllHeadNursesErr := service.GetAllValidAdminUsersWithSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
  1199. if getAllHeadNursesErr != nil {
  1200. this.ErrorLog("获取所有拥有护士长特殊权限的用户失败:%v", getAllHeadNursesErr)
  1201. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1202. return
  1203. }
  1204. this.ServeSuccessJSON(map[string]interface{}{
  1205. "users": adminUsers,
  1206. "head_nurses": headNurses,
  1207. })
  1208. }
  1209. // /api/admin/specialpermission/dialysisrecord/submit [post]
  1210. // @param ids:string ("1,2,5")
  1211. func (this *RoleAPIController) SubmitDialysisRecordPermission() {
  1212. adminUserInfo := this.GetAdminUserInfo()
  1213. //if adminUserInfo.AdminUser.IsSuperAdmin == false {
  1214. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
  1215. // return
  1216. //}
  1217. idsString := this.GetString("ids")
  1218. if len(idsString) == 0 {
  1219. // 取消所有用户的护士长权限
  1220. cancelErr := service.CancelAllSpecialPermissionAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
  1221. if cancelErr != nil {
  1222. this.ErrorLog("取消所有用户的护士长权限失败:%v", cancelErr)
  1223. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. } else {
  1226. this.ServeSuccessJSON(nil)
  1227. return
  1228. }
  1229. } else {
  1230. ids := make([]int64, 0)
  1231. idStrs := strings.Split(idsString, ",")
  1232. for _, idStr := range idStrs {
  1233. id, parseErr := strconv.Atoi(idStr)
  1234. if parseErr != nil {
  1235. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1236. return
  1237. }
  1238. ids = append(ids, int64(id))
  1239. }
  1240. headNurses, getAllHeadNursesErr := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
  1241. if getAllHeadNursesErr != nil {
  1242. this.ErrorLog("获取所有拥有或曾拥有护士长特殊权限的用户失败:%v", getAllHeadNursesErr)
  1243. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1244. return
  1245. }
  1246. cancelList := make([]*models.AdminUserSpecialPermission, 0)
  1247. addList := make([]*models.AdminUserSpecialPermission, 0)
  1248. for _, id := range ids {
  1249. exit := false
  1250. for _, headNurse := range headNurses {
  1251. if headNurse.AdminUserID == id {
  1252. exit = true
  1253. if headNurse.Status != 1 {
  1254. headNurse.Status = 1
  1255. headNurse.ModifyTime = time.Now().Unix()
  1256. addList = append(addList, headNurse)
  1257. }
  1258. break
  1259. }
  1260. }
  1261. if exit == false {
  1262. newHeadNurse := &models.AdminUserSpecialPermission{
  1263. OrgID: adminUserInfo.CurrentOrgId,
  1264. AppID: adminUserInfo.CurrentAppId,
  1265. AdminUserID: id,
  1266. Permission: int64(models.SpecialPermissionTypeHeadNurse),
  1267. Status: 1,
  1268. CreateTime: time.Now().Unix(),
  1269. ModifyTime: time.Now().Unix(),
  1270. }
  1271. addList = append(addList, newHeadNurse)
  1272. }
  1273. }
  1274. for _, headNurse := range headNurses {
  1275. cancel := true
  1276. for _, willAdd := range addList {
  1277. if willAdd.AdminUserID == headNurse.AdminUserID {
  1278. cancel = false
  1279. break
  1280. }
  1281. }
  1282. if cancel {
  1283. headNurse.Status = 0
  1284. headNurse.ModifyTime = time.Now().Unix()
  1285. cancelList = append(cancelList, headNurse)
  1286. }
  1287. }
  1288. addErr := service.BatchSaveSpecialPermissionAdminUsers(addList)
  1289. if addErr != nil {
  1290. this.ErrorLog("授权失败:%v", addErr)
  1291. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return
  1293. }
  1294. cancelErr := service.BatchSaveSpecialPermissionAdminUsers(cancelList)
  1295. if cancelErr != nil {
  1296. this.ErrorLog("取消授权失败:%v", cancelErr)
  1297. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. this.ServeSuccessJSON(nil)
  1301. }
  1302. }
  1303. func (this *RoleAPIController) GetAllOrgRole() {
  1304. adminUserInfo := this.GetAdminUserInfo()
  1305. var isSubSuperAdmin bool = false
  1306. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  1307. if len(adminUserRole.RoleIds) > 0 {
  1308. //app_role, _ := service.GetAppRoleById(adminUserInfo.)
  1309. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  1310. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1311. if adminUserInfo.AdminUser.Id != org.Creator {
  1312. for _, item := range role_ids {
  1313. id, _ := strconv.ParseInt(item, 10, 64)
  1314. if id != 0 {
  1315. role, _ := service.GetRoleByRoleID(id)
  1316. if role != nil {
  1317. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  1318. isSubSuperAdmin = true
  1319. }
  1320. }
  1321. }
  1322. }
  1323. }
  1324. }
  1325. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1326. roles, err := service.GetAllOrgValidRoles(adminUserInfo.CurrentOrgId, isSubSuperAdmin)
  1327. if err != nil {
  1328. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. return
  1330. } else {
  1331. this.ServeSuccessJSON(map[string]interface{}{
  1332. "roles": roles,
  1333. "isSubSuperAdmin": isSubSuperAdmin,
  1334. "org": org,
  1335. })
  1336. }
  1337. }
  1338. func (this *RoleAPIController) GetAllOrgUser() {
  1339. adminUserInfo := this.GetAdminUserInfo()
  1340. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1341. var isSubSuperAdmin bool = false
  1342. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  1343. if len(adminUserRole.RoleIds) > 0 {
  1344. //app_role, _ := service.GetAppRoleById(adminUserInfo.)
  1345. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  1346. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1347. if adminUserInfo.AdminUser.Id != org.Creator {
  1348. for _, item := range role_ids {
  1349. id, _ := strconv.ParseInt(item, 10, 64)
  1350. if id != 0 {
  1351. role, _ := service.GetRoleByRoleID(id)
  1352. if role != nil {
  1353. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  1354. isSubSuperAdmin = true
  1355. }
  1356. }
  1357. }
  1358. }
  1359. }
  1360. }
  1361. viewModels, _, _ := service.GetAllAdminUsersAndRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
  1362. this.ServeSuccessJSON(map[string]interface{}{
  1363. "admins": viewModels,
  1364. "org": org,
  1365. "isSubSuperAdmin": isSubSuperAdmin,
  1366. })
  1367. }
  1368. func (this *RoleAPIController) AddRoleStaff() {
  1369. //adminUserInfo := this.GetMobileAdminUserInfo()
  1370. role_id, _ := this.GetInt64("id", 0)
  1371. staff_ids := this.GetString("ids")
  1372. ids := strings.Split(staff_ids, ",")
  1373. for _, item := range ids {
  1374. id, _ := strconv.ParseInt(item, 10, 64)
  1375. role, _ := service.FindAdminUserID(id)
  1376. role.RoleIds = role.RoleIds + "," + strconv.FormatInt(role_id, 10)
  1377. service.SaveAdminUser(&role)
  1378. }
  1379. this.ServeSuccessJSON(map[string]interface{}{
  1380. "msg": "添加成功",
  1381. })
  1382. }
  1383. func (this *RoleAPIController) GetRoleStaff() {
  1384. adminUserInfo := this.GetAdminUserInfo()
  1385. var isSubSuperAdmin bool = false
  1386. adminUserRole, _ := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
  1387. if len(adminUserRole.RoleIds) > 0 {
  1388. role_ids := strings.Split(adminUserRole.RoleIds, ",")
  1389. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1390. if adminUserInfo.AdminUser.Id != org.Creator {
  1391. for _, item := range role_ids {
  1392. id, _ := strconv.ParseInt(item, 10, 64)
  1393. if id != 0 {
  1394. role, _ := service.GetRoleByRoleID(id)
  1395. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  1396. isSubSuperAdmin = true
  1397. }
  1398. }
  1399. }
  1400. }
  1401. }
  1402. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  1403. viewModels, _, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
  1404. if getAdminsErr != nil {
  1405. //beego.Error("获取管理员列表失败:", getAdminsErr)
  1406. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. return
  1408. }
  1409. this.ServeSuccessJSON(map[string]interface{}{
  1410. "admins": viewModels,
  1411. "org": org,
  1412. "isSubSuperAdmin": isSubSuperAdmin,
  1413. })
  1414. }
  1415. func (this *RoleAPIController) GetRoleInfo() {
  1416. roleId, _ := this.GetInt64("role_id")
  1417. if roleId <= 0 {
  1418. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1419. return
  1420. }
  1421. role, _ := service.GetRoleByRoleID(roleId)
  1422. this.ServeSuccessJSON(map[string]interface{}{
  1423. "role": role,
  1424. })
  1425. }