| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.model.TCrmClinic; |
| | | import com.ruoyi.system.model.TCrmSupplier; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private TCrmSupplierService crmSupplierService; |
| | | @Autowired |
| | | private TCrmClinicService crmClinicService; |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | |
| | | public AjaxResult list(@RequestBody SysUserQuery query) |
| | | { |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | if(roleType == 1 || roleType == 4 || roleType == 5){ |
| | | query.setRoleType(roleType); |
| | | } |
| | | if(roleType == 4){ |
| | | // 查询供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setObjectId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | // 查询诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | query.setObjectId(crmClinic.getId()); |
| | | } |
| | | PageInfo<SysUserVO> list = userService.pageList(query); |
| | | return AjaxResult.success(list); |
| | |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType == 4){ |
| | | // 查询供应商 |
| | | TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) |
| | | .eq(TCrmSupplier::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | user.setObjectId(crmSupplier.getId()); |
| | | } |
| | | if(roleType == 5){ |
| | | // 查询诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | user.setObjectId(crmClinic.getId()); |
| | | } |
| | | user.setRoleType(roleType); |
| | | user.setUserName(user.getUserName()); |
| | | if (!userService.checkUserNameUnique(user)) |