新增学员:支持零业务引用档案安全删除与引用保护
This commit is contained in:
1 parent
2dc22b06f8
commit
225f58481a
13 files changed
+469
-5
No files matched your search
+9
@@ -6,6 +6,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -74,4 +75,12 @@ public class TrainStudentController extends BaseController
|
||||
{
|
||||
return success(trainStudentService.createStudent(dto));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('train:student:remove')")
|
||||
@Log(title = "学员主档", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{sId}")
|
||||
public AjaxResult remove(@PathVariable("sId") String sId)
|
||||
{
|
||||
return toAjax(trainStudentService.deleteTrainStudentBySId(sId));
|
||||
}
|
||||
}
|
||||
+12
-3
@@ -23,16 +23,21 @@ public class StudentApiTest
|
||||
Method list = TrainStudentController.class.getMethod("list", StudentQuery.class);
|
||||
Method get = TrainStudentController.class.getMethod("getInfo", String.class);
|
||||
Method add = TrainStudentController.class.getMethod("add", StudentCreateDTO.class);
|
||||
Method remove = TrainStudentController.class.getMethod("remove", String.class);
|
||||
|
||||
assertEquals("/list", list.getAnnotation(GetMapping.class).value()[0]);
|
||||
assertEquals("/{sId}", get.getAnnotation(GetMapping.class).value()[0]);
|
||||
assertNotNull(add.getAnnotation(PostMapping.class));
|
||||
assertEquals("/{sId}", remove.getAnnotation(org.springframework.web.bind.annotation.DeleteMapping.class).value()[0]);
|
||||
|
||||
assertEquals("@ss.hasPermi('train:student:list')",
|
||||
list.getAnnotation(PreAuthorize.class).value());
|
||||
assertEquals("@ss.hasPermi('train:student:query')",
|
||||
get.getAnnotation(PreAuthorize.class).value());
|
||||
assertEquals("@ss.hasPermi('train:student:add')",
|
||||
add.getAnnotation(PreAuthorize.class).value());
|
||||
assertEquals("@ss.hasPermi('train:student:remove')",
|
||||
remove.getAnnotation(PreAuthorize.class).value());
|
||||
assertFalse(add.getAnnotation(Log.class).isSaveRequestData());
|
||||
}
|
||||
|
||||
@@ -66,12 +71,16 @@ public class StudentApiTest
|
||||
endpointCount++;
|
||||
assertFalse("不得公开 PUT 接口",
|
||||
method.isAnnotationPresent(org.springframework.web.bind.annotation.PutMapping.class));
|
||||
assertFalse("不得公开 DELETE 接口",
|
||||
method.isAnnotationPresent(org.springframework.web.bind.annotation.DeleteMapping.class));
|
||||
assertFalse("不得公开 export 接口",
|
||||
method.getName().toLowerCase().contains("export"));
|
||||
if (method.isAnnotationPresent(org.springframework.web.bind.annotation.DeleteMapping.class))
|
||||
{
|
||||
assertEquals("remove", method.getName());
|
||||
assertEquals("@ss.hasPermi('train:student:remove')",
|
||||
method.getAnnotation(PreAuthorize.class).value());
|
||||
}
|
||||
}
|
||||
}
|
||||
assertEquals("Controller必须严格只有3个P0端点", 3, endpointCount);
|
||||
assertEquals("Controller包含经过授权的4个端点(list, getInfo, add, remove)", 4, endpointCount);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user