对比新文件 |
| | |
| | | package com.mzl.flower.dto.request.film; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | public class FilmCollectsDTO { |
| | | /** |
| | | * 关联的影视作品ID |
| | | */ |
| | | private Integer filmId; |
| | | |
| | | /** |
| | | * 收藏状态(0取消,1有效) |
| | | */ |
| | | private Boolean status; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.dto.request.film; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class FilmCollectsQueryDTO { |
| | | |
| | | @ApiModelProperty("影视作品ID") |
| | | private Integer filmId; |
| | | |
| | | @ApiModelProperty("状态") |
| | | private Boolean status; |
| | | |
| | | |
| | | } |
| | |
| | | private Integer filmId; |
| | | |
| | | /** |
| | | * 拍摄地点名称 |
| | | */ |
| | | private String locationName; |
| | | |
| | | /** |
| | | * 详细地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 纬度坐标(精确到小数点后6位) |
| | | */ |
| | | private BigDecimal gpsLat; |
| | | |
| | | /** |
| | | * 经度坐标(精确到小数点后6位) |
| | | */ |
| | | private BigDecimal gpsLng; |
| | | |
| | | /** |
| | | * 拍摄开始日期 |
| | | */ |
| | | private LocalDate startDate; |
| | | |
| | | /** |
| | | * 拍摄结束日期 |
| | | */ |
| | | private LocalDate endDate; |
| | | |
| | | /** |
| | | * 场景类型 |
| | | */ |
| | | private String sceneType; |
| | | |
| | | /** |
| | | * 经典画面描述 |
| | | */ |
| | | private String classicScene; |
| | | |
| | | /** |
| | | * 是否开放参观(0否,1是) |
| | | */ |
| | | private Boolean isOpenVisit; |
| | | |
| | | /** |
| | | * 参观提示(JSON格式存储) |
| | | */ |
| | | private String visitInfo; |
| | | |
| | | /** |
| | | * 地标性建筑描述 |
| | | */ |
| | | private String landmarkDesc; |
| | | |
| | | /** |
| | | * 交通指引说明 |
| | | */ |
| | | private String transportGuide; |
| | | |
| | | /** |
| | | * 停车场信息 |
| | | */ |
| | | private String parkingInfo; |
| | | |
| | | /** |
| | | * 周边设施描述 |
| | | */ |
| | | private String surroundingFacilities; |
| | | |
| | | /** |
| | | * AR实景对比功能入口URL |
| | | */ |
| | | private String arEntry; |
| | | |
| | | /** |
| | | * 状态(0禁用,1启用) |
| | | * 收藏状态(0取消,1有效) |
| | | */ |
| | | private Boolean status; |
| | | |
| | | |
| | | /** |
| | | * 打卡记录量 |
| | | */ |
| | | private Integer checkinCount; |
| | | |
| | | /** |
| | | * 游客实拍图(存储JSON数组) |
| | | */ |
| | | private String visitorPhotos; |
| | | |
| | | } |
| | |
| | | |
| | | @Data |
| | | public class FilmLikesQueryDTO { |
| | | @ApiModelProperty(value = "会员等级名称") |
| | | private String name; |
| | | @ApiModelProperty("影视作品ID") |
| | | private Integer filmId; |
| | | |
| | | @ApiModelProperty("状态") |
| | | private Boolean status; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "关键字(中文名称、英文名称、导演、演员、剧情、动作)") |
| | | private String keywords; |
| | | |
| | | private String userId; |
| | | |
| | | private Integer id; |
| | | |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.dto.response.film; |
| | | |
| | | import com.mzl.flower.base.AbstractTransDTO; |
| | | import com.mzl.flower.base.annotation.DictTrans; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class FilmCollectsVO extends AbstractTransDTO { |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("影视作品ID") |
| | | private Integer filmId; |
| | | |
| | | @ApiModelProperty("状态") |
| | | private Boolean status; |
| | | |
| | | @ApiModelProperty("创建日期") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("修改日期") |
| | | private LocalDateTime updateTime; |
| | | |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class FilmLikesVO extends AbstractTransDTO { |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("会员等级名称") |
| | | private String name; |
| | | @ApiModelProperty("影视作品ID") |
| | | private Integer filmId; |
| | | |
| | | @ApiModelProperty("成长点-区间-开始") |
| | | private int startPoint; |
| | | |
| | | @ApiModelProperty("成长点-区间-结束") |
| | | private int endPoint; |
| | | |
| | | @ApiModelProperty("会员折扣类型(百分比、固定金额)") |
| | | @DictTrans(target = "discountTypeStr", codeType = "DISCOUNT_TYPE") |
| | | private String discountType; |
| | | |
| | | private String discountTypeStr; |
| | | |
| | | @ApiModelProperty("会员折扣百分比") |
| | | private BigDecimal discountRatio; |
| | | |
| | | @ApiModelProperty("会员折扣固定金额") |
| | | private BigDecimal discountAmount; |
| | | |
| | | @ApiModelProperty("消费金额(元)") |
| | | private int consumptionAmount; |
| | | |
| | | @ApiModelProperty("已消费产生的成长值") |
| | | private int growthValue; |
| | | |
| | | @ApiModelProperty("未消费产生的下降值") |
| | | private int downgradeValue; |
| | | @ApiModelProperty("状态") |
| | | private Boolean status; |
| | | |
| | | @ApiModelProperty("创建日期") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("修改日期") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("操作人") |
| | | private String createName; |
| | | |
| | | @ApiModelProperty("背景") |
| | | private String background; |
| | | |
| | | @ApiModelProperty("图片") |
| | | private String pictures; |
| | | |
| | | @ApiModelProperty(value = "会员成长值获取规则") |
| | | private String growthValueDesc; |
| | | |
| | | @ApiModelProperty("更新人") |
| | | private String updateBy; |
| | | } |
| | |
| | | private String filmPictures; |
| | | |
| | | |
| | | private Boolean liked; |
| | | |
| | | private Boolean collected; |
| | | |
| | | /** |
| | | * 收藏量 |
| | | */ |
| | | private Integer voCollectCount; |
| | | |
| | | /** |
| | | * 点赞量 |
| | | */ |
| | | private Integer voLikeCount; |
| | | |
| | | /** |
| | | * 评论量 |
| | | */ |
| | | private Integer voCommentCount; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.entity.film; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.mzl.flower.base.BaseAutoEntity; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 影视作品收藏表 |
| | | * |
| | | * @author generator@Fang |
| | | * @since 2025-05-29 |
| | | */ |
| | | @Data |
| | | @TableName("film_collects") |
| | | public class FilmCollects extends BaseAutoEntity { |
| | | |
| | | |
| | | /** |
| | | * 关联的影视作品ID |
| | | */ |
| | | private Integer filmId; |
| | | |
| | | /** |
| | | * 收藏状态(0取消,1有效) |
| | | */ |
| | | private Boolean status; |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.mapper.film; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mzl.flower.entity.film.FilmCollects; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | | * <p> |
| | | * 影视作品收藏表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author generator@Fang |
| | | * @since 2025-05-29 |
| | | */ |
| | | @Repository |
| | | public interface FilmCollectsMapper extends BaseMapper<FilmCollects> { |
| | | |
| | | @Select("select * from film_collects where film_id = #{filmId} and create_by = #{createBy}") |
| | | FilmCollects getFilmCollectsByfilmIdAndCreateBy(Integer filmId, String createBy); |
| | | |
| | | @Update("UPDATE film_collects SET status = #{status}, update_by = #{updateBy}, update_time = NOW() WHERE id = #{id}") |
| | | int updateStatusById(@Param("id") Long id, |
| | | @Param("status") Boolean status, |
| | | @Param("updateBy") String updateBy); |
| | | } |
| | |
| | | |
| | | import com.mzl.flower.entity.film.FilmLikes; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | /** |
| | |
| | | @Repository |
| | | public interface FilmLikesMapper extends BaseMapper<FilmLikes> { |
| | | |
| | | |
| | | @Select("select * from film_likes where film_id = #{filmId} and create_by = #{createBy}") |
| | | FilmLikes getFilmLikesByfilmIdAndCreateBy(Integer filmId, String createBy); |
| | | |
| | | @Update("UPDATE film_likes SET status = #{status}, update_by = #{updateBy}, update_time = NOW() WHERE id = #{id}") |
| | | int updateStatusById(@Param("id") Long id, |
| | | @Param("status") Boolean status, |
| | | @Param("updateBy") String updateBy); |
| | | } |
| | |
| | | List<FilmWorksVO> getFilmWorksAll(); |
| | | |
| | | List<FilmWorksVO> queryPage(@Param("dto") FilmWorksQueryDTO dto, Page page); |
| | | FilmWorksVO selectInfoById(@Param("id") Long id, @Param("userId") String userId); |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.service.film; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsDTO; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsQueryDTO; |
| | | import com.mzl.flower.dto.response.film.FilmCollectsVO; |
| | | import com.mzl.flower.entity.film.FilmCollects; |
| | | |
| | | /** |
| | | * <p> |
| | | * 影视作品点赞表 服务类 |
| | | * </p> |
| | | * |
| | | * @author generator@Fang |
| | | * @since 2025-05-29 |
| | | */ |
| | | public interface FilmCollectsService extends IService<FilmCollects> { |
| | | |
| | | void saveFilmCollects(FilmCollectsDTO filmCollectsDTO); |
| | | |
| | | Boolean updateFilmCollects(FilmCollectsDTO filmCollectsDTO); |
| | | void deleteFilmCollects(String id); |
| | | |
| | | Page<FilmCollectsVO> queryPage(FilmCollectsQueryDTO filmCollectsQueryDTO, Page page); |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.service.film.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mzl.flower.config.exception.ValidationException; |
| | | import com.mzl.flower.config.security.SecurityUtils; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsDTO; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsQueryDTO; |
| | | import com.mzl.flower.dto.response.film.FilmCollectsVO; |
| | | import com.mzl.flower.entity.film.FilmCollects; |
| | | import com.mzl.flower.mapper.film.FilmCollectsMapper; |
| | | import com.mzl.flower.service.film.FilmCollectsService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * 影视作品收藏表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author generator@Fang |
| | | * @since 2025-05-29 |
| | | */ |
| | | @Service |
| | | public class FilmCollectsServiceImpl extends ServiceImpl<FilmCollectsMapper, FilmCollects> implements FilmCollectsService { |
| | | |
| | | @Resource |
| | | private FilmCollectsMapper filmCollectsMapper; |
| | | |
| | | @Override |
| | | public void saveFilmCollects(FilmCollectsDTO filmCollectsDTO) { |
| | | FilmCollects filmCollects = new FilmCollects(); |
| | | filmCollects.setFilmId(filmCollectsDTO.getFilmId()); |
| | | filmCollects.setStatus(true); |
| | | if (filmCollectsMapper.insert(filmCollects) <= 0) { |
| | | throw new ValidationException("添加评论收藏失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateFilmCollects(FilmCollectsDTO filmCollectsDTO) { |
| | | // 没有,新增 |
| | | FilmCollects filmCollects = filmCollectsMapper.getFilmCollectsByfilmIdAndCreateBy(filmCollectsDTO.getFilmId(), SecurityUtils.getUserId()); |
| | | if (filmCollects == null) { |
| | | filmCollects = new FilmCollects(); |
| | | filmCollects.setFilmId(filmCollectsDTO.getFilmId()); |
| | | filmCollects.setStatus(true); |
| | | filmCollects.setCreateBy(SecurityUtils.getUserId()); |
| | | if (filmCollectsMapper.insert(filmCollects) <= 0) { |
| | | throw new ValidationException("添加评论收藏失败"); |
| | | } |
| | | } else { |
| | | // 状态取反 |
| | | filmCollects.setStatus(!filmCollects.getStatus()); |
| | | filmCollects.update(SecurityUtils.getUserId()); |
| | | // 校验主键是否存在 |
| | | if (filmCollects.getId() == null) { |
| | | throw new ValidationException("主键 ID 不能为空"); |
| | | } |
| | | int affectedRows = filmCollectsMapper.updateStatusById( |
| | | filmCollects.getId(), // 确保 id 是 Long 类型 |
| | | filmCollects.getStatus(), |
| | | SecurityUtils.getUserId() // 更新人 |
| | | ); |
| | | if (affectedRows <= 0) { |
| | | throw new ValidationException("更新评论点赞状态失败"); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteFilmCollects(String id) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Page<FilmCollectsVO> queryPage(FilmCollectsQueryDTO filmCollectsQueryDTO, Page page) { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.config.exception.ValidationException; |
| | | import com.mzl.flower.config.security.SecurityUtils; |
| | | import com.mzl.flower.dto.request.film.FilmLikesDTO; |
| | | import com.mzl.flower.dto.request.film.FilmLikesQueryDTO; |
| | | import com.mzl.flower.dto.response.film.FilmLikesVO; |
| | |
| | | |
| | | @Override |
| | | public Boolean updateFilmLikes(FilmLikesDTO filmLikesDTO) { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | | // 没有,新增 |
| | | FilmLikes filmLikes = null; |
| | | if (filmLikesDTO == null) { |
| | | FilmLikes filmLikes = filmLikesMapper.getFilmLikesByfilmIdAndCreateBy(filmLikesDTO.getFilmId(), SecurityUtils.getUserId()); |
| | | if (filmLikes == null) { |
| | | filmLikes = new FilmLikes(); |
| | | filmLikes.setFilmId(filmLikesDTO.getFilmId()); |
| | | filmLikes.setStatus(true); |
| | | filmLikes.setCreateBy(SecurityUtils.getUserId()); |
| | | if (filmLikesMapper.insert(filmLikes) <= 0) { |
| | | throw new ValidationException("添加评论点赞失败"); |
| | | } |
| | | } else { |
| | | // 状态取反 |
| | | filmLikesDTO.setStatus(!filmLikesDTO.getStatus()); |
| | | if (filmLikesMapper.updateById(filmLikes) <= 0) { |
| | | filmLikes.setStatus(!filmLikes.getStatus()); |
| | | filmLikes.update(SecurityUtils.getUserId()); |
| | | |
| | | // 校验主键是否存在 |
| | | if (filmLikes.getId() == null) { |
| | | throw new ValidationException("主键 ID 不能为空"); |
| | | } |
| | | int affectedRows = filmLikesMapper.updateStatusById( |
| | | filmLikes.getId(), // 确保 id 是 Long 类型 |
| | | filmLikes.getStatus(), |
| | | SecurityUtils.getUserId() // 更新人 |
| | | ); |
| | | if (affectedRows <= 0) { |
| | | throw new ValidationException("更新评论点赞状态失败"); |
| | | } |
| | | } |
| | |
| | | if(StringUtils.isNotBlank(dto.getCreateDateEndStr())){ |
| | | dto.setCreateDateEnd(DateUtils.dateToLocalDateTime(dto.getCreateDateEndStr(),false)); |
| | | } |
| | | |
| | | //todo 这里的用户ID可能为空,用户存在不登录的情况下访问,传null |
| | | try { |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | } catch (Exception e) { |
| | | dto.setUserId(null); |
| | | } |
| | | |
| | | List<FilmWorksVO> list = filmWorksMapper.queryPage(dto,page); |
| | | page.setRecords(list); |
| | | |
| | | |
| | | return page; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public FilmWorksVO detail(Long id) { |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if(filmWork==null){ |
| | | // userId 可以是空,因为用户可以登录 |
| | | |
| | | String userId = SecurityUtils.getUserId(); |
| | | FilmWorksVO filmWorksVO = filmWorksMapper.selectInfoById(id,userId); |
| | | if(filmWorksVO==null){ |
| | | return null; |
| | | } |
| | | FilmWorksVO filmWorksVO = new FilmWorksVO(); |
| | | BeanUtils.copyProperties(filmWork,filmWorksVO); |
| | | CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(filmWork.getCreateBy()); |
| | | CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(filmWorksVO.getCreateBy()); |
| | | filmWorksVO.setNickname(currentCustomer.getNickName()); |
| | | filmWorksVO.setAvatar(currentCustomer.getCover()); |
| | | return filmWorksVO; |
对比新文件 |
| | |
| | | package com.mzl.flower.web.film; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.base.BaseController; |
| | | import com.mzl.flower.base.R; |
| | | import com.mzl.flower.base.ReturnDataDTO; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsDTO; |
| | | import com.mzl.flower.dto.request.film.FilmCollectsQueryDTO; |
| | | import com.mzl.flower.dto.response.film.FilmCollectsVO; |
| | | import com.mzl.flower.service.film.FilmCollectsService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | |
| | | @Api(value = "影视作品收藏", tags = "影视作品收藏") |
| | | @RestController |
| | | @RequestMapping("/v2/film-collects") |
| | | @RequiredArgsConstructor |
| | | public class FilmCollectsController extends BaseController { |
| | | |
| | | private final FilmCollectsService filmCollectsService; |
| | | |
| | | @GetMapping("/filmCollects/list") |
| | | @ApiOperation(value = "影视作品收藏列表", httpMethod = "GET") |
| | | public ResponseEntity<ReturnDataDTO<Page<FilmCollectsVO>>> getFilmCollectsList(Page page, FilmCollectsQueryDTO dto) { |
| | | return returnData(R.SUCCESS.getCode(), filmCollectsService.queryPage(dto, page)); |
| | | } |
| | | |
| | | @GetMapping(value = "/filmCollects/delete") |
| | | @ApiOperation(value = "删除影视作品收藏 ", httpMethod = "GET", notes = "ID") |
| | | public ResponseEntity delete(@NotNull(message = "id不能为空") Long id) { |
| | | filmCollectsService.deleteFilmCollects(String.valueOf(id)); |
| | | return returnData(R.SUCCESS.getCode(), null); |
| | | } |
| | | |
| | | @PostMapping(value = "/filmCollects/new") |
| | | @ApiOperation(value = "保存影视作品收藏", httpMethod = "POST") |
| | | public ResponseEntity insert(@RequestBody FilmCollectsDTO filmCollectsDTO) { |
| | | filmCollectsService.saveFilmCollects(filmCollectsDTO); |
| | | return returnData(R.SUCCESS.getCode(), null); |
| | | } |
| | | |
| | | @PostMapping(value = "/filmCollects/edit") |
| | | @ApiOperation(value = "更新影视作品收藏", httpMethod = "POST") |
| | | public ResponseEntity update(@RequestBody FilmCollectsDTO filmCollectsDTO) { |
| | | filmCollectsService.updateFilmCollects(filmCollectsDTO); |
| | | return returnData(R.SUCCESS.getCode(), null); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | <?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="com.mzl.flower.mapper.film.FilmCollectsMapper"> |
| | | |
| | | </mapper> |
| | |
| | | SELECT |
| | | t.*, |
| | | c.name AS nickname, |
| | | c.cover AS avatar |
| | | c.cover AS avatar, |
| | | COALESCE(l.like_count, 0) AS vo_like_count, |
| | | COALESCE(com.comment_count, 0) AS vo_comment_count, |
| | | COALESCE(col.collect_count, 0) AS vo_collect_count, |
| | | CASE WHEN l_user.status = 1 THEN 1 ELSE 0 END AS liked, |
| | | CASE WHEN col_user.status = 1 THEN 1 ELSE 0 END AS collected |
| | | FROM |
| | | film_works t |
| | | LEFT JOIN |
| | | t_customer_info c |
| | | ON |
| | | t.create_by = c.user_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS like_count |
| | | FROM film_likes |
| | | WHERE status = 1 |
| | | GROUP BY film_id |
| | | ) l ON t.id = l.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS comment_count |
| | | FROM film_comments |
| | | WHERE state = 1 |
| | | GROUP BY film_id |
| | | ) com ON t.id = com.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS collect_count |
| | | FROM film_collects |
| | | WHERE status = 1 |
| | | GROUP BY film_id |
| | | ) col ON t.id = col.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, status |
| | | FROM film_likes |
| | | WHERE create_by = #{dto.userId} |
| | | ) l_user ON t.id = l_user.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, status |
| | | FROM film_collects |
| | | WHERE create_by = #{dto.userId} |
| | | ) col_user ON t.id = col_user.film_id |
| | | WHERE |
| | | t.deleted = 0 |
| | | <if test="dto.id != null and dto.id != ''"> |
| | | AND t.id = #{dto.id} |
| | | </if> |
| | | <if test="dto.nameCn != null and dto.nameCn != ''"> |
| | | AND t.name_cn LIKE CONCAT('%', #{dto.nameCn}, '%') |
| | | </if> |
| | |
| | | t.update_time DESC |
| | | </select> |
| | | |
| | | |
| | | <select id="selectInfoById" resultType="com.mzl.flower.dto.response.film.FilmWorksVO"> |
| | | SELECT |
| | | t.*, |
| | | c.name AS nickname, |
| | | c.cover AS avatar, |
| | | COALESCE(l.like_count, 0) AS vo_like_count, |
| | | COALESCE(com.comment_count, 0) AS vo_comment_count, |
| | | COALESCE(col.collect_count, 0) AS vo_collect_count, |
| | | CASE WHEN l_user.status = 1 THEN 1 ELSE 0 END AS liked, |
| | | CASE WHEN col_user.status = 1 THEN 1 ELSE 0 END AS collected |
| | | FROM |
| | | film_works t |
| | | LEFT JOIN |
| | | t_customer_info c |
| | | ON |
| | | t.create_by = c.user_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS like_count |
| | | FROM film_likes |
| | | WHERE status = 1 |
| | | GROUP BY film_id |
| | | ) l ON t.id = l.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS comment_count |
| | | FROM film_comments |
| | | WHERE state = 1 |
| | | GROUP BY film_id |
| | | ) com ON t.id = com.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, COUNT(*) AS collect_count |
| | | FROM film_collects |
| | | WHERE status = 1 |
| | | GROUP BY film_id |
| | | ) col ON t.id = col.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, status |
| | | FROM film_likes |
| | | WHERE create_by = #{userId} |
| | | ) l_user ON t.id = l_user.film_id |
| | | LEFT JOIN ( |
| | | SELECT film_id, status |
| | | FROM film_collects |
| | | WHERE create_by = #{userId} |
| | | ) col_user ON t.id = col_user.film_id |
| | | WHERE |
| | | t.deleted = 0 |
| | | <if test="id != null and id != ''"> |
| | | AND t.id = #{id} |
| | | </if> |
| | | ORDER BY |
| | | t.update_time DESC |
| | | </select> |
| | | |
| | | </mapper> |