Skip to content

Commit

Permalink
fix: event query. fix: remove lark invite.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballade0d committed Oct 19, 2024
1 parent 7ce80d0 commit 56781fe
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public Pagination<Event> query(EventQuery query, Integer current, Integer size)
Page<Event> page = new Page<>(current, size);
QueryWrapper<Event> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(query.id() != null, "id", query.id());
queryWrapper.like(query.summary() != null, "summary", query.summary());
queryWrapper.like(query.description() != null, "description", query.description());
queryWrapper.like(query.summary() != null && !query.summary().isEmpty(), "summary", query.summary());
queryWrapper.like(query.description() != null && !query.description().isEmpty(), "description", query.description());
LocalDateTime now = LocalDateTime.now();
if (Boolean.TRUE.equals(query.active())) {
queryWrapper.le("start", now);
Expand All @@ -172,10 +172,10 @@ public Pagination<Event> query(EventQuery query, Integer current, Integer size)
queryWrapper.ge(query.start() != null, "start", query.start());
queryWrapper.le(query.end() != null, "end", query.end());
}
queryWrapper.eq(query.location() != null, "location", query.location());
queryWrapper.eq(query.tag() != null, "tag", query.tag());
queryWrapper.eq(query.larkMeetingRoomName() != null, "lark_meeting_room_name", query.larkMeetingRoomName());
queryWrapper.eq(query.larkDepartmentName() != null, "lark_department_name", query.larkDepartmentName());
queryWrapper.eq(query.location() != null && !query.location().isEmpty(), "location", query.location());
queryWrapper.eq(query.tag() != null && !query.tag().isEmpty(), "tag", query.tag());
queryWrapper.eq(query.larkMeetingRoomName() != null && !query.larkMeetingRoomName().isEmpty(), "lark_meeting_room_name", query.larkMeetingRoomName());
queryWrapper.eq(query.larkDepartmentName() != null && !query.larkDepartmentName().isEmpty(), "lark_department_name", query.larkDepartmentName());
queryWrapper.exists(Boolean.TRUE.equals(query.participated()),
"SELECT 1 FROM subscription WHERE subscription.event_id = event.id AND subscription.link_id = " +
JWTInterceptor.userHolder.get().getUserId() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,11 @@ public String create(LarkEventCreate create) {
"resource":Room
"third_party":Email
*/
List<String> users = larkDepartmentServiceImpl.getUserList(create.departmentId());
List<CalendarEventAttendee> attendeeList = new ArrayList<>();
attendeeList.add(CalendarEventAttendee.newBuilder()
.type("resource")
.roomId(create.roomId())
.build());
for (String user : users) {
attendeeList.add(CalendarEventAttendee.newBuilder()
.type("user")
.userId(user)
.build());
}
CalendarEventAttendee[] attendees = attendeeList.toArray(new CalendarEventAttendee[0]);
CreateCalendarEventAttendeeResp createCalendarEventAttendeeResp = oApi.getClient().calendar().calendarEventAttendee().create(CreateCalendarEventAttendeeReq.newBuilder()
.calendarId(calendarId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private boolean requireLogin(String userId) {
}
return cache.get(userId) == null;
} catch (RuntimeException exception) {
log.error("failed to check user token cache.");
log.error("failed to check user token cache.", exception);
return false;
}
}
Expand Down
124 changes: 62 additions & 62 deletions src/test/java/fun/sast/evento/lark/EventServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,66 +29,66 @@ public class EventServiceTest {
@Autowired
SubscriptionService subscriptionService;

@Test
void createTestEvent(){
eventService.create(new EventCreate(
"this is a test event",
"test description",
LocalDateTime.now().plusDays(1),
LocalDateTime.now().plusDays(1).plusHours(2),
"test location",
"tag",
"omm_203fe8e78aa4a73f9de528b87d6c32d1",
"od-64e02d30d83fe3d587e91d25da1fab95"
));
}

@Test
void deleteTestEvent(){
eventService.delete(1846897410146017281L);
}

@Test
void queryEvent(){
eventService.query(new EventQuery(
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
true,
null
), 1, 1).elements().forEach(System.out::println);
}

@Test
void print(){
larkDepartmentService.list().forEach(System.out::println);
larkRoomService.list().forEach(System.out::println);
}

@Test
void subscribe() {
User user = new User();
user.setUserId("123");
user.setPermission(0);
JWTInterceptor.userHolder.set(user);
System.out.println(jwtService.generate(new JWTService.Payload<>(user)));

subscriptionService.subscribeEvent(1847132458277367809L, "123", true);
}

@Test
void admin() {
User user = new User();
user.setUserId("B23051508");
user.setPermission(2);
JWTInterceptor.userHolder.set(user);
System.out.println(jwtService.generate(new JWTService.Payload<>(user)));
}
// @Test
// void createTestEvent(){
// eventService.create(new EventCreate(
// "this is a test event",
// "test description",
// LocalDateTime.now().plusDays(1),
// LocalDateTime.now().plusDays(1).plusHours(2),
// "test location",
// "tag",
// "omm_203fe8e78aa4a73f9de528b87d6c32d1",
// "od-64e02d30d83fe3d587e91d25da1fab95"
// ));
// }
//
// @Test
// void deleteTestEvent(){
// eventService.delete(1846897410146017281L);
// }
//
// @Test
// void queryEvent(){
// eventService.query(new EventQuery(
// null,
// null,
// null,
// null,
// null,
// null,
// null,
// null,
// null,
// null,
// true,
// null
// ), 1, 1).elements().forEach(System.out::println);
// }
//
// @Test
// void print(){
// larkDepartmentService.list().forEach(System.out::println);
// larkRoomService.list().forEach(System.out::println);
// }
//
// @Test
// void subscribe() {
// User user = new User();
// user.setUserId("123");
// user.setPermission(0);
// JWTInterceptor.userHolder.set(user);
// System.out.println(jwtService.generate(new JWTService.Payload<>(user)));
//
// subscriptionService.subscribeEvent(1847132458277367809L, "123", true);
// }
//
// @Test
// void admin() {
// User user = new User();
// user.setUserId("B23051508");
// user.setPermission(2);
// JWTInterceptor.userHolder.set(user);
// System.out.println(jwtService.generate(new JWTService.Payload<>(user)));
// }
}
20 changes: 10 additions & 10 deletions src/test/java/fun/sast/evento/lark/OSSTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ public class OSSTests {
@Autowired
OSS oss;

@Test
public void OSSTest() {
MockMultipartFile file = new MockMultipartFile("file", "test.txt", "text/plain", "hello".getBytes());
String key = oss.upload(file);
log.info("upload success, key:{}", key);
String url = oss.url(key).toString();
log.info("gen url success, url:{}", url);
oss.delete(key);
log.info("delete success.");
}
// @Test
// public void OSSTest() {
// MockMultipartFile file = new MockMultipartFile("file", "test.txt", "text/plain", "hello".getBytes());
// String key = oss.upload(file);
// log.info("upload success, key:{}", key);
// String url = oss.url(key).toString();
// log.info("gen url success, url:{}", url);
// oss.delete(key);
// log.info("delete success.");
// }

@Test
void remove(){
Expand Down

0 comments on commit 56781fe

Please sign in to comment.