10 changed files with 65 additions and 16 deletions
-
4src/main/java/com/example/demo/Mysql/MysqlServiceImpl.java
-
37src/main/java/com/example/demo/Util/StringToListTypeHandler.java
-
4src/main/java/com/example/demo/controller/WorkbenchController.java
-
3src/main/java/com/example/demo/domain/entity/Admin.java
-
4src/main/java/com/example/demo/domain/vo/Permission.java
-
1src/main/java/com/example/demo/service/PermissionService.java
-
9src/main/java/com/example/demo/serviceImpl/PermissionServiceImpl.java
-
6src/main/resources/application-dev.yml
-
1src/main/resources/application.yml
-
12src/main/resources/mapper/PermissionMapper.xml
@ -0,0 +1,37 @@ |
|||||
|
package com.example.demo.Util; |
||||
|
|
||||
|
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; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class StringToListTypeHandler extends BaseTypeHandler<List<String>> { |
||||
|
|
||||
|
@Override |
||||
|
public void setNonNullParameter(PreparedStatement ps, int i, List<String> parameter, JdbcType jdbcType) throws SQLException { |
||||
|
ps.setString(i, String.join(",", parameter)); // 将 List 转换为逗号分隔的字符串 |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<String> getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
|
String value = rs.getString(columnName); |
||||
|
return value == null ? null : Arrays.asList(value.split(",")); // 将字符串转换为 List |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<String> getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
|
String value = rs.getString(columnIndex); |
||||
|
return value == null ? null : Arrays.asList(value.split(",")); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<String> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
|
String value = cs.getString(columnIndex); |
||||
|
return value == null ? null : Arrays.asList(value.split(",")); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue