Compare commits
2 Commits
7834754dd3
...
47bbdca5af
| Author | SHA1 | Date | |
|---|---|---|---|
| 47bbdca5af | |||
| 8f2fc48ad8 |
@ -51,7 +51,7 @@ public class NewsService {
|
|||||||
if (user.getSuperAdmin()) {
|
if (user.getSuperAdmin()) {
|
||||||
newsPage = newsRepository.findAllByOrderByIdDesc(pageable);
|
newsPage = newsRepository.findAllByOrderByIdDesc(pageable);
|
||||||
} else {
|
} else {
|
||||||
newsPage = newsRepository.findByTenantOrderByIdDesc(user.getUsername(), pageable);
|
newsPage = newsRepository.findByTenantOrderByIdDesc(user.getTenant(), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsPage.hasContent()) {
|
if (newsPage.hasContent()) {
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
package org.cmh.backend.UserManagement.controller;
|
package org.cmh.backend.UserManagement.controller;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.cmh.backend.UserManagement.dto.TenantOptionsResponse;
|
||||||
import org.cmh.backend.UserManagement.model.Tenant;
|
import org.cmh.backend.UserManagement.model.Tenant;
|
||||||
import org.cmh.backend.UserManagement.model.User;
|
import org.cmh.backend.UserManagement.model.User;
|
||||||
import org.cmh.backend.UserManagement.service.TenantManagementService;
|
import org.cmh.backend.UserManagement.service.TenantManagementService;
|
||||||
|
import org.cmh.backend.Utils.JwtVerify;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/tenant")
|
@RequestMapping("/tenant")
|
||||||
@ -27,6 +33,20 @@ public class TenantManagementController {
|
|||||||
return tenantManagementService.findAll();
|
return tenantManagementService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getTenantOptions")
|
||||||
|
@JwtVerify
|
||||||
|
public ResponseEntity<TenantOptionsResponse> getAll(@RequestParam String token) {
|
||||||
|
tenantManagementService.findAll();
|
||||||
|
try {
|
||||||
|
List<String> options = tenantManagementService.findAll().stream()
|
||||||
|
.map(Tenant::getName)
|
||||||
|
.toList();
|
||||||
|
return new ResponseEntity<>(new TenantOptionsResponse(options, "请求成功"), HttpStatus.OK);
|
||||||
|
}catch (Exception e){
|
||||||
|
return new ResponseEntity<>(new TenantOptionsResponse(null, "请求失败"+e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/updateTenant")
|
@PostMapping("/updateTenant")
|
||||||
public Tenant update(@RequestBody Tenant tenant) {
|
public Tenant update(@RequestBody Tenant tenant) {
|
||||||
System.out.println(tenant);
|
System.out.println(tenant);
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package org.cmh.backend.UserManagement.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.cmh.backend.NewsManagement.dto.MessageResponse;
|
||||||
|
import org.cmh.backend.UserManagement.model.Tenant;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TenantOptionsResponse {
|
||||||
|
List<String> options;
|
||||||
|
String message;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user