123
This commit is contained in:
@@ -76,12 +76,13 @@ public class UserController extends BaseController {
|
||||
}
|
||||
|
||||
@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){
|
||||
limit = 40;
|
||||
}
|
||||
List<User> users = userService.list(Wrappers.lambdaQuery(User.class)
|
||||
.select(User::getUsercode)
|
||||
.eq(isAnchor != null, User::getIsAnchor, isAnchor)
|
||||
.like(StringUtils.isNotEmpty(usercode), User::getUsercode, usercode)
|
||||
.last("limit " + limit));
|
||||
return R.ok(users.stream().map(User::getUsercode).collect(Collectors.toList()));
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class DynamicCreateVo {
|
||||
|
||||
private List<String> imageList;
|
||||
private String imageList;
|
||||
private String content;
|
||||
private Long usercode;
|
||||
private String usercode;
|
||||
}
|
||||
|
||||
@@ -112,13 +112,17 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
|
||||
|
||||
@Override
|
||||
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("动态内容和图片必须上传");
|
||||
}
|
||||
if(bo.getImageList() != null && bo.getImageList().size() > 9){
|
||||
String[] imageArrays = bo.getImageList().split(",");
|
||||
if(imageArrays.length > 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){
|
||||
throw new ServiceException("只有主播可以发布动态哦");
|
||||
}
|
||||
@@ -132,16 +136,10 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
|
||||
} else {
|
||||
dynamic.setCity(citysService.getByCityId(dynamic.getCityId()));
|
||||
}
|
||||
if(CollectionUtil.isNotEmpty(bo.getImageList())){
|
||||
dynamic.setIsAttach(1);
|
||||
}else{
|
||||
dynamic.setIsAttach(0);
|
||||
}
|
||||
this.save(dynamic);
|
||||
List<DynamicImages> dynamicImages = new ArrayList<>();
|
||||
List<String> imageList = bo.getImageList();
|
||||
if(CollectionUtil.isNotEmpty(imageList)){
|
||||
for (String image : imageList) {
|
||||
for (String image : imageArrays) {
|
||||
CaiFileUtils.FileSize fileSize = CaiFileUtils.getFastFileSize(image);
|
||||
DynamicImages po = new DynamicImages();
|
||||
po.setUserId(dynamic.getUserId());
|
||||
@@ -154,7 +152,6 @@ public class DynamicServiceImpl extends ServiceImpl<DynamicMapper, Dynamic> impl
|
||||
}
|
||||
dynamicImagesService.saveBatch(dynamicImages);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDynamic(DynamicAddReq res) {
|
||||
|
||||
Reference in New Issue
Block a user