feat(system): 新增用户批量查询

master
yang 2025-02-12 10:18:26 +08:00
parent 103a6e7db7
commit be124c92fa
5 changed files with 24 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@ -36,7 +37,7 @@ public class ModelImageCommentController {
*/ */
@ApiOperation(value = "图片评论发布") @ApiOperation(value = "图片评论发布")
@PostMapping("/comment") @PostMapping("/comment")
public AjaxResult comment(@RequestBody ModelImageCommentRes modelImageCommentRes) { public AjaxResult comment(@Valid @RequestBody ModelImageCommentRes modelImageCommentRes) {
modelImageCommentService.comment(modelImageCommentRes); modelImageCommentService.comment(modelImageCommentRes);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -46,8 +47,8 @@ public class ModelImageCommentController {
*/ */
@ApiOperation(value = "图片评论点赞/取消") @ApiOperation(value = "图片评论点赞/取消")
@RepeatSubmit @RepeatSubmit
@GetMapping("/commentLike/{commentId}") @GetMapping("/commentLike")
public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { public AjaxResult commentLike(@Valid @NotNull(message = "评论id不能为空") Long commentId) {
modelImageCommentLikeService.like(commentId); modelImageCommentLikeService.like(commentId);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -56,8 +57,8 @@ public class ModelImageCommentController {
* *
*/ */
@ApiOperation(value = "删除图片评论") @ApiOperation(value = "删除图片评论")
@GetMapping("/commentDelete/{commentId}") @GetMapping("/commentDelete")
public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { public AjaxResult commentDelete(@Valid @NotNull(message = "评论id不能为空") Long commentId) {
modelImageCommentService.removeById(commentId); modelImageCommentService.removeById(commentId);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -66,8 +67,8 @@ public class ModelImageCommentController {
* *
*/ */
@ApiOperation(value = "获取图片评论") @ApiOperation(value = "获取图片评论")
@GetMapping("/comment/{imageId}") @GetMapping("/comment")
public AjaxResult getComment(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) { public AjaxResult getComment(@Valid @NotNull(message = "图片id不能为空") Long imageId) {
List<ModelImageCommentVo> modelImageCommentVoList = modelImageCommentService.getComment(imageId); List<ModelImageCommentVo> modelImageCommentVoList = modelImageCommentService.getComment(imageId);
return AjaxResult.success(modelImageCommentVoList); return AjaxResult.success(modelImageCommentVoList);
} }

View File

@ -138,4 +138,5 @@ public interface SysUserMapper
List<SysUser> listByIds(List<Long> userIdList); List<SysUser> listByIds(List<Long> userIdList);
List<SysUser> selectUserByIds(@Param("userIds") List<Long> userIds);
} }

View File

@ -218,4 +218,5 @@ public interface ISysUserService
List<SysUser> listByIds(List<Long> userIdList); List<SysUser> listByIds(List<Long> userIdList);
List<SysUser> selectUserByIds(List<Long> userIds);
} }

View File

@ -33,6 +33,7 @@ import org.springframework.util.CollectionUtils;
import javax.validation.Validator; import javax.validation.Validator;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -674,4 +675,9 @@ public class SysUserServiceImpl implements ISysUserService
return sb.toString(); return sb.toString();
} }
@Override
public List<SysUser> selectUserByIds(List<Long> userIds) {
return userMapper.selectUserByIds(userIds);
}
} }

View File

@ -167,6 +167,14 @@
</select> </select>
<select id="selectUserByIds" resultType="com.mcwl.common.core.domain.entity.SysUser">
<include refid="selectUserVo"/>
where u.user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if> <if test="userId != null and userId != 0">user_id,</if>