New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zxl |
| | | * @since 2025-05-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_tag") |
| | | public class Tag extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | @TableField("tag_name") |
| | | private String tagName; |
| | | |
| | | @TableField("tag_type_id") |
| | | private String tagTypeId; |
| | | |
| | | |
| | | @TableField("sort_num") |
| | | private Integer sortNum; |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zxl |
| | | * @since 2025-05-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_tag_type") |
| | | public class TagType extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("tag_type_name") |
| | | private String tagTypeName; |
| | | |
| | | @TableField("type_key") |
| | | private String typeKey; |
| | | |
| | | @TableField("parent_id") |
| | | private String parentId; |
| | | |
| | | @TableField("sort_num") |
| | | private Integer sortNum; |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.entity.Tag; |
| | | import cn.lili.modules.lmk.domain.entity.VideoTag; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 视频标签表单 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "VideoTag表单", description = "视频标签表单") |
| | | public class TagForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "标签名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("标签名称") |
| | | private String tagName; |
| | | |
| | | @NotNull(message = "标签分类不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("标签分类") |
| | | private String tagTypeId; |
| | | |
| | | @NotNull(message = "序号不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("序号") |
| | | private Integer sortNum; |
| | | |
| | | public static Tag getEntityByForm(@NonNull TagForm form, Tag entity) { |
| | | if (entity == null) { |
| | | entity = new Tag(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.entity.TagType; |
| | | import cn.lili.modules.lmk.domain.entity.VideoTag; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 视频标签表单 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "VideoTag表单", description = "视频标签表单") |
| | | public class TagTypeForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "标签名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("标签名称") |
| | | private String tagTypeName; |
| | | |
| | | @NotNull(message = "分类标识不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("分类标识") |
| | | private String typeKey; |
| | | |
| | | @NotNull(message = "父节点不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("父节点") |
| | | private String parentId; |
| | | |
| | | |
| | | @NotNull(message = "序号不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("序号") |
| | | private Integer sortNum; |
| | | |
| | | public static TagType getEntityByForm(@NonNull TagTypeForm form, TagType entity) { |
| | | if (entity == null) { |
| | | entity = new TagType(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 视频标签查询 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "Tag查询参数", description = "标签查询参数") |
| | | public class TagQuery extends AbsQuery { |
| | | |
| | | @ApiModelProperty("标签名称") |
| | | private String tagName; |
| | | |
| | | @ApiModelProperty("标签分类") |
| | | private String tagTypeId; |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 视频标签查询 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "Tag分类查询参数", description = "标签分类查询参数") |
| | | public class TagTypeQuery extends AbsQuery { |
| | | |
| | | @ApiModelProperty("标签名称") |
| | | private String tagTypeName; |
| | | |
| | | @ApiModelProperty("分类标识") |
| | | private String typeKey; |
| | | |
| | | @ApiModelProperty("父节点") |
| | | private String parentId; |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.entity.TagType; |
| | | import cn.lili.modules.lmk.domain.entity.VideoTag; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视频标签展示 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "标签分类响应数据", description = "标签分类响应数据") |
| | | public class TagTypeVO extends AbsVo { |
| | | |
| | | @ApiModelProperty("标签名称") |
| | | private String tagTypeName; |
| | | |
| | | @ApiModelProperty("分类标识") |
| | | private String typeKey; |
| | | |
| | | @ApiModelProperty("父节点") |
| | | private String parentId; |
| | | |
| | | @ApiModelProperty("序号") |
| | | private Integer sortNum; |
| | | |
| | | private List<TagVO> children; |
| | | |
| | | public static TagTypeVO getVoByEntity(@NonNull TagType entity, TagTypeVO vo) { |
| | | if (vo == null) { |
| | | vo = new TagTypeVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.entity.Tag; |
| | | import cn.lili.modules.lmk.domain.entity.VideoTag; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 视频标签展示 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "标签响应数据", description = "标签响应数据") |
| | | public class TagVO extends AbsVo { |
| | | |
| | | @ApiModelProperty("标签名称") |
| | | private String tagName; |
| | | |
| | | @ApiModelProperty("标签分类") |
| | | private String tagTypeId; |
| | | |
| | | @ApiModelProperty("标签分类") |
| | | private String tagTypeName; |
| | | |
| | | |
| | | @ApiModelProperty("序号") |
| | | private Integer sortNum; |
| | | |
| | | public static TagVO getVoByEntity(@NonNull Tag entity, TagVO vo) { |
| | | if (vo == null) { |
| | | vo = new TagVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.enums.general; |
| | | |
| | | import lombok.Getter; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Getter |
| | | public enum TagTypeKeyEnum { |
| | | USER("USER", "用户"), |
| | | GOODS("GOODS", "商品"); |
| | | |
| | | private final String value; |
| | | |
| | | |
| | | private final String desc; |
| | | |
| | | TagTypeKeyEnum(String value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | /** |
| | | * 获取含义 |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static String getDescByValue(String value) { |
| | | if (StringUtils.isBlank(value)) { |
| | | return null; |
| | | } |
| | | for (TagTypeKeyEnum e : TagTypeKeyEnum.values()) { |
| | | if (value.equals(e.getValue())) { |
| | | return e.getDesc(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static List<Map<String, Object>> getList() { |
| | | return Arrays.stream(TagTypeKeyEnum.values()) |
| | | .map(e -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("value", e.getValue()); |
| | | map.put("label", e.getDesc()); |
| | | return map; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.Tag; |
| | | import cn.lili.modules.lmk.domain.query.TagQuery; |
| | | import cn.lili.modules.lmk.domain.vo.TagVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 视频标签 Mapper 接口 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Mapper |
| | | public interface TagMapper extends BaseMapper<Tag> { |
| | | |
| | | IPage<TagVO> getPage(IPage<TagVO> page, @Param("query") TagQuery query); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.TagType; |
| | | import cn.lili.modules.lmk.domain.vo.TagTypeVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视频标签 Mapper 接口 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Mapper |
| | | public interface TagTypeMapper extends BaseMapper<TagType> { |
| | | |
| | | |
| | | List<TagTypeVO> getTree(@Param("typeKey") String typeKey, @Param("tagTypeName") String tagTypeName); |
| | | |
| | | List<TagTypeVO> getByParentId(@Param("id") String id); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.Tag; |
| | | import cn.lili.modules.lmk.domain.form.TagForm; |
| | | import cn.lili.modules.lmk.domain.query.TagQuery; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 标签 服务类 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | public interface TagService extends IService<Tag> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(TagForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(TagForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(TagQuery query); |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param tagName |
| | | * @return |
| | | */ |
| | | Result all(String tagName); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.TagType; |
| | | import cn.lili.modules.lmk.domain.form.TagTypeForm; |
| | | import cn.lili.modules.lmk.domain.query.TagTypeQuery; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 标签分类 服务类 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | public interface TagTypeService extends IService<TagType> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(TagTypeForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(TagTypeForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param tagTypeName |
| | | * @return |
| | | */ |
| | | Result getTree(String keyType, String tagTypeName); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.Tag; |
| | | import cn.lili.modules.lmk.domain.form.TagForm; |
| | | import cn.lili.modules.lmk.domain.query.TagQuery; |
| | | import cn.lili.modules.lmk.domain.vo.TagVO; |
| | | import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum; |
| | | import cn.lili.modules.lmk.mapper.TagMapper; |
| | | import cn.lili.modules.lmk.service.TagService; |
| | | import cn.lili.utils.PageUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 视频标签 服务实现类 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService { |
| | | |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(TagForm form) { |
| | | Tag entity = TagForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(TagForm form) { |
| | | Tag entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(TagQuery query) { |
| | | IPage<TagVO> page = PageUtil.getPage(query, TagVO.class); |
| | | page = baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param tagName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all(String tagName) { |
| | | // List<Tag> entities = new LambdaQueryChainWrapper<>(baseMapper) |
| | | // .select(Tag::getId, Tag::getTagName) |
| | | // .like(StringUtils.isNotBlank(tagName), Tag::getTagName, tagName) |
| | | // .orderByDesc(Tag::getUseNum) |
| | | // .list(); |
| | | // List<SimpleTagVO> vos = entities.stream() |
| | | // .map(entity -> { |
| | | // SimpleTagVO vo = new SimpleTagVO(); |
| | | // BeanUtils.copyProperties(entity, vo); |
| | | // return vo; |
| | | // }) |
| | | // .collect(Collectors.toList()); |
| | | // return Result.ok().data(vos); |
| | | return Result.ok().data(new ArrayList<>()); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.TagType; |
| | | import cn.lili.modules.lmk.domain.form.TagForm; |
| | | import cn.lili.modules.lmk.domain.form.TagTypeForm; |
| | | import cn.lili.modules.lmk.domain.query.TagQuery; |
| | | import cn.lili.modules.lmk.domain.query.TagTypeQuery; |
| | | import cn.lili.modules.lmk.domain.vo.TagTypeVO; |
| | | import cn.lili.modules.lmk.domain.vo.TagVO; |
| | | import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum; |
| | | import cn.lili.modules.lmk.mapper.TagMapper; |
| | | import cn.lili.modules.lmk.mapper.TagTypeMapper; |
| | | import cn.lili.modules.lmk.service.TagService; |
| | | import cn.lili.modules.lmk.service.TagTypeService; |
| | | import cn.lili.utils.PageUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 视频标签 服务实现类 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TagTypeServiceImpl extends ServiceImpl<TagTypeMapper, TagType> implements TagTypeService { |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(TagTypeForm form) { |
| | | TagType entity = TagTypeForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(TagTypeForm form) { |
| | | TagType entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param tagTypeName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result getTree(String keyType, String tagTypeName) { |
| | | List<TagTypeVO> list = baseMapper.getTree(keyType, tagTypeName); |
| | | return Result.ok().data(list); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.TagMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.TagVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="tag_type_id" property="tagTypeId"/> |
| | | <result column="tag_type_name" property="tagTypeName"/> |
| | | <result column="tag_name" property="tagName"/> |
| | | <result column="sort_num" property="sortNum"/> |
| | | |
| | | </resultMap> |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | select t.id,t.tag_type_id,t.tag_name,t.sort_num,tt.tag_type_name as tag_type_name |
| | | from lmk_tag t |
| | | left join lmk_tag_type tt on t.tag_type_id = tt.id |
| | | where t.delete_flag = false |
| | | <if test="query.tagName != null and query.tagName != ''"> |
| | | and t.tag_name like concat('%',#{query.tagName},'%') |
| | | </if> |
| | | <if test="query.tagTypeId != null and query.tagTypeId != ''"> |
| | | and t.tag_type_id like concat('%',#{query.tagTypeId},'%') |
| | | </if> |
| | | order by t.sort_num |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.TagTypeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.TagTypeVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="tag_type_name" property="tagTypeName"/> |
| | | <result column="type_key" property="typeKey"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="sort_num" property="sortNum"/> |
| | | <collection property="children" ofType="cn.lili.modules.lmk.domain.vo.TagVO" |
| | | select="cn.lili.modules.lmk.mapper.TagTypeMapper.getByParentId" column="id"> |
| | | </collection> |
| | | |
| | | |
| | | </resultMap> |
| | | <select id="getByParentId" resultMap="BaseResultMap"> |
| | | select * |
| | | from lmk_tag_type |
| | | where delete_flag = false |
| | | and parent_id = #{id} |
| | | order by sort_num asc |
| | | </select> |
| | | <select id="getTree" resultMap="BaseResultMap"> |
| | | select * |
| | | from lmk_tag_type |
| | | where delete_flag = false |
| | | <if test="tagTypeName != null and tagTypeName!=''"> |
| | | and tag_type_name like concat('%',#{tagTypeName},'%') |
| | | </if> |
| | | <if test="tagTypeName == null or tagTypeName==''"> |
| | | and parent_id = 0 |
| | | </if> |
| | | <if test="typeKey != null"> |
| | | and type_key = #{typeKey} |
| | | </if> |
| | | order by sort_num asc |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.form.TagForm; |
| | | import cn.lili.modules.lmk.domain.query.TagQuery; |
| | | import cn.lili.modules.lmk.service.TagService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视频标签 前端控制器 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "标签", tags = "标签管理") |
| | | @RestController |
| | | @RequestMapping("/manager/lmk/tag") |
| | | public class TagController { |
| | | |
| | | private final TagService tagService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) TagForm form) { |
| | | return tagService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) TagForm form) { |
| | | return tagService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return tagService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return tagService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | public Result page(TagQuery query) { |
| | | return tagService.page(query); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.form.TagTypeForm; |
| | | import cn.lili.modules.lmk.domain.query.TagTypeQuery; |
| | | import cn.lili.modules.lmk.enums.general.TagTypeKeyEnum; |
| | | import cn.lili.modules.lmk.service.TagTypeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 视频标签 前端控制器 |
| | | * |
| | | * @author xp |
| | | * @since 2025-05-13 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "标签分类", tags = "标签分类管理") |
| | | @RestController |
| | | @RequestMapping("/manager/lmk/tag-type") |
| | | public class TagTypeController { |
| | | |
| | | private final TagTypeService tagTypeService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) TagTypeForm form) { |
| | | return tagTypeService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) TagTypeForm form) { |
| | | return tagTypeService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return tagTypeService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return tagTypeService.remove(ids); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result list(String tagTypeName) { |
| | | return tagTypeService.getTree(null, tagTypeName); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/key/list") |
| | | @ApiOperation(value = "keyType列表", notes = "keyType列表") |
| | | public Result keyList() { |
| | | return Result.ok().data(TagTypeKeyEnum.getList()); |
| | | } |
| | | } |