This commit is contained in:
张良(004796)
2024-01-02 17:01:28 +08:00
parent cf724410f3
commit 2c68510a02
17 changed files with 73 additions and 24 deletions

View File

@@ -4,6 +4,7 @@ public class RedisConstant {
public static final String REDIS_P = "cai-"; public static final String REDIS_P = "cai-";
public static final String SYSTEM_CONFIG = REDIS_P + "system-config"; public static final String SYSTEM_CONFIG = REDIS_P + "system-config";
public static final String CITY_CACHE_REDIS = REDIS_P + "city"; public static final String CITY_CACHE_REDIS = REDIS_P + "city";
public static final String CITY_CACHE_ALL_REDIS = REDIS_P + "cityAll";
public static final String DYNAMIC_TOTAL_CACHE_REDIS = REDIS_P + "synamicTotal:%s:%s"; public static final String DYNAMIC_TOTAL_CACHE_REDIS = REDIS_P + "synamicTotal:%s:%s";
public static final String CODE_REDIS = REDIS_P + "code:%s:%s"; public static final String CODE_REDIS = REDIS_P + "code:%s:%s";
public static final String USER_GREET_TOTAL_REDIS = REDIS_P + "userGreetTotal:%s:%s"; public static final String USER_GREET_TOTAL_REDIS = REDIS_P + "userGreetTotal:%s:%s";

View File

@@ -76,7 +76,8 @@ public class User implements Serializable {
/** /**
* 城市 * 城市
*/ */
private Long city; private Integer cityId;
private String city;
/** /**
* 资料是否完成 0 未完成 1已完成 * 资料是否完成 0 未完成 1已完成
*/ */

View File

@@ -10,7 +10,7 @@ public class UserUpdateReq {
@Schema(description = "用户ID",accessMode = Schema.AccessMode.READ_ONLY) @Schema(description = "用户ID",accessMode = Schema.AccessMode.READ_ONLY)
private Long userId; private Long userId;
@Schema(description = "城市") @Schema(description = "城市")
private Long city; private Integer cityId;
@Schema(description = "昵称") @Schema(description = "昵称")
private String nickname; private String nickname;
@Schema(description = "生日") @Schema(description = "生日")

View File

@@ -17,5 +17,5 @@ public class AnchorListQuery {
private Integer type; private Integer type;
@Schema(description = "城市(同城查询使用)") @Schema(description = "城市(同城查询使用)")
private String city; private Integer cityId;
} }

View File

@@ -7,7 +7,7 @@ import lombok.Data;
@Schema(description = "群打招呼用户搜索") @Schema(description = "群打招呼用户搜索")
public class GreetQuery { public class GreetQuery {
@Schema(description = "城市") @Schema(description = "城市")
private Long city; private Integer cityId;
@Schema(description = "搜索类型 1=活跃 2=同城") @Schema(description = "搜索类型 1=活跃 2=同城")
private Integer type = 1; private Integer type = 1;
} }

View File

@@ -1,34 +1,44 @@
package com.ruoyi.cai.dto.app.vo; package com.ruoyi.cai.dto.app.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
@Data @Data
@Schema(description = "主播列表信息")
public class AnchorListVo { public class AnchorListVo {
/** /**
* 头像 * 头像
*/ */
@Schema(description = "主播头像")
private String avatar; private String avatar;
/** /**
* 性别 0 未知 1 女 2 男 * 性别 0 未知 1 女 2 男
*/ */
@Schema(description = "性别")
private Integer gender; private Integer gender;
/** /**
* 城市 * 城市
*/ */
private Long city; @Schema(description = "城市ID")
private Integer cityId;
@Schema(description = "城市")
private String city;
/** /**
* 昵称 * 昵称
*/ */
@Schema(description = "昵称")
private String nickname; private String nickname;
/** /**
* 用户号/ID号 * 用户号/ID号
*/ */
@Schema(description = "蜜瓜号")
private String usercode; private String usercode;
/** /**
* 用户评分 * 用户评分
*/ */
@Schema(description = "评分")
private BigDecimal giveScore; private BigDecimal giveScore;
} }

View File

@@ -54,8 +54,10 @@ public class CurrentUserInfoVo {
/** /**
* 城市 * 城市
*/ */
@Schema(description = "城市ID")
private Integer cityId;
@Schema(description = "城市") @Schema(description = "城市")
private Long city; private String city;
/** /**
* 是否是播主 0 否 1 是 * 是否是播主 0 否 1 是
*/ */

View File

@@ -26,8 +26,11 @@ public class DynamicVo {
/** /**
* 城市ID * 城市ID
*/ */
@Schema(description = "城市") @Schema(description = "城市ID")
private Integer cityId; private Integer cityId;
@Schema(description = "城市")
private String city;
/** /**
* 是否有附件 0 没有 1 有 * 是否有附件 0 没有 1 有
*/ */

View File

@@ -4,8 +4,6 @@ package com.ruoyi.cai.dto.app.vo.user;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
@Data @Data
public class UserBaseVo { public class UserBaseVo {
@@ -23,8 +21,10 @@ public class UserBaseVo {
/** /**
* 城市 * 城市
*/ */
@Schema(description = "城市ID")
private Integer cityId;
@Schema(description = "城市") @Schema(description = "城市")
private Long city; private Integer city;
/** /**
* 昵称 * 昵称
*/ */

View File

@@ -25,6 +25,10 @@ public class UserInfoVo {
private String nickname; private String nickname;
@Schema(description = "头像") @Schema(description = "头像")
private String avatar; private String avatar;
@Schema(description = "城市")
private String city;
@Schema(description = "城市ID")
private Integer cityId;
/** /**
* 价格默认50彩币 * 价格默认50彩币

View File

@@ -45,6 +45,8 @@ public class CurrentUserManager {
private AccountBankcardService accountBankcardService; private AccountBankcardService accountBankcardService;
@Resource @Resource
private ImUserRefClient userClient; private ImUserRefClient userClient;
@Autowired
private CitysService citysService;
public CurrentUserInfoVo currentInfo() { public CurrentUserInfoVo currentInfo() {
Long userId = LoginHelper.getUserId(); Long userId = LoginHelper.getUserId();
@@ -122,8 +124,9 @@ public class CurrentUserManager {
throw new ServiceException("性别不可以修改"); throw new ServiceException("性别不可以修改");
} }
} }
if(res.getCity() != null){ if(res.getCityId() != null){
update.set(User::getCity,res.getCity()); update.set(User::getCityId,res.getCityId());
update.set(User::getCity,citysService.getByCityId(res.getCityId()));
updateFlag=true; updateFlag=true;
} }
if(StringUtils.isNotEmpty(res.getAvatar())){ if(StringUtils.isNotEmpty(res.getAvatar())){

View File

@@ -15,4 +15,5 @@ public interface CitysService extends IService<Citys> {
Map<Long,String> all(); Map<Long,String> all();
String getByCityId(Integer cityId);
} }

View File

@@ -31,7 +31,7 @@ public class AnchorServiceImpl extends ServiceImpl<AnchorMapper, Anchor> impleme
@Override @Override
public Page<AnchorListVo> pageApp(PageQuery pageQuery, AnchorListQuery query) { public Page<AnchorListVo> pageApp(PageQuery pageQuery, AnchorListQuery query) {
if(query.getType() != null && query.getType() != 3){ if(query.getType() != null && query.getType() != 3){
query.setCity(null); query.setCityId(null);
} }
return baseMapper.pageApp(pageQuery.build(),query); return baseMapper.pageApp(pageQuery.build(),query);
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -29,9 +30,16 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
@Autowired @Autowired
private StringRedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
@PostConstruct
public void init() {
List<Citys> list = this.list();
Map<Long, String> map = list.stream().collect(Collectors.toMap(Citys::getId, Citys::getName));
redisTemplate.opsForHash().putAll(RedisConstant.CITY_CACHE_REDIS, map);
}
@Override @Override
public Map<Long, String> all() { public Map<Long, String> all() {
String value = redisTemplate.opsForValue().get(RedisConstant.CITY_CACHE_REDIS); String value = redisTemplate.opsForValue().get(RedisConstant.CITY_CACHE_ALL_REDIS);
if(value != null){ if(value != null){
return JSON.parseObject(value, new TypeReference<LinkedHashMap<Long, String>>(){}); return JSON.parseObject(value, new TypeReference<LinkedHashMap<Long, String>>(){});
} }
@@ -40,4 +48,21 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
redisTemplate.opsForValue().set(RedisConstant.CITY_CACHE_REDIS,JSON.toJSONString(map),30, TimeUnit.DAYS); redisTemplate.opsForValue().set(RedisConstant.CITY_CACHE_REDIS,JSON.toJSONString(map),30, TimeUnit.DAYS);
return map; return map;
} }
@Override
public String getByCityId(Integer cityId){
if(cityId == null || cityId == 0){
return null;
}
Object val = redisTemplate.opsForHash().get(RedisConstant.CITY_CACHE_REDIS, cityId);
if(val != null){
return String.valueOf(val);
}
Citys city = this.getById(cityId);
if(city == null){
return null;
}
redisTemplate.opsForHash().put(RedisConstant.CITY_CACHE_REDIS, cityId, city.getName());
return city.getName();
}
} }

View File

@@ -88,6 +88,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
} }
} }
vo.setCity(user.getCity());
vo.setCityId(user.getCityId());
vo.setFansNum(userFollowService.getFansNumByUserId(userId)); vo.setFansNum(userFollowService.getFansNumByUserId(userId));
vo.setStar(userFollowService.checkStar(currentUserId, userId)); vo.setStar(userFollowService.checkStar(currentUserId, userId));
vo.setAlbumList(userAlbumService.getUserAlbum(userId, user.getIsAnchor())); vo.setAlbumList(userAlbumService.getUserAlbum(userId, user.getIsAnchor()));

View File

@@ -14,14 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="giveScore" column="give_score"/> <result property="giveScore" column="give_score"/>
<result property="serviceCount" column="service_count"/> <result property="serviceCount" column="service_count"/>
<result property="serviceTime" column="service_time"/> <result property="serviceTime" column="service_time"/>
<result property="giftInviteRate" column="gift_invite_rate"/>
<result property="videoRate" column="video_rate"/> <result property="videoRate" column="video_rate"/>
<result property="giftRate" column="gift_rate"/> <result property="giftRate" column="gift_rate"/>
<result property="recommendStatus" column="recommend_status"/> <result property="recommendStatus" column="recommend_status"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="jifen" column="jifen"/>
<result property="lastJifen" column="last_jifen"/>
</resultMap> </resultMap>
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorAdminVo"> <select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorAdminVo">
select select
@@ -30,13 +27,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join cai_user t2 on t1.user_id = t2.id left join cai_user t2 on t1.user_id = t2.id
</select> </select>
<select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.AnchorListVo"> <select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.AnchorListVo">
select t1.avatar,t1.gender,t1.city,t1.nickname,t1.usercode,t2.give_score select t1.avatar,t1.gender,t1.city,t1.nickname,t1.usercode,t1.city_id,t1.city,t2.give_score
from cai_user t1 from cai_user t1
join cai_anchor t2 on t1.id = t2.user_id join cai_anchor t2 on t1.id = t2.user_id
join cai_user_online t3 on t1.id = t3.user_id join cai_user_online t3 on t1.id = t3.user_id
where t1.status = 0 and t1.is_anchor = 1 where t1.status = 0 and t1.is_anchor = 1
<if test="query.city != null and query.city != ''"> <if test="query.cityId != null and query.cityId != ''">
and t1.city = #{query.city} and t1.city_id = #{query.cityId}
</if> </if>
<if test="query.type != null"> <if test="query.type != null">
<if test="query.type == 1"> <if test="query.type == 1">

View File

@@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo"> <select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
select t1.avatar,t1.gender,t1.city,t1.nickname,t1.usercode,t1.age,t2.last_live_time select t1.avatar,t1.gender,t1.city,t1.city_id,t1.nickname,t1.usercode,t1.age,t2.last_live_time
from cai_user t1 from cai_user t1
join cai_user_online t2 on t1.id = t2.user_id join cai_user_online t2 on t1.id = t2.user_id
where t1.status = 0 where t1.status = 0
@@ -43,12 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by t2.last_live_time desc order by t2.last_live_time desc
</select> </select>
<select id="greetPageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo"> <select id="greetPageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
select t1.avatar,t1.gender,t1.city,t1.nickname,t1.usercode,t1.age,t2.last_live_time select t1.avatar,t1.gender,t1.city,t1.city_id,t1.nickname,t1.usercode,t1.age,t2.last_live_time
from cai_user t1 from cai_user t1
join cai_user_online t2 on t1.id = t2.user_id join cai_user_online t2 on t1.id = t2.user_id
where t1.status = 0 where t1.status = 0
<if test="query.city != null and query.city != ''"> <if test="query.cityId != null and query.cityId != ''">
and t1.city = #{query.city} and t1.city_id = #{query.cityId}
</if> </if>
order by t2.last_live_time desc order by t2.last_live_time desc
</select> </select>