mirror of https://github.com/halo-dev/halo
Complete tag update api
parent
a8eb88956c
commit
e8a9498ea4
|
@ -88,11 +88,11 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
private void printStartInfo() {
|
||||
String blogUrl = getBaseUrl();
|
||||
|
||||
log.info("Halo started at {}", blogUrl);
|
||||
log.info("Halo started at {}", blogUrl);
|
||||
// TODO admin may be changeable
|
||||
log.info("Halo admin is at {}/admin", blogUrl);
|
||||
log.info("Halo admin started at {}/admin", blogUrl);
|
||||
if (!haloProperties.getDocDisabled()) {
|
||||
log.debug("Halo doc enable at {}/swagger-ui.html", blogUrl);
|
||||
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,9 @@ package cc.ryanc.halo.model.params;
|
|||
import cc.ryanc.halo.model.dto.base.InputConverter;
|
||||
import cc.ryanc.halo.model.entity.Tag;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import cc.ryanc.halo.utils.SlugUtils;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
@ -32,7 +30,7 @@ public class TagParam implements InputConverter<Tag> {
|
|||
public Tag convertTo() {
|
||||
if (StringUtils.isBlank(slugName)) {
|
||||
// Handle slug name
|
||||
slugName = SlugUtils.slugify(name);
|
||||
slugName = URLUtil.normalize(name);
|
||||
}
|
||||
|
||||
slugName = HaloUtils.initializeUrlIfBlank(slugName);
|
||||
|
|
|
@ -58,24 +58,38 @@ public class TagController {
|
|||
/**
|
||||
* Get tag by id
|
||||
*
|
||||
* @param id id
|
||||
* @param tagId tag id
|
||||
* @return TagOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@GetMapping("{tagId:\\d+}")
|
||||
@ApiOperation("Get tag detail by id")
|
||||
public TagOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new TagOutputDTO().convertFrom(tagService.getById(id));
|
||||
public TagOutputDTO getBy(@PathVariable("tagId") Integer tagId) {
|
||||
return new TagOutputDTO().convertFrom(tagService.getById(tagId));
|
||||
}
|
||||
|
||||
@PutMapping("{tagId:\\d+}")
|
||||
@ApiOperation("Updates tag")
|
||||
public TagOutputDTO updateBy(@PathVariable("tagId") Integer tagId,
|
||||
@Valid @RequestBody TagParam tagParam) {
|
||||
// Get old tag
|
||||
Tag tag = tagService.getById(tagId);
|
||||
|
||||
// Update tag
|
||||
tagParam.update(tag);
|
||||
|
||||
// Update tag
|
||||
return new TagOutputDTO().convertFrom(tagService.update(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete tag by id.
|
||||
*
|
||||
* @param id id
|
||||
* @param tagId tag id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@DeleteMapping("{tagId:\\d+}")
|
||||
@ApiOperation("Delete tag by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
tagService.removeById(id);
|
||||
postTagService.removeByTagId(id);
|
||||
public void deletePermanently(@PathVariable("tagId") Integer tagId) {
|
||||
tagService.removeById(tagId);
|
||||
postTagService.removeByTagId(tagId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue