123
This commit is contained in:
@@ -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()));
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,28 +136,21 @@ 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)){
|
CaiFileUtils.FileSize fileSize = CaiFileUtils.getFastFileSize(image);
|
||||||
for (String image : imageList) {
|
DynamicImages po = new DynamicImages();
|
||||||
CaiFileUtils.FileSize fileSize = CaiFileUtils.getFastFileSize(image);
|
po.setUserId(dynamic.getUserId());
|
||||||
DynamicImages po = new DynamicImages();
|
po.setDynamicId(dynamic.getId());
|
||||||
po.setUserId(dynamic.getUserId());
|
po.setUrl(image);
|
||||||
po.setDynamicId(dynamic.getId());
|
po.setWidth(fileSize.getWidth());
|
||||||
po.setUrl(image);
|
po.setHeight(fileSize.getHeight());
|
||||||
po.setWidth(fileSize.getWidth());
|
po.setExts(fileSize.getSuffix());
|
||||||
po.setHeight(fileSize.getHeight());
|
dynamicImages.add(po);
|
||||||
po.setExts(fileSize.getSuffix());
|
|
||||||
dynamicImages.add(po);
|
|
||||||
}
|
|
||||||
dynamicImagesService.saveBatch(dynamicImages);
|
|
||||||
}
|
}
|
||||||
|
dynamicImagesService.saveBatch(dynamicImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user