@Override public TagType[] allTagType() { return TagType.values(); }
@Override public List<Tag> allTagByType(int tagType) { return tagRepository.findByTypeAndDisabledFalseOrderByWeightDesc(TagType.values()[tagType]); }
@PostMapping("/manage/tagList") @Transactional public String add(@RequestParam String name, Integer type , @RequestParam(required = false, defaultValue = "0") Integer weight, String icon) throws IOException { Tag tag = tagRepository.findOne(name); if (tag == null) { tag = new Tag(); tag.setName(name); tag.setType(TagType.values()[type]); } tag.setWeight(weight); tag = tagRepository.saveAndFlush(tag); //转存资源 if (!StringUtils.isEmpty(icon) && !icon.equalsIgnoreCase(tag.getIcon())) { String tagImgResource = "tag/" + tag.getName().hashCode() + "." + FileUtils.fileExtensionName(icon); resourceService.moveResource(tagImgResource, icon); tag.setIcon(tagImgResource); } return "redirect:/manageTag"; }