Commit 8576a507 authored by luojun's avatar luojun

查询近10条的用户会话记录

parent 071ee1d9
Pipeline #6422 failed with stages
......@@ -83,4 +83,6 @@ public interface ChatgptRoleRecordsService extends CommonService<ChatgptRoleReco
* @return
*/
String queryMaxSessionId();
List<ChatgptRoleRecordsDto> queryTenRecords(Integer userId);
}
......@@ -114,6 +114,12 @@ public class ChatgptRoleRecordsServiceImpl extends CommonServiceImpl<ChatgptRole
return String.valueOf(i+1);
}
@Override
public List<ChatgptRoleRecordsDto> queryTenRecords(Integer userId) {
List<ChatgptRoleRecordsDto> chatgptRoleRecordsDtos = chatgptRoleRecordsMapper.queryTenRecordByUserId(userId);
return ConvertUtil.convertList(chatgptRoleRecordsDtos,ChatgptRoleRecordsDto.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer removeById(Integer id){
......
......@@ -2,6 +2,7 @@ package admin.modules.chatgpt.service.mapper;
import admin.base.CommonMapper;
import admin.modules.chatgpt.domain.ChatgptRoleRecords;
import admin.modules.chatgpt.service.dto.ChatgptRoleRecordsDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -26,4 +27,6 @@ public interface ChatgptRoleRecordsMapper extends CommonMapper<ChatgptRoleRecord
Integer findBySessionCount(Long memberId);
Integer findByDialogueCount(Long memberId);
List<ChatgptRoleRecordsDto> queryTenRecordByUserId(@Param("userId") Integer userId);
}
......@@ -15,10 +15,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.concurrent.TimeUnit;
......@@ -50,4 +47,13 @@ public class ChatgptRoleRecordsController {
query.setUserId(byUserName);
return ApiResponse.buildSuccess(chatgptRoleSessionService.queryAll(query,pageable));
}
@ApiOperation("大屏临时查询十条会话记录")
@GetMapping(value = "queryTenRecords")
public ApiResponse<Object> queryTenRecords(@RequestParam String userName) {
Integer userId = ScreenEnum.getByUserName(userName);
return ApiResponse.buildSuccess(chatgptRoleRecordsService.queryTenRecords(userId));
}
}
......@@ -41,4 +41,11 @@
FROM `chatgpt_role_records`
WHERE sender_id = #{memberId}
</select>
<select id="queryTenRecordByUserId" resultType="admin.modules.chatgpt.domain.ChatgptRoleRecords">
SELECT *
FROM `chatgpt_role_records`
WHERE sender_id = #{userId} or receiver_id =#{userId} order by create_time desc limit 10
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment