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