v1.0.1
This commit is contained in:
parent
d50b053c6a
commit
24ffb52a48
@ -46,8 +46,7 @@ public class FileController {
|
||||
// 组装完整的存储路径
|
||||
File destFile = new File(storageDir, file.getOriginalFilename());
|
||||
log.info(destFile.getAbsolutePath());
|
||||
// 存储文件
|
||||
// file.transferTo(destFile);
|
||||
String imgUrl = destFile.getAbsolutePath();
|
||||
// 使用流手动存储文件
|
||||
try (InputStream inputStream = file.getInputStream();
|
||||
OutputStream outputStream = new FileOutputStream(destFile)) {
|
||||
@ -58,21 +57,21 @@ public class FileController {
|
||||
}
|
||||
}
|
||||
|
||||
log.info("文件存储成功: " + destFile.getAbsolutePath());
|
||||
log.info("本地文件存储成功: " + destFile.getAbsolutePath());
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
|
||||
|
||||
|
||||
MinIOUtils.uploadFile(minIOConfig.getBucketName(),
|
||||
fileName,
|
||||
file.getInputStream());
|
||||
|
||||
String imgUrl = minIOConfig.getFileHost()
|
||||
+ "/"
|
||||
+ minIOConfig.getBucketName()
|
||||
+ "/"
|
||||
+ fileName;
|
||||
// String fileName = file.getOriginalFilename();
|
||||
//
|
||||
//
|
||||
//
|
||||
// MinIOUtils.uploadFile(minIOConfig.getBucketName(),
|
||||
// fileName,
|
||||
// file.getInputStream());
|
||||
//
|
||||
// String imgUrl = minIOConfig.getFileHost()
|
||||
// + "/"
|
||||
// + minIOConfig.getBucketName()
|
||||
// + "/"
|
||||
// + fileName;
|
||||
|
||||
return GraceJSONResult.ok(imgUrl);
|
||||
}
|
||||
|
@ -91,6 +91,41 @@ public class UserInfoController extends BaseInfoProperties {
|
||||
UserInfoModifyType.checkUserInfoTypeIsRight(type);
|
||||
Users newUserInfo = userService.updateUserInfo(updatedUserBO, type);
|
||||
return GraceJSONResult.ok(newUserInfo);
|
||||
|
||||
// NICKNAME(1, "昵称"),
|
||||
// IMOOCNUM(2, "慕课号"),
|
||||
// SEX(3, "性别"),
|
||||
// BIRTHDAY(4, "生日"),
|
||||
// LOCATION(5, "所在地"),
|
||||
// DESC(6, "简介");
|
||||
// Users user = userService.getUser(updatedUserBO.getId());
|
||||
//
|
||||
// UsersVO usersVO = new UsersVO();
|
||||
// BeanUtils.copyProperties(user, usersVO);
|
||||
// UserInfoModifyType.checkUserInfoTypeIsRight(type);
|
||||
// if(type==1){
|
||||
// usersVO.setNickname(updatedUserBO.getNickname());
|
||||
// }
|
||||
// if(type==2){
|
||||
// usersVO.setImoocNum(updatedUserBO.getImoocNum());
|
||||
// usersVO.setCanImoocNumBeUpdated(0);
|
||||
// }
|
||||
// if(type==3){
|
||||
// usersVO.setSex(updatedUserBO.getSex());
|
||||
// }
|
||||
// if(type==4){
|
||||
// usersVO.setBirthday(updatedUserBO.getBirthday());
|
||||
// }
|
||||
// if(type==5){
|
||||
// usersVO.setProvince(updatedUserBO.getProvince());
|
||||
// usersVO.setCity(updatedUserBO.getCity());
|
||||
// usersVO.setDistrict(updatedUserBO.getDistrict());
|
||||
// }
|
||||
// if(type==6){
|
||||
// usersVO.setDescription(updatedUserBO.getDescription());
|
||||
// }
|
||||
// userService.updateUserInfo();
|
||||
// return GraceJSONResult.ok(usersVO);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
@ -149,15 +149,16 @@ public class VlogController extends BaseInfoProperties {
|
||||
@PostMapping("publish")
|
||||
public GraceJSONResult publish(@RequestBody VlogBO vlogBO) throws Exception {
|
||||
String url = vlogBO.getUrl();
|
||||
log.info(url);
|
||||
log.info("未审核视频地址:"+url);
|
||||
String fileName = url.substring(url.lastIndexOf("/") + 1);
|
||||
log.info(fileName);
|
||||
log.info("视频文件名称:"+fileName);
|
||||
String fileId = qcCloud.uploadViaTempFile(fileName);
|
||||
log.info(fileId);
|
||||
log.info("视频发布ID:"+fileId);
|
||||
vlogBO.setFileId(fileId);
|
||||
// 删除minio文件
|
||||
MinIOUtils.removeFile(minIOConfig.getBucketName(),fileName);
|
||||
log.info("删除minio文件:"+fileName);
|
||||
// MinIOUtils.removeFile(minIOConfig.getBucketName(),fileName);
|
||||
// log.info("删除minio文件:"+fileName);
|
||||
|
||||
// FIXME 校验VlogBO
|
||||
vlogService.createVlog(vlogBO);
|
||||
|
||||
|
@ -26,7 +26,7 @@ nacos:
|
||||
counts: 10
|
||||
# 整合mybatis
|
||||
mybatis:
|
||||
type-aliases-package: com.imooc.pojo # 所有pojo类所在的包路径
|
||||
type-aliases-package: com.imooc.pojo,com.imooc.vo,com.imooc.mo,com.imooc.bo # 所有pojo类所在的包路径
|
||||
mapper-locations: classpath:mapper/*.xml # mapper映射文件
|
||||
|
||||
# 通用mapper工具的配置
|
||||
|
2
book-api/src/main/resources/tencentcloud.properties
Normal file
2
book-api/src/main/resources/tencentcloud.properties
Normal file
@ -0,0 +1,2 @@
|
||||
tencent.cloud.secretId=AKIDvhEVWHm0xe5JGxOZXGitnRovlKcfRzIN
|
||||
tencent.cloud.secretKey=qPhiTxA7oENFrCH5dvxiCQN4UdWAYgYA
|
@ -36,14 +36,14 @@ public class QcCloud {
|
||||
// String storagePath = "/Users/wuzhongjie/Desktop/vlog-1.0.0/vlogdata"; // 本地
|
||||
String storagePath = "/data/vlogdata"; // 生产
|
||||
|
||||
System.out.println("绝对路径: " + storagePath);
|
||||
System.out.println("腾讯云服务:绝对路径: " + storagePath);
|
||||
File storageDir = new File(storagePath);
|
||||
// 组装完整的文件路径
|
||||
File sourceFile = new File(storageDir, fileName);
|
||||
System.out.println("完整文件路径: " + sourceFile.toPath());
|
||||
System.out.println("腾讯云服务:完整文件路径: " + sourceFile.toPath());
|
||||
|
||||
if (!sourceFile.exists()) {
|
||||
throw new RuntimeException("文件不存在: " + sourceFile.getAbsolutePath());
|
||||
throw new RuntimeException("腾讯云服务:文件不存在: " + sourceFile.getAbsolutePath());
|
||||
}
|
||||
try {
|
||||
VodUploadClient client = new VodUploadClient(getSecretId(), getSecretKey());
|
||||
|
@ -2,6 +2,8 @@ package com.imooc.mapper;
|
||||
|
||||
import com.imooc.my.mapper.MyMapper;
|
||||
import com.imooc.pojo.Fans;
|
||||
import com.imooc.vo.FansVO;
|
||||
import com.imooc.vo.VlogerVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@ -10,22 +12,35 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//@Repository
|
||||
//public interface FansMapper extends MyMapper<Fans> {
|
||||
// int updateByPrimaryKeySelective(Fans record);
|
||||
//
|
||||
//
|
||||
// @Select("<script> " +
|
||||
// "SELECT vloger_id, is_fan_friend_of_mine FROM t_fans " +
|
||||
// "WHERE fan_id = #{currentUserId} " +
|
||||
// "AND vloger_id IN " +
|
||||
// "<foreach collection='vlogerIds' item='vlogerId' open='(' separator=',' close=')'> " +
|
||||
// "#{vlogerId} " +
|
||||
// "</foreach> " +
|
||||
// "</script>")
|
||||
// List<Map<String, Object>> getFollowedVlogerIds(@Param("currentUserId")String currentUserId,@Param("vlogerIds")List<String> vlogerIds);
|
||||
//// Set<String> getFollowedVlogerIds(
|
||||
//// @Param("currentUserId") String currentUserId,
|
||||
//// @Param("vlogerIds") List<String> vlogerIds
|
||||
//// );
|
||||
//
|
||||
//}
|
||||
|
||||
@Repository
|
||||
public interface FansMapper extends MyMapper<Fans> {
|
||||
public interface FansMapper {
|
||||
int updateByPrimaryKeySelective(Fans record);
|
||||
public List<Map<String, Object>> getFollowedVlogerIds(@Param("currentUserId")String currentUserId,@Param("vlogerIds")List<String> vlogerIds);
|
||||
|
||||
int insert(@Param("fansData") Map<String, Object> vlogData);
|
||||
|
||||
@Select("<script> " +
|
||||
"SELECT vloger_id, is_fan_friend_of_mine FROM t_fans " +
|
||||
"WHERE fan_id = #{currentUserId} " +
|
||||
"AND vloger_id IN " +
|
||||
"<foreach collection='vlogerIds' item='vlogerId' open='(' separator=',' close=')'> " +
|
||||
"#{vlogerId} " +
|
||||
"</foreach> " +
|
||||
"</script>")
|
||||
List<Map<String, Object>> getFollowedVlogerIds(@Param("currentUserId")String currentUserId,@Param("vlogerIds")List<String> vlogerIds);
|
||||
// Set<String> getFollowedVlogerIds(
|
||||
// @Param("currentUserId") String currentUserId,
|
||||
// @Param("vlogerIds") List<String> vlogerIds
|
||||
// );
|
||||
public List<VlogerVO> selectByExample(@Param("paramMap") Map<String, Object> map);
|
||||
|
||||
int delete(@Param("id") String id);
|
||||
}
|
@ -4,9 +4,11 @@ import com.imooc.my.mapper.MyMapper;
|
||||
import com.imooc.pojo.Users;
|
||||
import com.imooc.utils.PagedGridResult;
|
||||
import com.imooc.vo.UsersVO;
|
||||
import com.imooc.bo.UpdatedUserBO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@ -14,4 +16,16 @@ public interface UsersMapper extends MyMapper<Users> {
|
||||
|
||||
@Select("SELECT * FROM t_users WHERE nickname LIKE CONCAT('%', #{nickname}, '%')")
|
||||
List<UsersVO> searchByNickname(String nickname);
|
||||
@Update("UPDATE t_users SET nickname = #{nickname} WHERE id = #{id}")
|
||||
int updateNickname(UpdatedUserBO user);
|
||||
@Update("UPDATE t_users SET sex = #{sex} WHERE id = #{id}")
|
||||
int updateSex(UpdatedUserBO user);
|
||||
@Update("UPDATE t_users SET birthday = #{birthday} WHERE id = #{id}")
|
||||
int updateBirthday(UpdatedUserBO user);
|
||||
@Update("UPDATE t_users SET description = #{description} WHERE id = #{id}")
|
||||
int updateDescription(UpdatedUserBO user);
|
||||
@Update("UPDATE t_users SET province = #{province},city = #{city},district = #{district} WHERE id = #{id}")
|
||||
int updateLocation(UpdatedUserBO user);
|
||||
@Update("UPDATE t_users SET imooc_num = #{imoocNum},can_imooc_num_be_updated = 0 WHERE id = #{id}")
|
||||
int updateVnum(UpdatedUserBO user);
|
||||
}
|
@ -2,9 +2,57 @@ package com.imooc.mapper;
|
||||
|
||||
import com.imooc.my.mapper.MyMapper;
|
||||
import com.imooc.pojo.Vlog;
|
||||
import com.imooc.vo.IndexVlogVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
//@Repository
|
||||
//public interface VlogMapper extends MyMapper<Vlog> {
|
||||
//}
|
||||
@Repository
|
||||
public interface VlogMapper extends MyMapper<Vlog> {
|
||||
public interface VlogMapper {
|
||||
// public List<IndexVlogVO> updateVlogStatus(@Param("paramMap") Map<String, Object> map);
|
||||
/**
|
||||
* 通用动态更新方法
|
||||
* @param primaryKey 主键字段名
|
||||
* @param idValue 主键值
|
||||
* @param updateFields 待更新的字段Map(key=字段名, value=字段值)
|
||||
* @return 影响的行数
|
||||
*/
|
||||
int dynamicUpdate(
|
||||
@Param("primaryKey") String primaryKey,
|
||||
@Param("idValue") Object idValue,
|
||||
@Param("updateFields") Map<String, Object> updateFields
|
||||
);
|
||||
|
||||
/**
|
||||
* Vlog表多条件动态更新
|
||||
* @param updateFields 需要更新的字段及值(Map结构)
|
||||
* @param conditions 更新条件(Map结构)
|
||||
* @return 受影响的行数
|
||||
*/
|
||||
int updateVlogByConditions(
|
||||
@Param("updates") Map<String, Object> updateFields,
|
||||
@Param("conditions") Map<String, Object> conditions
|
||||
);
|
||||
|
||||
/**
|
||||
* 单条插入vlog记录
|
||||
* @param vlogData 插入数据的键值对(key=列名, value=列值)
|
||||
* @return 影响的行数
|
||||
*/
|
||||
int dynamicInsert(@Param("vlogData") Map<String, Object> vlogData);
|
||||
|
||||
/**
|
||||
* 批量插入vlog记录
|
||||
* @param vlogList 插入数据列表(每个Map代表一行数据)
|
||||
* @return 影响的行数
|
||||
*/
|
||||
int dynamicBatchInsert(@Param("vlogList") List<Map<String, Object>> vlogList);
|
||||
|
||||
public List<IndexVlogVO> selectMyPublic(@Param("paramMap")Map<String, Object> map);
|
||||
public List<IndexVlogVO> getVlogDetailFromId(@Param("paramMap")Map<String, Object> map);
|
||||
}
|
@ -19,4 +19,45 @@
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 单条插入 -->
|
||||
<insert id="insert">
|
||||
INSERT INTO t_fans
|
||||
<foreach collection="fansData.keys" item="key" open="(" separator="," close=")">
|
||||
${key}
|
||||
</foreach>
|
||||
VALUES
|
||||
<foreach collection="fansData.values" item="value" open="(" separator="," close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 查询 -->
|
||||
<select id="selectByExample" resultType="com.imooc.pojo.Fans" parameterType="map">
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
t_fans f
|
||||
WHERE
|
||||
vloger_id = #{paramMap.vlogerId}
|
||||
AND fan_id = #{paramMap.fanId}
|
||||
|
||||
</select>
|
||||
|
||||
<delete id="delete" parameterType="com.imooc.pojo.Fans">
|
||||
DELETE FROM t_fans
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getFollowedVlogerIds" resultType="com.imooc.pojo.Fans" parameterType="map">
|
||||
|
||||
SELECT vloger_id, is_fan_friend_of_mine FROM t_fans
|
||||
WHERE fan_id = #{currentUserId}
|
||||
AND vloger_id IN
|
||||
<foreach collection='vlogerIds' item='vlogerId' open='(' separator=',' close=')'>
|
||||
#{vlogerId}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
</mapper>
|
@ -1,27 +1,154 @@
|
||||
<?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.imooc.mapper.VlogMapper" >
|
||||
<resultMap id="BaseResultMap" type="com.imooc.pojo.Vlog" >
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
-->
|
||||
<id column="id" property="id" jdbcType="VARCHAR" />
|
||||
<result column="vloger_id" property="vlogerId" jdbcType="VARCHAR" />
|
||||
<result column="url" property="url" jdbcType="VARCHAR" />
|
||||
<result column="cover" property="cover" jdbcType="VARCHAR" />
|
||||
<result column="title" property="title" jdbcType="VARCHAR" />
|
||||
<result column="width" property="width" jdbcType="INTEGER" />
|
||||
<result column="height" property="height" jdbcType="INTEGER" />
|
||||
<result column="like_counts" property="likeCounts" jdbcType="INTEGER" />
|
||||
<result column="comments_counts" property="commentsCounts" jdbcType="INTEGER" />
|
||||
<result column="is_private" property="isPrivate" jdbcType="INTEGER" />
|
||||
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
|
||||
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP" />
|
||||
<result column="status" property="status" jdbcType="INTEGER" />
|
||||
<result column="reason" property="reason" jdbcType="VARCHAR" />
|
||||
<result column="city_code" property="cityCode" jdbcType="INTEGER" />
|
||||
<result column="file_id" property="fileId" jdbcType="VARCHAR" />
|
||||
<result column="first_frame_img" property="firstFrameImg" jdbcType="VARCHAR" />
|
||||
|
||||
</resultMap>
|
||||
</mapper>
|
||||
<mapper namespace="com.imooc.mapper.VlogMapper">
|
||||
<!-- 通用更新 -->
|
||||
<update id="dynamicUpdate">
|
||||
UPDATE t_vlog
|
||||
<set>
|
||||
<foreach collection="updateFields" index="key" item="value" separator=",">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
</set>
|
||||
WHERE ${primaryKey} = #{idValue}
|
||||
</update>
|
||||
|
||||
<update id="updateVlogByConditions">
|
||||
UPDATE t_vlog
|
||||
<set>
|
||||
<foreach collection="updates" item="value" index="key" separator=",">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
</set>
|
||||
<where>
|
||||
<foreach collection="conditions" item="value" index="key" separator=" AND ">
|
||||
<choose>
|
||||
<!-- 处理null值条件 -->
|
||||
<when test="value == null">
|
||||
${key} IS NULL
|
||||
</when>
|
||||
<!-- 处理IN条件 -->
|
||||
<when test="value instanceof java.util.Collection">
|
||||
${key} IN
|
||||
<foreach collection="value" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</when>
|
||||
<!-- 处理普通条件 -->
|
||||
<otherwise>
|
||||
${key} = #{value}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<!-- 单条插入 -->
|
||||
<insert id="dynamicInsert">
|
||||
INSERT INTO t_vlog
|
||||
<foreach collection="vlogData.keys" item="key" open="(" separator="," close=")">
|
||||
${key}
|
||||
</foreach>
|
||||
VALUES
|
||||
<foreach collection="vlogData.values" item="value" open="(" separator="," close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="dynamicBatchInsert">
|
||||
INSERT INTO t_vlog
|
||||
<foreach collection="vlogList[0].keys" item="key" open="(" separator="," close=")">
|
||||
${key}
|
||||
</foreach>
|
||||
VALUES
|
||||
<foreach collection="vlogList" item="vlogData" separator=",">
|
||||
<foreach collection="vlogData.values" item="value" open="(" separator="," close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 查询 -->
|
||||
<select id="selectMyPublic" parameterType="map" resultType="com.imooc.vo.IndexVlogVO">
|
||||
SELECT
|
||||
v.id as vlogId,
|
||||
v.vloger_id as vlogerId,
|
||||
u.face as vlogerFace,
|
||||
u.nickname as vlogerName,
|
||||
v.title as content,
|
||||
v.url as url,
|
||||
v.cover as cover,
|
||||
v.width as width,
|
||||
v.height as height,
|
||||
v.like_counts as likeCounts,
|
||||
v.comments_counts as commentsCounts,
|
||||
v.is_private as isPrivate,
|
||||
v.city_code as cityCode,
|
||||
v.reason as reason,
|
||||
v.file_id as fileId,
|
||||
v.status as status,
|
||||
v.first_frame_img as firstFrameImg
|
||||
FROM
|
||||
t_vlog v
|
||||
LEFT JOIN
|
||||
t_users u
|
||||
ON
|
||||
v.vloger_id = u.id
|
||||
WHERE
|
||||
v.is_private = 0
|
||||
AND v.vloger_id = #{paramMap.vlogerId}
|
||||
<choose>
|
||||
<when test="paramMap.status != null and paramMap.status!=''">
|
||||
AND v.status = #{paramMap.status}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND v.status = 1
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="paramMap.cityCode != null and paramMap.cityCode != ''">
|
||||
AND v.city_code = #{paramMap.cityCode}
|
||||
</if>
|
||||
<if test="paramMap.search != null and paramMap.search != ''">
|
||||
AND v.title like '%${paramMap.search}%'
|
||||
</if>
|
||||
ORDER BY
|
||||
v.created_time
|
||||
DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getVlogDetailFromId" parameterType="map" resultType="com.imooc.vo.IndexVlogVO">
|
||||
SELECT
|
||||
v.id as vlogId,
|
||||
v.vloger_id as vlogerId,
|
||||
u.face as vlogerFace,
|
||||
u.nickname as vlogerName,
|
||||
v.title as content,
|
||||
v.url as url,
|
||||
v.cover as cover,
|
||||
v.width as width,
|
||||
v.height as height,
|
||||
v.like_counts as likeCounts,
|
||||
v.comments_counts as commentsCounts,
|
||||
v.is_private as isPrivate,
|
||||
v.city_code as cityCode,
|
||||
v.reason as reason,
|
||||
v.file_id as fileId,
|
||||
v.status as status,
|
||||
v.first_frame_img as firstFrameImg
|
||||
FROM
|
||||
t_vlog v
|
||||
LEFT JOIN
|
||||
t_users u
|
||||
ON
|
||||
v.vloger_id = u.id
|
||||
WHERE
|
||||
v.id = #{paramMap.vlogId}
|
||||
AND v.status = 1
|
||||
AND v.first_frame_img IS NOT NULL
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.imooc.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.imooc.base.BaseInfoProperties;
|
||||
import com.imooc.base.RabbitMQConfig;
|
||||
@ -19,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.n3r.idworker.Sid;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cglib.beans.BeanMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
@ -51,23 +53,31 @@ public class FansServiceImpl extends BaseInfoProperties implements FansService {
|
||||
|
||||
String fid = sid.nextShort();
|
||||
|
||||
Fans fans = new Fans();
|
||||
fans.setId(fid);
|
||||
fans.setFanId(myId);
|
||||
fans.setVlogerId(vlogerId);
|
||||
fans.setCreatedTime(new Date());
|
||||
// Fans fans = new Fans();
|
||||
// fans.setId(fid);
|
||||
// fans.setFanId(myId);
|
||||
// fans.setVlogerId(vlogerId);
|
||||
// fans.setCreatedTime(new Date());
|
||||
|
||||
Map<String, Object> fans = new HashMap<>();
|
||||
fans.put("id", fid);
|
||||
fans.put("fan_id", myId);
|
||||
fans.put("vloger_id", vlogerId);
|
||||
fans.put("created_time", new Date());
|
||||
|
||||
// 判断对方是否关注我,如果关注我,那么双方都要互为朋友关系
|
||||
Fans vloger = queryFansRelationship(vlogerId, myId);
|
||||
System.out.println(vloger);
|
||||
if (vloger != null) {
|
||||
fans.setIsFanFriendOfMine(YesOrNo.YES.type);
|
||||
|
||||
// fans.setIsFanFriendOfMine(YesOrNo.YES.type);
|
||||
fans.put("is_fan_friend_of_mine",YesOrNo.YES.type);
|
||||
vloger.setIsFanFriendOfMine(YesOrNo.YES.type);
|
||||
fansMapper.updateByPrimaryKeySelective(vloger);
|
||||
System.out.println(vloger.getIsFanFriendOfMine());
|
||||
} else {
|
||||
fans.setIsFanFriendOfMine(YesOrNo.NO.type);
|
||||
// fans.setIsFanFriendOfMine(YesOrNo.NO.type);
|
||||
fans.put("is_fan_friend_of_mine",YesOrNo.NO.type);
|
||||
}
|
||||
|
||||
fansMapper.insert(fans);
|
||||
|
||||
|
||||
@ -83,11 +93,17 @@ public class FansServiceImpl extends BaseInfoProperties implements FansService {
|
||||
}
|
||||
|
||||
public Fans queryFansRelationship(String fanId, String vlogerId) {
|
||||
Example example = new Example(Fans.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("vlogerId", vlogerId);
|
||||
criteria.andEqualTo("fanId", fanId);
|
||||
List list = fansMapper.selectByExample(example);
|
||||
// Example example = new Example(Fans.class);
|
||||
// Example.Criteria criteria = example.createCriteria();
|
||||
// criteria.andEqualTo("vlogerId", vlogerId);
|
||||
// criteria.andEqualTo("fanId", fanId);
|
||||
|
||||
|
||||
Map<String, Object> mapexample = new HashMap<>();
|
||||
mapexample.put("vlogerId", vlogerId);
|
||||
mapexample.put("fanId", fanId);
|
||||
|
||||
List list = fansMapper.selectByExample(mapexample);
|
||||
|
||||
Fans fan = null;
|
||||
if (list != null && list.size() > 0 && !list.isEmpty()) {
|
||||
@ -112,7 +128,8 @@ public class FansServiceImpl extends BaseInfoProperties implements FansService {
|
||||
}
|
||||
|
||||
// 删除自己的关注关联表记录
|
||||
fansMapper.delete(fan);
|
||||
String fanId = fan.getId();
|
||||
fansMapper.delete(fanId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,6 +116,7 @@ public class UserServiceImpl implements UserService {
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Users updateUserInfo(UpdatedUserBO updatedUserBO) {
|
||||
@ -129,33 +130,54 @@ public class UserServiceImpl implements UserService {
|
||||
@Transactional
|
||||
@Override
|
||||
public Users updateUserInfo(UpdatedUserBO updatedUserBO, Integer type) {
|
||||
|
||||
Example example = new Example(Users.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
if (type == UserInfoModifyType.NICKNAME.type) {
|
||||
criteria.andEqualTo("nickname", updatedUserBO.getNickname());
|
||||
Users user = usersMapper.selectOneByExample(example);
|
||||
if (user != null) {
|
||||
GraceException.display(ResponseStatusEnum.USER_INFO_UPDATED_NICKNAME_EXIST_ERROR);
|
||||
}
|
||||
usersMapper.updateNickname(updatedUserBO);
|
||||
}
|
||||
if (type == UserInfoModifyType.SEX.type) {
|
||||
usersMapper.updateSex(updatedUserBO);
|
||||
}
|
||||
if (type == UserInfoModifyType.BIRTHDAY.type) {
|
||||
usersMapper.updateBirthday(updatedUserBO);
|
||||
}
|
||||
if (type == UserInfoModifyType.LOCATION.type) {
|
||||
usersMapper.updateLocation(updatedUserBO);
|
||||
}
|
||||
if (type == UserInfoModifyType.DESC.type) {
|
||||
usersMapper.updateDescription(updatedUserBO);
|
||||
}
|
||||
|
||||
if (type == UserInfoModifyType.IMOOCNUM.type) {
|
||||
criteria.andEqualTo("imoocNum", updatedUserBO.getImoocNum());
|
||||
Users user = usersMapper.selectOneByExample(example);
|
||||
if (user != null) {
|
||||
GraceException.display(ResponseStatusEnum.USER_INFO_UPDATED_NICKNAME_EXIST_ERROR);
|
||||
}
|
||||
|
||||
Users tempUser = getUser(updatedUserBO.getId());
|
||||
if (tempUser.getCanImoocNumBeUpdated() == YesOrNo.NO.type) {
|
||||
GraceException.display(ResponseStatusEnum.USER_INFO_CANT_UPDATED_IMOOCNUM_ERROR);
|
||||
}
|
||||
|
||||
updatedUserBO.setCanImoocNumBeUpdated(YesOrNo.NO.type);
|
||||
usersMapper.updateVnum(updatedUserBO);
|
||||
}
|
||||
|
||||
return updateUserInfo(updatedUserBO);
|
||||
|
||||
return getUser(updatedUserBO.getId());
|
||||
|
||||
// Example example = new Example(Users.class);
|
||||
// Example.Criteria criteria = example.createCriteria();
|
||||
// if (type == UserInfoModifyType.NICKNAME.type) {
|
||||
// criteria.andEqualTo("nickname", updatedUserBO.getNickname());
|
||||
// Users user = usersMapper.selectOneByExample(example);
|
||||
// if (user != null) {
|
||||
// GraceException.display(ResponseStatusEnum.USER_INFO_UPDATED_NICKNAME_EXIST_ERROR);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (type == UserInfoModifyType.IMOOCNUM.type) {
|
||||
// criteria.andEqualTo("imoocNum", updatedUserBO.getImoocNum());
|
||||
// Users user = usersMapper.selectOneByExample(example);
|
||||
// if (user != null) {
|
||||
// GraceException.display(ResponseStatusEnum.USER_INFO_UPDATED_NICKNAME_EXIST_ERROR);
|
||||
// }
|
||||
//
|
||||
// Users tempUser = getUser(updatedUserBO.getId());
|
||||
// if (tempUser.getCanImoocNumBeUpdated() == YesOrNo.NO.type) {
|
||||
// GraceException.display(ResponseStatusEnum.USER_INFO_CANT_UPDATED_IMOOCNUM_ERROR);
|
||||
// }
|
||||
//
|
||||
// updatedUserBO.setCanImoocNumBeUpdated(YesOrNo.NO.type);
|
||||
// }
|
||||
//
|
||||
// return updateUserInfo(updatedUserBO);
|
||||
|
||||
}
|
||||
|
||||
@ -174,7 +196,7 @@ public class UserServiceImpl implements UserService {
|
||||
user.setFace(USER_FACE1);
|
||||
user.setBirthday(DateUtil.stringToDate("1999-01-01"));
|
||||
user.setSex(Sex.secret.type);
|
||||
user.setBgImg("http://82.156.121.2:29000/bucket/IMG20241212102441.jpg");
|
||||
user.setBgImg(USER_FACE1);
|
||||
user.setCountry("中国");
|
||||
user.setProvince("");
|
||||
user.setCity("");
|
||||
@ -252,7 +274,7 @@ public class UserServiceImpl implements UserService {
|
||||
user.setFace(USER_FACE1);
|
||||
user.setBirthday(DateUtil.stringToDate("1999-01-01"));
|
||||
user.setSex(Sex.secret.type);
|
||||
user.setBgImg("http://82.156.121.2:29000/bucket/IMG20241212102441.jpg"); // 测试用地址
|
||||
user.setBgImg("https://wuzhongjie.com.cn/download/logo.png"); // 测试用地址
|
||||
user.setCountry("中国");
|
||||
user.setProvince("");
|
||||
user.setCity("");
|
||||
|
@ -23,10 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
|
||||
@ -51,50 +48,104 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateVlogStatus(String fileId,Integer status,String reason) {
|
||||
Example example = new Example(Vlog.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("fileId", fileId);
|
||||
// Example example = new Example(Vlog.class);
|
||||
// Example.Criteria criteria = example.createCriteria();
|
||||
// criteria.andEqualTo("fileId", fileId);
|
||||
//
|
||||
// Vlog pendingVlog = new Vlog();
|
||||
// pendingVlog.setStatus(status);
|
||||
// pendingVlog.setReason(reason);
|
||||
// vlogMapper.updateVlogStatus(fileId, example);
|
||||
|
||||
Vlog pendingVlog = new Vlog();
|
||||
pendingVlog.setStatus(status);
|
||||
pendingVlog.setReason(reason);
|
||||
// 示例:更新 vlog 表
|
||||
Map<String, Object> updateFields = new HashMap<>();
|
||||
updateFields.put("status", status);
|
||||
updateFields.put("reason", reason);
|
||||
|
||||
vlogMapper.updateByExampleSelective(pendingVlog, example);
|
||||
vlogMapper.dynamicUpdate(
|
||||
"file_id", // 主键字段名
|
||||
fileId, // 主键值
|
||||
updateFields // 更新字段
|
||||
);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateVlogFirstImg(String fileId,String url,String fileUrl) {
|
||||
Example example = new Example(Vlog.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("fileId", fileId);
|
||||
Vlog pendingVlog = new Vlog();
|
||||
pendingVlog.setFirstFrameImg(url);
|
||||
pendingVlog.setUrl(fileUrl);
|
||||
// Example example = new Example(Vlog.class);
|
||||
// Example.Criteria criteria = example.createCriteria();
|
||||
// criteria.andEqualTo("fileId", fileId);
|
||||
// Vlog pendingVlog = new Vlog();
|
||||
// pendingVlog.setFirstFrameImg(url);
|
||||
// pendingVlog.setUrl(fileUrl);
|
||||
//
|
||||
// vlogMapper.updateByExampleSelective(pendingVlog, example);
|
||||
// 示例:更新 vlog 表
|
||||
Map<String, Object> updateFields = new HashMap<>();
|
||||
updateFields.put("first_frame_img", url);
|
||||
updateFields.put("url", fileUrl);
|
||||
|
||||
vlogMapper.dynamicUpdate(
|
||||
"file_id", // 主键字段名
|
||||
fileId, // 主键值
|
||||
updateFields // 更新字段
|
||||
);
|
||||
|
||||
vlogMapper.updateByExampleSelective(pendingVlog, example);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void createVlog(VlogBO vlogBO) {
|
||||
|
||||
// String vid = sid.nextShort();
|
||||
//
|
||||
// Vlog vlog = new Vlog();
|
||||
// BeanUtils.copyProperties(vlogBO, vlog);
|
||||
//
|
||||
// vlog.setId(vid);
|
||||
//
|
||||
// vlog.setLikeCounts(0);
|
||||
// vlog.setCommentsCounts(0);
|
||||
// vlog.setStatus(0);
|
||||
// vlog.setIsPrivate(YesOrNo.NO.type);
|
||||
//
|
||||
// vlog.setCreatedTime(new Date());
|
||||
// vlog.setUpdatedTime(new Date());
|
||||
//
|
||||
// vlogMapper.insert(vlog);
|
||||
String vid = sid.nextShort();
|
||||
Map<String, Object> vlog = new HashMap<>();
|
||||
|
||||
Vlog vlog = new Vlog();
|
||||
BeanUtils.copyProperties(vlogBO, vlog);
|
||||
vlog.put("id", vid);
|
||||
vlog.put("vloger_id", vlogBO.getVlogerId());
|
||||
vlog.put("url", vlogBO.getUrl());
|
||||
vlog.put("title", vlogBO.getTitle());
|
||||
vlog.put("width", vlogBO.getWidth());
|
||||
vlog.put("height", vlogBO.getHeight());
|
||||
vlog.put("is_private", YesOrNo.NO.type);
|
||||
vlog.put("created_time", new Date());
|
||||
vlog.put("updated_time", new Date());
|
||||
vlog.put("city_code", vlogBO.getCityCode());
|
||||
vlog.put("file_id", vlogBO.getFileId());
|
||||
vlog.put("first_frame_img", vlogBO.getFirstFrameImg());
|
||||
|
||||
vlog.setId(vid);
|
||||
|
||||
vlog.setLikeCounts(0);
|
||||
vlog.setCommentsCounts(0);
|
||||
vlog.setStatus(0);
|
||||
vlog.setIsPrivate(YesOrNo.NO.type);
|
||||
vlogMapper.dynamicInsert(vlog);
|
||||
|
||||
vlog.setCreatedTime(new Date());
|
||||
vlog.setUpdatedTime(new Date());
|
||||
|
||||
vlogMapper.insert(vlog);
|
||||
//多条导入
|
||||
// List<Map<String, Object>> vlogList = new ArrayList<>();
|
||||
//
|
||||
// Map<String, Object> vlog1 = new HashMap<>();
|
||||
// vlog1.put("id", sid.nextShort());
|
||||
// vlog1.put("title", "视频1");
|
||||
// vlogList.add(vlog1);
|
||||
//
|
||||
// Map<String, Object> vlog2 = new HashMap<>();
|
||||
// vlog2.put("id", sid.nextShort());
|
||||
// vlog2.put("title", "视频2");
|
||||
// vlogList.add(vlog2);
|
||||
//
|
||||
// vlogMapper.dynamicBatchInsert(vlogList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -212,15 +263,24 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
|
||||
public void changeToPrivateOrPublic(String userId,
|
||||
String vlogId,
|
||||
Integer yesOrNo) {
|
||||
Example example = new Example(Vlog.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("id", vlogId);
|
||||
criteria.andEqualTo("vlogerId", userId);
|
||||
// Example example = new Example(Vlog.class);
|
||||
// Example.Criteria criteria = example.createCriteria();
|
||||
// criteria.andEqualTo("id", vlogId);
|
||||
// criteria.andEqualTo("vlogerId", userId);
|
||||
//
|
||||
// Vlog pendingVlog = new Vlog();
|
||||
// pendingVlog.setIsPrivate(yesOrNo);
|
||||
|
||||
Vlog pendingVlog = new Vlog();
|
||||
pendingVlog.setIsPrivate(yesOrNo);
|
||||
Map<String, Object> updates = new HashMap<>();
|
||||
updates.put("is_private", 2);
|
||||
Map<String, Object> conditions = new HashMap<>();
|
||||
conditions.put("id", vlogId);
|
||||
conditions.put("vloger_id", userId);
|
||||
vlogMapper.updateVlogByConditions(
|
||||
updates,
|
||||
conditions
|
||||
);
|
||||
|
||||
vlogMapper.updateByExampleSelective(pendingVlog, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -229,14 +289,30 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
|
||||
Integer pageSize,
|
||||
Integer yesOrNo) {
|
||||
|
||||
Example example = new Example(Vlog.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("vlogerId", userId);
|
||||
criteria.andEqualTo("isPrivate", yesOrNo);
|
||||
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<Vlog> list = vlogMapper.selectByExample(example);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// if (StringUtils.isNotBlank(search)) {
|
||||
// map.put("search", search);
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(cityCode)) {
|
||||
// map.put("cityCode", cityCode);
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(status)) {
|
||||
// map.put("status", status);
|
||||
// }
|
||||
|
||||
map.put("vlogerId", userId);
|
||||
|
||||
List<IndexVlogVO> list = vlogMapper.selectMyPublic(map);
|
||||
|
||||
for (IndexVlogVO v : list) {
|
||||
String vlogId = v.getVlogId();
|
||||
// 获得当前视频被点赞过的总数
|
||||
v.setLikeCounts(getVlogBeLikedCounts(vlogId));
|
||||
// 评论数
|
||||
v.setCommentsCounts(getVlogComment(vlogId));
|
||||
}
|
||||
return setterPagedGrid(list, page);
|
||||
}
|
||||
|
||||
@ -281,23 +357,41 @@ public class VlogServiceImpl extends BaseInfoProperties implements VlogService {
|
||||
//
|
||||
@Override
|
||||
public Vlog getVlog(String id) {
|
||||
Vlog vlog = vlogMapper.selectByPrimaryKey(id);
|
||||
// Vlog vlog = new Vlog();
|
||||
// vlog.setId(id);
|
||||
// Vlog vlog1 = vlogMapper.selectOne(vlog);
|
||||
return vlog;
|
||||
// Vlog vlog = vlogMapper.selectByPrimaryKey(id);
|
||||
// return vlog;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("vlogId", id);
|
||||
|
||||
List<IndexVlogVO> list = vlogMapper.getVlogDetailFromId(map);
|
||||
|
||||
if (list != null && list.size() > 0 && !list.isEmpty()) {
|
||||
IndexVlogVO result = list.get(0);
|
||||
Vlog vlogVO = new Vlog();
|
||||
BeanUtils.copyProperties(result, vlogVO);
|
||||
return vlogVO;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void flushCounts(String vlogId, Integer counts) {
|
||||
//
|
||||
// Vlog vlog = new Vlog();
|
||||
// vlog.setId(vlogId);
|
||||
// vlog.setLikeCounts(counts);
|
||||
// int i = vlogMapper.updateByPrimaryKeySelective(vlog);
|
||||
|
||||
Vlog vlog = new Vlog();
|
||||
vlog.setId(vlogId);
|
||||
vlog.setLikeCounts(counts);
|
||||
// System.out.println(vlog.toString());
|
||||
int i = vlogMapper.updateByPrimaryKeySelective(vlog);
|
||||
// System.out.println(i);
|
||||
// 示例:更新 vlog 表
|
||||
Map<String, Object> updateFields = new HashMap<>();
|
||||
updateFields.put("like_counts", counts);
|
||||
|
||||
vlogMapper.dynamicUpdate(
|
||||
"id", // 主键字段名
|
||||
vlogId, // 主键值
|
||||
updateFields // 更新字段
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user