| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) ActivityForm form) { |
| | | public Result add(@RequestBody ActivityForm form) { |
| | | form.setActivityContent(addVideoControls(form.getActivityContent())); |
| | | return activityService.add(form,true); |
| | | } |
| | | |
| | | public static String addVideoControls(String html) { |
| | | if (html == null || html.isEmpty()) { |
| | | return html; |
| | | } |
| | | |
| | | // 匹配所有未包含 controls 属性的 <video> 标签 |
| | | String regex = "<video\\b(?![^>]*\\bcontrols\\b)([^>]*)>"; |
| | | String replacement = "<video controls=\"controls\"$1>"; |
| | | |
| | | return html.replaceAll(regex, replacement); |
| | | } |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) ActivityForm form) { |
| | | public Result update(@RequestBody ActivityForm form) { |
| | | form.setActivityContent(addVideoControls(form.getActivityContent())); |
| | | return activityService.update(form,true); |
| | | } |
| | | |