|
|
@@ -2,6 +2,7 @@ package org.springblade.box.tube.annualBudget.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -10,6 +11,8 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springblade.box.tube.annualBudget.service.IAnnualBudgetService;
|
|
|
import org.springblade.box.tube.entity.AnnualBudget;
|
|
|
import org.springblade.box.tube.vo.AnnualBudgetVO;
|
|
|
+import org.springblade.client.entity.CorpsDesc;
|
|
|
+import org.springblade.client.feign.IRedisClient;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
@@ -17,9 +20,13 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 年度预算控制器
|
|
|
@@ -32,6 +39,9 @@ public class AnnualBudgetController extends BladeController {
|
|
|
|
|
|
private final IAnnualBudgetService annualBudgetService;
|
|
|
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
+ private final IRedisClient redisClient;//redis缓存处理
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@@ -58,6 +68,25 @@ public class AnnualBudgetController extends BladeController {
|
|
|
|
|
|
IPage<AnnualBudget> page = annualBudgetService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
|
|
|
+ redisClient.basicData("all");
|
|
|
+ List<User> userList = castToList(redisTemplate.opsForValue().get("user"), User.class);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(page.getRecords())) {
|
|
|
+ page.getRecords().forEach(item -> {
|
|
|
+ if (item.getCreateUser() != null){
|
|
|
+ User user = userList.stream().filter(e -> e.getId().equals(item.getCreateUser())).findFirst().orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(user)){
|
|
|
+ item.setCreateUserName(user.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.getUpdateUser() != null){
|
|
|
+ User user = userList.stream().filter(e -> e.getId().equals(item.getUpdateUser())).findFirst().orElse(null);
|
|
|
+ if (ObjectUtil.isNotEmpty(user)){
|
|
|
+ item.setUpdateUserName(user.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return R.data(page);
|
|
|
}
|
|
|
|
|
|
@@ -112,4 +141,25 @@ public class AnnualBudgetController extends BladeController {
|
|
|
return R.status(annualBudgetService.removeByIds(Func.toLongList(ids)));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将Object转换成List类型
|
|
|
+ *
|
|
|
+ * @param obj Object对象
|
|
|
+ * @param clazz 数据类型
|
|
|
+ * @param <T> 泛型类型
|
|
|
+ * @return List类型
|
|
|
+ */
|
|
|
+ public static <T> List<T> castToList(Object obj, Class<T> clazz) {
|
|
|
+ List<T> resList = new ArrayList<>();
|
|
|
+ // 如果不是List<?>对象,是没有办法转换的
|
|
|
+ if (obj instanceof List<?>) {
|
|
|
+ for (Object o : (List<?>) obj) {
|
|
|
+ // 将对应的元素进行类型转换
|
|
|
+ resList.add(clazz.cast(o));
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|