|
@@ -1,5 +1,6 @@
|
|
package edu.travel.service;
|
|
package edu.travel.service;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -13,9 +14,11 @@ import org.springframework.context.ApplicationContext;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 扩展mbp ServiceImpl
|
|
* 扩展mbp ServiceImpl
|
|
@@ -35,7 +38,7 @@ public class SysServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,T>
|
|
* @param queryWrapper
|
|
* @param queryWrapper
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public T getOneLink(QueryWrapper<T> queryWrapper) {
|
|
|
|
|
|
+ public T getOneLink(Wrapper<T> queryWrapper) {
|
|
T one = super.getOne(queryWrapper);
|
|
T one = super.getOne(queryWrapper);
|
|
if (one == null) {
|
|
if (one == null) {
|
|
return null;
|
|
return null;
|
|
@@ -49,7 +52,7 @@ public class SysServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,T>
|
|
* @param queryWrapper
|
|
* @param queryWrapper
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public List<T> getListLink(QueryWrapper<T> queryWrapper) {
|
|
|
|
|
|
+ public List<T> getListLink(Wrapper<T> queryWrapper) {
|
|
List<T> list = super.list(queryWrapper);
|
|
List<T> list = super.list(queryWrapper);
|
|
if (list == null || list.isEmpty()) {
|
|
if (list == null || list.isEmpty()) {
|
|
return list;
|
|
return list;
|
|
@@ -64,7 +67,7 @@ public class SysServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,T>
|
|
* @param page
|
|
* @param page
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public IPage<T> getPageLink(QueryWrapper<T> queryWrapper,IPage<T> page) {
|
|
|
|
|
|
+ public IPage<T> getPageLink(Wrapper<T> queryWrapper,IPage<T> page) {
|
|
IPage<T> iPage = super.page(page, queryWrapper);
|
|
IPage<T> iPage = super.page(page, queryWrapper);
|
|
if (iPage == null ) {
|
|
if (iPage == null ) {
|
|
return new Page();
|
|
return new Page();
|
|
@@ -110,17 +113,23 @@ public class SysServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,T>
|
|
LinkConst linkConst = field.getAnnotation(LinkConst.class);
|
|
LinkConst linkConst = field.getAnnotation(LinkConst.class);
|
|
if (linkConst != null) {
|
|
if (linkConst != null) {
|
|
Class clazz = linkConst.clazz();
|
|
Class clazz = linkConst.clazz();
|
|
|
|
+ System.out.println(Arrays.toString(clazz.getDeclaredFields()));
|
|
Object object = clazz.newInstance();
|
|
Object object = clazz.newInstance();
|
|
- Method getValueMethod = clazz.getMethod("getValue");
|
|
|
|
|
|
+ Method getValueMethod = clazz.getDeclaredMethod("getValue", Integer.class);
|
|
if (getValueMethod == null) {
|
|
if (getValueMethod == null) {
|
|
throw new RuntimeException("没有获取到getValue方法");
|
|
throw new RuntimeException("没有获取到getValue方法");
|
|
}
|
|
}
|
|
- Object getValue = getValueMethod.invoke(object, Integer.valueOf(field.get(one).toString()));
|
|
|
|
|
|
+ getValueMethod.setAccessible(true);
|
|
|
|
+ Field declaredField = one.getClass().getDeclaredField(linkConst.fieldName());
|
|
|
|
+ declaredField.setAccessible(true);
|
|
|
|
+ Object getValue = getValueMethod.invoke(object, Integer.valueOf(declaredField.get(one).toString()));
|
|
if (getValue == null) {
|
|
if (getValue == null) {
|
|
throw new RuntimeException("常量字典没有这个类");
|
|
throw new RuntimeException("常量字典没有这个类");
|
|
}
|
|
}
|
|
- HashMap<String, String> objectObjectHashMap = new HashMap<>();
|
|
|
|
- objectObjectHashMap.put(field.get(one).toString(), getValue.toString());
|
|
|
|
|
|
+ ConcurrentHashMap objectObjectHashMap = new ConcurrentHashMap();
|
|
|
|
+ objectObjectHashMap.put("key",Integer.valueOf(declaredField.get(one).toString()));
|
|
|
|
+ objectObjectHashMap.put("value", getValue);
|
|
|
|
+ System.out.println(objectObjectHashMap);
|
|
field.set(one, objectObjectHashMap);
|
|
field.set(one, objectObjectHashMap);
|
|
}
|
|
}
|
|
}catch (Exception e) {
|
|
}catch (Exception e) {
|