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 SYSTEM_CONFIG = REDIS_P + "system-config";
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 CODE_REDIS = REDIS_P + "code:%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已完成
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,8 +26,11 @@ public class DynamicVo {
/**
* 城市ID
*/
@Schema(description = "城市")
@Schema(description = "城市ID")
private Integer cityId;
@Schema(description = "城市")
private String city;
/**
* 是否有附件 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 lombok.Data;
import java.time.LocalDateTime;
@Data
public class UserBaseVo {
@@ -23,8 +21,10 @@ public class UserBaseVo {
/**
* 城市
*/
@Schema(description = "城市ID")
private Integer cityId;
@Schema(description = "城市")
private Long city;
private Integer city;
/**
* 昵称
*/

View File

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

View File

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

View File

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

View File

@@ -31,7 +31,7 @@ public class AnchorServiceImpl extends ServiceImpl<AnchorMapper, Anchor> impleme
@Override
public Page<AnchorListVo> pageApp(PageQuery pageQuery, AnchorListQuery query) {
if(query.getType() != null && query.getType() != 3){
query.setCity(null);
query.setCityId(null);
}
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.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -29,9 +30,16 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
@Autowired
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
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){
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);
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.setStar(userFollowService.checkStar(currentUserId, userId));
vo.setAlbumList(userAlbumService.getUserAlbum(userId, user.getIsAnchor()));