This commit is contained in:
777
2025-04-28 14:08:13 +08:00
parent 6d8e255299
commit 34c651e15a
3 changed files with 23 additions and 25 deletions

View File

@@ -76,12 +76,13 @@ public class UserController extends BaseController {
} }
@GetMapping("/listByUserCode") @GetMapping("/listByUserCode")
public R<List<String>> listByUserCode(String usercode,int limit){ public R<List<String>> listByUserCode(Integer isAnchor, String usercode,int limit){
if(limit == 0){ if(limit == 0){
limit = 40; limit = 40;
} }
List<User> users = userService.list(Wrappers.lambdaQuery(User.class) List<User> users = userService.list(Wrappers.lambdaQuery(User.class)
.select(User::getUsercode) .select(User::getUsercode)
.eq(isAnchor != null, User::getIsAnchor, isAnchor)
.like(StringUtils.isNotEmpty(usercode), User::getUsercode, usercode) .like(StringUtils.isNotEmpty(usercode), User::getUsercode, usercode)
.last("limit " + limit)); .last("limit " + limit));
return R.ok(users.stream().map(User::getUsercode).collect(Collectors.toList())); return R.ok(users.stream().map(User::getUsercode).collect(Collectors.toList()));

View File

@@ -7,7 +7,7 @@ import java.util.List;
@Data @Data
public class DynamicCreateVo { public class DynamicCreateVo {
private List<String> imageList; private String imageList;
private String content; private String content;
private Long usercode; private String usercode;
} }

View File

@@ -112,13 +112,17 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
@Override @Override
public void createAdmin(DynamicCreateVo bo) { public void createAdmin(DynamicCreateVo bo) {
if(CollectionUtil.isEmpty(bo.getImageList()) || StringUtils.isEmpty(bo.getContent())){ if(StringUtils.isEmpty(bo.getImageList()) || StringUtils.isEmpty(bo.getContent())){
throw new ServiceException("动态内容和图片必须上传"); throw new ServiceException("动态内容和图片必须上传");
} }
if(bo.getImageList() != null && bo.getImageList().size() > 9){ String[] imageArrays = bo.getImageList().split(",");
if(imageArrays.length > 9){
throw new ServiceException("最多只能发送9张照片哦"); throw new ServiceException("最多只能发送9张照片哦");
} }
User user = userService.getById(bo.getUsercode()); User user = userService.getByUserCode(bo.getUsercode());
if(user == null){
throw new ServiceException("主播不存在");
}
if(user.getIsAnchor() == null || user.getIsAnchor() != 1){ if(user.getIsAnchor() == null || user.getIsAnchor() != 1){
throw new ServiceException("只有主播可以发布动态哦"); throw new ServiceException("只有主播可以发布动态哦");
} }
@@ -132,16 +136,10 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
} else { } else {
dynamic.setCity(citysService.getByCityId(dynamic.getCityId())); dynamic.setCity(citysService.getByCityId(dynamic.getCityId()));
} }
if(CollectionUtil.isNotEmpty(bo.getImageList())){
dynamic.setIsAttach(1); dynamic.setIsAttach(1);
}else{
dynamic.setIsAttach(0);
}
this.save(dynamic); this.save(dynamic);
List<DynamicImages> dynamicImages = new ArrayList<>(); List<DynamicImages> dynamicImages = new ArrayList<>();
List<String> imageList = bo.getImageList(); for (String image : imageArrays) {
if(CollectionUtil.isNotEmpty(imageList)){
for (String image : imageList) {
CaiFileUtils.FileSize fileSize = CaiFileUtils.getFastFileSize(image); CaiFileUtils.FileSize fileSize = CaiFileUtils.getFastFileSize(image);
DynamicImages po = new DynamicImages(); DynamicImages po = new DynamicImages();
po.setUserId(dynamic.getUserId()); po.setUserId(dynamic.getUserId());
@@ -154,7 +152,6 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
} }
dynamicImagesService.saveBatch(dynamicImages); dynamicImagesService.saveBatch(dynamicImages);
} }
}
@Override @Override
public void saveDynamic(DynamicAddReq res) { public void saveDynamic(DynamicAddReq res) {