Skip to content

Commit

Permalink
Merge pull request #108 from NJUPT-SAST/dev-felmose
Browse files Browse the repository at this point in the history
feat update sast-link-sdk
  • Loading branch information
feellmoose authored Jan 5, 2024
2 parents 521612f + 4bf7887 commit 874e17a
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 127 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Love98

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file removed lib/SastLink-Java-SDK-0.0.1.jar
Binary file not shown.
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>link.sast</groupId>
<artifactId>SastLink-Java-SDK</artifactId>
<type>jar</type>
<version>0.0.1</version>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/SastLink-Java-SDK-0.0.1.jar</systemPath>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -38,6 +31,13 @@
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>

<!-- sast-link-sdk -->
<dependency>
<groupId>fun.feellmoose</groupId>
<artifactId>sast-link-SDK</artifactId>
<version>0.1.2</version>
</dependency>

<!-- quartz -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package sast.evento.common.typehandler;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
* @author Aiden
* @date 2023/12/31 14:50
*/
public class FeedbackScoreTypeHandler extends BaseTypeHandler<Double> {
@Override
public void setNonNullParameter(PreparedStatement preparedStatement, int i, Double aDouble, JdbcType jdbcType) throws SQLException {
preparedStatement.setDouble(i, aDouble * 10);
}

@Override
public Double getNullableResult(ResultSet resultSet, String s) throws SQLException {
return resultSet.getDouble(s) / 10;
}

@Override
public Double getNullableResult(ResultSet resultSet, int i) throws SQLException {
return resultSet.getDouble(i) / 10;
}

@Override
public Double getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
return callableStatement.getDouble(i) / 10;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sast.evento.common.typehandler;

import fun.feellmoose.enums.Organization;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import sast.sastlink.sdk.enums.Organization;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/sast/evento/config/SastLinkServiceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sast.sastlink.sdk.service.SastLinkService;
import sast.sastlink.sdk.test.RestTemplateTestSastLinkService;
import fun.feellmoose.service.SastLinkService;
import fun.feellmoose.test.TestSastLinkServiceAdapter;

/**
* @projectName: sast-evento-backend
Expand Down Expand Up @@ -40,7 +40,7 @@ public class SastLinkServiceConfig {

@Bean
public SastLinkService sastLinkService() {
return RestTemplateTestSastLinkService.builder()
return new TestSastLinkServiceAdapter.Builder()
.setRedirectUri(redirectUri)
.setClientId(clientId)
.setClientSecret(clientSecret)
Expand All @@ -51,7 +51,7 @@ public SastLinkService sastLinkService() {

@Bean
public SastLinkService sastLinkServiceWeb() {
return RestTemplateTestSastLinkService.builder()
return new TestSastLinkServiceAdapter.Builder()
.setRedirectUri(redirectUri_web)
.setClientId(clientId_web)
.setClientSecret(clientSecret_web)
Expand All @@ -62,7 +62,7 @@ public SastLinkService sastLinkServiceWeb() {

@Bean
public SastLinkService sastLinkServiceMobileDev() {
return RestTemplateTestSastLinkService.builder()
return new TestSastLinkServiceAdapter.Builder()
.setRedirectUri(redirectUri_mobile_dev)
.setClientId(clientId_mobile_dev)
.setClientSecret(clientSecret_mobile_dev)
Expand Down
1 change: 0 additions & 1 deletion src/main/java/sast/evento/controller/EventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import sast.evento.common.enums.ErrorEnum;
import sast.evento.entitiy.Department;
import sast.evento.entitiy.Event;
import sast.evento.entitiy.User;
import sast.evento.exception.LocalRunTimeException;
import sast.evento.interceptor.HttpInterceptor;
import sast.evento.model.EventModel;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/sast/evento/controller/FeedbackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import sast.evento.annotation.EventId;
import sast.evento.annotation.OperateLog;
import sast.evento.common.enums.ActionState;
import sast.evento.entitiy.User;
import sast.evento.interceptor.HttpInterceptor;
import sast.evento.model.*;
import sast.evento.service.FeedBackService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/feedback")
Expand All @@ -26,7 +24,7 @@ public class FeedbackController {
* @author Aiden
*/
@OperateLog("获取某活动反馈详情")
@DefaultActionState(value = ActionState.ADMIN,group = "feedback")
@DefaultActionState(value = ActionState.ADMIN, group = "feedback")
@GetMapping("/event")
public FeedbacksDTO getFeedback(@RequestParam @EventId Integer eventId) {
return feedBackService.getFeedback(eventId);
Expand All @@ -39,7 +37,7 @@ public FeedbacksDTO getFeedback(@RequestParam @EventId Integer eventId) {
* @author Aiden
*/
@OperateLog("获取活动及其反馈数量列表")
@DefaultActionState(value = ActionState.ADMIN,group = "feedback")
@DefaultActionState(value = ActionState.ADMIN, group = "feedback")
@GetMapping("/num")
public PageModel<FeedbackNumModel> getFeedbackEvents(
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/sast/evento/controller/LoginController.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package sast.evento.controller;

import fun.feellmoose.exception.SastLinkException;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import sast.evento.annotation.DefaultActionState;
import sast.evento.annotation.OperateLog;
import sast.evento.common.enums.ActionState;
import sast.evento.common.enums.ErrorEnum;
import sast.evento.common.enums.Platform;
import sast.evento.entitiy.User;
import sast.evento.exception.LocalRunTimeException;
import sast.evento.interceptor.HttpInterceptor;
import sast.evento.model.UserModel;
import sast.evento.service.LoginService;
import sast.sastlink.sdk.exception.SastLinkException;


import java.util.Map;

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/sast/evento/controller/PermissionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@ public List<String> getSelfManagerPermission(@RequestParam @EventId Integer even
return permissionService.getUserManagerPermissAsList(eventId, user.getId());
}

@OperateLog("分页查询所有用户")
@DefaultActionState(ActionState.ADMIN)
@GetMapping(value = "/users")
public Map<String, Object> getUsers(@RequestParam(required = false,defaultValue = "1")Integer current,
@RequestParam(required = false,defaultValue = "10")Integer size) {
Page<User> userPage = permissionService.getUsers(current, size);
return Map.of("users", userPage.getRecords(), "total", userPage.getTotal());
}

@OperateLog("模糊查询用户")
@DefaultActionState(ActionState.ADMIN)
@GetMapping(value = "/users/search")
public Map<String, Object> searchUsers(@RequestParam String keyword,
@RequestParam(required = false,defaultValue = "1")Integer current,
@RequestParam(required = false,defaultValue = "10")Integer size){
Page<User> userPage = permissionService.searchUsers(keyword, current, size);
return Map.of("users", userPage.getRecords(), "total", userPage.getTotal());
}

private String checkUser(String userId, String studentId) {
if (userId != null && !userId.isEmpty()) {
return userId;
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/sast/evento/controller/TestController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package sast.evento.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import fun.feellmoose.test.TestSastLinkServiceAdapter;
import fun.feellmoose.test.data.Token;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -22,8 +24,7 @@
import sast.evento.model.Action;
import sast.evento.model.UserModel;
import sast.evento.service.PermissionService;
import sast.sastlink.sdk.test.RestTemplateTestSastLinkService;
import sast.sastlink.sdk.test.data.Token;


import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -38,11 +39,11 @@ public class TestController {
private String method;

@Resource
private RestTemplateTestSastLinkService sastLinkService;
private TestSastLinkServiceAdapter sastLinkService;
@Resource
private RestTemplateTestSastLinkService sastLinkServiceWeb;
private TestSastLinkServiceAdapter sastLinkServiceWeb;
@Resource
private RestTemplateTestSastLinkService sastLinkServiceMobileDev;
private TestSastLinkServiceAdapter sastLinkServiceMobileDev;
@Resource
private PermissionService permissionService;
@Resource
Expand All @@ -57,7 +58,7 @@ public class TestController {
public String linkLogin(@RequestParam Integer type,
@RequestParam String email,
@RequestParam String password) {
RestTemplateTestSastLinkService service = switch (type) {
TestSastLinkServiceAdapter service = switch (type) {
case 0 -> sastLinkService;
case 1 -> sastLinkServiceWeb;
case 2 -> sastLinkServiceMobileDev;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sast/evento/entitiy/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import fun.feellmoose.model.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import sast.evento.common.typehandler.OrganizationTypeHandler;
import sast.sastlink.sdk.model.UserInfo;

import java.util.List;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/sast/evento/mapper/FeedbackModelMapper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package sast.evento.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/sast/evento/model/FeedbackModel.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package sast.evento.model;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import sast.evento.common.typehandler.FeedbackScoreTypeHandler;

/**
* @projectName: sast-evento-backend
Expand All @@ -18,6 +20,7 @@ public class FeedbackModel {

private String content;

@TableField(typeHandler = FeedbackScoreTypeHandler.class)
private Double score;

private Integer eventId;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/sast/evento/model/FeedbacksDTO.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package sast.evento.model;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import sast.evento.common.typehandler.FeedbackScoreTypeHandler;

import java.util.List;

Expand All @@ -16,6 +18,7 @@
@AllArgsConstructor
public class FeedbacksDTO {
private Integer eventId;
@TableField(typeHandler = FeedbackScoreTypeHandler.class)
private Double average;
private Integer subscribeNum;
private Integer registrationNum;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/sast/evento/service/EventDepartmentService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package sast.evento.service;

import org.springframework.stereotype.Service;
import sast.evento.entitiy.Department;

import java.util.Collection;
import java.util.List;
import java.util.Map;

Expand All @@ -13,8 +11,12 @@
*/
public interface EventDepartmentService {
Boolean addEventDepartment(Integer eventId, Integer departmentId);

Boolean deleteEventDepartment(Integer id);

Boolean addEventDepartments(Integer eventId, List<Department> departmentIds);

Boolean deleteEventDepartmentsByEventId(Integer eventId);
Map<Integer,List<Department>> getEventDepartmentListMap(List<Integer> eventIds);

Map<Integer, List<Department>> getEventDepartmentListMap(List<Integer> eventIds);
}
1 change: 0 additions & 1 deletion src/main/java/sast/evento/service/FeedBackService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sast.evento.model.PageModel;

import java.util.List;
import java.util.Map;

/**
* @projectName: sast-evento-backend
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sast/evento/service/LoginService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sast.evento.service;

import jakarta.annotation.Nullable;
import sast.sastlink.sdk.exception.SastLinkException;

import fun.feellmoose.exception.SastLinkException;

import java.util.Map;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/sast/evento/service/PermissionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ public interface PermissionService {

Boolean checkPermission(String userId, Integer eventId, String methodName);

Page<User> getUsers( Integer current, Integer size);

Page<User> searchUsers(String keyword, Integer current, Integer size);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sast.evento.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import sast.evento.common.enums.ErrorEnum;
Expand Down Expand Up @@ -81,11 +80,11 @@ public Boolean deleteEventDepartmentsByEventId(Integer eventId) {
@Override
public Map<Integer, List<Department>> getEventDepartmentListMap(List<Integer> eventIds) {
List<EventDepartment> eventDepartments = eventDepartmentMapper.selectBatchDepartmentByEventIds(eventIds);
Map<Integer,List<Department>> res = new HashMap<>();
Map<Integer,Department> departmentMap = new HashMap<>();
for (EventDepartment eventDepartment: eventDepartments) {
Map<Integer, List<Department>> res = new HashMap<>();
Map<Integer, Department> departmentMap = new HashMap<>();
for (EventDepartment eventDepartment : eventDepartments) {
List<Department> departments = res.computeIfAbsent(eventDepartment.getEventId(), k -> new ArrayList<>());
Department department = departmentMap.computeIfAbsent(eventDepartment.getDepartmentId(),k -> new Department(k, eventDepartment.getDepartmentName()));
Department department = departmentMap.computeIfAbsent(eventDepartment.getDepartmentId(), k -> new Department(k, eventDepartment.getDepartmentName()));
departments.add(department);
}
return res;
Expand Down
Loading

0 comments on commit 874e17a

Please sign in to comment.