21 changed files with 344 additions and 305 deletions
@ -0,0 +1,21 @@ |
|||
package io.sc.platform.core.validation; |
|||
|
|||
import io.sc.platform.core.validation.annotation.Code; |
|||
|
|||
import javax.validation.ConstraintValidator; |
|||
import javax.validation.ConstraintValidatorContext; |
|||
|
|||
public class CodeValidator implements ConstraintValidator<Code, String> { |
|||
@Override |
|||
public void initialize(Code constraintAnnotation) { |
|||
ConstraintValidator.super.initialize(constraintAnnotation); |
|||
} |
|||
|
|||
@Override |
|||
public boolean isValid(String value, ConstraintValidatorContext context) { |
|||
System.out.println(">>>>>>>>" + value); |
|||
return false; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,43 @@ |
|||
package io.sc.platform.core.validation.annotation; |
|||
|
|||
import io.sc.platform.core.validation.CodeValidator; |
|||
|
|||
import javax.validation.Constraint; |
|||
import javax.validation.Payload; |
|||
import javax.validation.constraints.Pattern; |
|||
import java.lang.annotation.Documented; |
|||
import java.lang.annotation.Repeatable; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.Target; |
|||
|
|||
import static java.lang.annotation.ElementType.*; |
|||
import static java.lang.annotation.RetentionPolicy.RUNTIME; |
|||
|
|||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) |
|||
@Retention(RUNTIME) |
|||
@Repeatable(Code.List.class) |
|||
@Documented |
|||
@Constraint(validatedBy= CodeValidator.class) |
|||
public @interface Code { |
|||
/** |
|||
* @return the error message template |
|||
*/ |
|||
String message() default "{javax.validation.constraints.Pattern.message}"; |
|||
|
|||
/** |
|||
* @return the groups the constraint belongs to |
|||
*/ |
|||
Class<?>[] groups() default { }; |
|||
|
|||
/** |
|||
* @return the payload associated to the constraint |
|||
*/ |
|||
Class<? extends Payload>[] payload() default { }; |
|||
|
|||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) |
|||
@Retention(RUNTIME) |
|||
@Documented |
|||
@interface List { |
|||
Code[] value(); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
package io.sc.platform.developer.tools.controller; |
|||
|
|||
|
|||
import io.sc.platform.core.DirectoryManager; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.File; |
|||
import java.util.Locale; |
|||
|
|||
@RestController("io.sc.platform.developer.sql.controller.ToolsWebController") |
|||
@RequestMapping("/api/developer/tools") |
|||
public class ToolsWebController { |
|||
@PostMapping(value="upload") |
|||
public void upload(@RequestParam(name="file",required=false) MultipartFile multipartFile,Locale locale) throws Exception{ |
|||
if(multipartFile!=null && !multipartFile.isEmpty()) { |
|||
String file =DirectoryManager.getInstance().getByName("dir.work.web.upload") + "/" + multipartFile.getOriginalFilename(); |
|||
multipartFile.transferTo(new File(file)); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue