|
@@ -1,23 +1,22 @@
|
|
|
package edu.travel.tenant.web;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import edu.travel.resp.BaseResponse;
|
|
|
import edu.travel.resp.PageResponse;
|
|
|
+import edu.travel.tenant.dto.AssignRolesOrMenus;
|
|
|
+import edu.travel.tenant.dto.EduTenantPageDto;
|
|
|
import edu.travel.tenant.entity.EduTenant;
|
|
|
+import edu.travel.tenant.entity.SysMenu;
|
|
|
import edu.travel.tenant.entity.SysRole;
|
|
|
import edu.travel.tenant.service.ITenantService;
|
|
|
-import edu.travel.tenant.vo.EduTenantVo;
|
|
|
import edu.travel.web.BaseController;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/tenant")
|
|
@@ -25,43 +24,111 @@ public class TenantController extends BaseController<EduTenant> {
|
|
|
@Autowired
|
|
|
private ITenantService tenantService;
|
|
|
|
|
|
- @GetMapping("/getTenant")
|
|
|
- public BaseResponse getTenant() {
|
|
|
+ @GetMapping("/getTenantByPhoneNumber")
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<EduTenant> getTenantByPhoneNumber() {
|
|
|
EduTenant principal = (EduTenant)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
|
- EduTenant list = tenantService.getTenantByID(principal.getTenantPhone());
|
|
|
+ EduTenant list = tenantService.getTenantByPhoneNumber(principal.getTenantPhone());
|
|
|
return PageResponse.out(200,"success",list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增用户
|
|
|
+ * @param tenant
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@PostMapping("/addTenant")
|
|
|
// @PreAuthorize("hasRole('超级管理员')")
|
|
|
- public BaseResponse addTenant(EduTenant tenant) {
|
|
|
+ public BaseResponse<Boolean> addTenant(EduTenant tenant) {
|
|
|
tenantService.addTenant(tenant);
|
|
|
- return PageResponse.out(200,"success",tenant);
|
|
|
+ return PageResponse.out(200,"success",true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过ids删除用户
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@PostMapping("/deleteTenantByIds")
|
|
|
// @PreAuthorize("hasRole('超级管理员')")
|
|
|
- public BaseResponse deleteTenant(Set<Long> ids) {
|
|
|
+ public BaseResponse<Boolean> deleteTenant(List<Long> ids) {
|
|
|
tenantService.deleteByIds(ids);
|
|
|
- return PageResponse.out(200,"success",ids);
|
|
|
+ return PageResponse.out(200,"success",true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改用户信息
|
|
|
+ * @param tenant
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@PostMapping("/updateTenantById")
|
|
|
// @PreAuthorize("hasRole('超级管理员')")
|
|
|
- public BaseResponse updateTenant(EduTenant tenant) {
|
|
|
+ public BaseResponse<Boolean> updateTenant(EduTenant tenant) {
|
|
|
tenantService.updateTenant(tenant);
|
|
|
- return PageResponse.out(200,"success",tenant);
|
|
|
+ return PageResponse.out(200,"success",true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过id查询用户信息
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@GetMapping("/getTenantById")
|
|
|
- public BaseResponse getTenantById(Long id) {
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<EduTenant> getTenantById(Long id) {
|
|
|
EduTenant tenant = tenantService.getTenantById(id);
|
|
|
return PageResponse.out(200,"success",tenant);
|
|
|
}
|
|
|
|
|
|
-// @GetMapping("/getMenuList")
|
|
|
-// public BaseResponse getMenuList() {
|
|
|
-// List<SysRole> menuList = tenantService.getMenuList();
|
|
|
-// return PageResponse.out(200,"success",menuList);
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 获取用户分页列表
|
|
|
+ * @param tenantDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getTenantPageList")
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<List<EduTenant>> getTenantList(EduTenantPageDto tenantDto) {
|
|
|
+ IPage<EduTenant> page = new Page<>(tenantDto.getPageNum(), tenantDto.getPageSize());
|
|
|
+ IPage<EduTenant> tenantIPage = tenantService.page(page, new LambdaQueryWrapper<EduTenant>().eq(EduTenant::getDeleteFlag, 0));
|
|
|
+ return PageResponse.out(200,"success",tenantIPage.getRecords(),(int)tenantIPage.getTotal(),(int)tenantIPage.getSize()) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户id获取用户角色列表(未分页)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getRoleListByUserId")
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<List<SysRole>> getRoleListByUserId() {
|
|
|
+ EduTenant principal = (EduTenant) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
|
+ List<SysRole> roleList = tenantService.getRoleListByUserId(principal);
|
|
|
+ return PageResponse.out(200,"success",roleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户id获取用户菜单列表(未分页)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getMenuListByUserId")
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<List<SysMenu>> getMenuList() {
|
|
|
+ EduTenant principal = (EduTenant) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
|
+ List<SysMenu> menuList = tenantService.getMenuList(principal);
|
|
|
+ return PageResponse.out(200,"success",menuList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户id给用户分配角色(可以多个角色)
|
|
|
+ * @param assignRolesOrMenus
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/assignRolesToUser")
|
|
|
+// @PreAuthorize("hasRole('超级管理员')")
|
|
|
+ public BaseResponse<Boolean> assignRolesToUser(@RequestBody AssignRolesOrMenus assignRolesOrMenus) {
|
|
|
+ EduTenant principal = (EduTenant) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
|
|
+ tenantService.assignRolesToUser(assignRolesOrMenus);
|
|
|
+ return PageResponse.out(200,"success",true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|