diff --git a/pom.xml b/pom.xml
index 1827db2..01ce105 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
4.12
2.9.0
1.2.13
- 3.5.5
+ 3.5.7
8.0.25
4.0
11.2.0.3
@@ -71,8 +71,22 @@
org.springframework.boot
spring-boot-starter-test
+
+
+ org.apache.logging.log4j
+ log4j-api
+
+
test
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.17.1
+
+
org.springframework.boot
spring-boot-starter-web
@@ -285,6 +299,17 @@
mybatis-plus-join-boot-starter
1.5.0
+
+
+ org.mapstruct
+ mapstruct
+ 1.6.0.Beta1
+
+
+
+
+
+
diff --git a/shapelight-admin/pom.xml b/shapelight-admin/pom.xml
index a21f5ba..13c22d1 100644
--- a/shapelight-admin/pom.xml
+++ b/shapelight-admin/pom.xml
@@ -155,6 +155,14 @@
0.7
+
+
+ com.guwan
+ easyexcel
+ 4.0.3
+
+
+
com.alibaba
easyexcel
@@ -251,10 +259,31 @@
true
-
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.34
+
+
+ org.mapstruct
+ mapstruct-processor
+ 1.6.0.Beta1
+
+
+
+
+
com.spotify
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java
index 76ab865..8860601 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import net.shapelight.common.handler.CustomizeTableNameHandler;
+import net.shapelight.common.handler.TimeHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,6 +20,14 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
+
+ @Bean
+ public TimeHandler metaObjectHandler() {
+ return new TimeHandler();
+ }
+
+
+
/**
* 分表插件
*/
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
index e025de2..b104f5e 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
@@ -128,9 +128,11 @@ public class ShiroConfig {
filterMap.put("/swagger-ui.html", "anon");
filterMap.put("/swagger-resources/**", "anon");
filterMap.put("/captcha.jpg", "anon");
+ filterMap.put("/mobile/device/group/export", "anon");
// filterMap.put("/aaa.txt", "anon");
filterMap.put("/**", "oauth2");
+
shiroFilter.setFilterChainDefinitionMap(filterMap);
return shiroFilter;
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/handler/TimeHandler.java b/shapelight-admin/src/main/java/net/shapelight/common/handler/TimeHandler.java
index 6149a11..182bd15 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/handler/TimeHandler.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/handler/TimeHandler.java
@@ -6,7 +6,7 @@ import org.apache.ibatis.reflection.MetaObject;
import java.util.Date;
public class TimeHandler implements MetaObjectHandler {
- @Override
+ /* @Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createTime", new Date(), metaObject);
this.setFieldValByName("updateTime", new Date(), metaObject);
@@ -15,5 +15,18 @@ public class TimeHandler implements MetaObjectHandler {
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateTime", new Date(), metaObject);
+ }*/
+
+ @Override
+ public void insertFill(MetaObject metaObject) {
+ this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
+ this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
+ this.strictInsertFill(metaObject, "deleteFlag", Integer.class, 0);
}
+
+ @Override
+ public void updateFill(MetaObject metaObject) {
+ this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
+ }
+
}
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/BeanUtils.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/BeanUtils.java
new file mode 100644
index 0000000..8187037
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/BeanUtils.java
@@ -0,0 +1,42 @@
+package net.shapelight.common.utils;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.db.PageResult;
+
+
+import java.util.List;
+import java.util.function.Consumer;
+
+
+public class BeanUtils {
+
+ public static T toBean(Object source, Class targetClass) {
+ return BeanUtil.toBean(source, targetClass);
+ }
+
+ public static T toBean(Object source, Class targetClass, Consumer peek) {
+ T target = toBean(source, targetClass);
+ if (target != null) {
+ peek.accept(target);
+ }
+ return target;
+ }
+
+ public static List toBean(List source, Class targetType) {
+ if (source == null) {
+ return null;
+ }
+ return CollectionUtils.convertList(source, s -> toBean(s, targetType));
+ }
+
+ public static List toBean(List source, Class targetType, Consumer peek) {
+ List list = toBean(source, targetType);
+ if (list != null) {
+ list.forEach(peek);
+ }
+ return list;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/CollectionUtils.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/CollectionUtils.java
new file mode 100644
index 0000000..5a1b863
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/CollectionUtils.java
@@ -0,0 +1,326 @@
+package net.shapelight.common.utils;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ArrayUtil;
+import com.google.common.collect.ImmutableMap;
+
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static java.util.Arrays.asList;
+
+
+public class CollectionUtils {
+
+ public static boolean containsAny(Object source, Object... targets) {
+ return asList(targets).contains(source);
+ }
+
+ public static boolean isAnyEmpty(Collection>... collections) {
+ return Arrays.stream(collections).anyMatch(CollectionUtil::isEmpty);
+ }
+
+ public static boolean anyMatch(Collection from, Predicate predicate) {
+ return from.stream().anyMatch(predicate);
+ }
+
+ public static List filterList(Collection from, Predicate predicate) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return from.stream().filter(predicate).collect(Collectors.toList());
+ }
+
+ public static List distinct(Collection from, Function keyMapper) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return distinct(from, keyMapper, (t1, t2) -> t1);
+ }
+
+ public static List distinct(Collection from, Function keyMapper, BinaryOperator cover) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return new ArrayList<>(convertMap(from, keyMapper, Function.identity(), cover).values());
+ }
+
+ public static List convertList(T[] from, Function func) {
+ if (ArrayUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return convertList(Arrays.asList(from), func);
+ }
+
+ public static List convertList(Collection from, Function func) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ public static List convertList(Collection from, Function func, Predicate filter) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ public static List convertListByFlatMap(Collection from,
+ Function> func) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ public static List convertListByFlatMap(Collection from,
+ Function super T, ? extends U> mapper,
+ Function> func) {
+ if (CollUtil.isEmpty(from)) {
+ return new ArrayList<>();
+ }
+ return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ public static List mergeValuesFromMap(Map> map) {
+ return map.values()
+ .stream()
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
+ }
+
+ public static Set convertSet(Collection from) {
+ return convertSet(from, v -> v);
+ }
+
+ public static Set convertSet(Collection from, Function func) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashSet<>();
+ }
+ return from.stream().map(func).filter(Objects::nonNull).collect(Collectors.toSet());
+ }
+
+ public static Set convertSet(Collection from, Function func, Predicate filter) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashSet<>();
+ }
+ return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toSet());
+ }
+
+ public static Map convertMapByFilter(Collection from, Predicate filter, Function keyFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return from.stream().filter(filter).collect(Collectors.toMap(keyFunc, v -> v));
+ }
+
+ public static Set convertSetByFlatMap(Collection from,
+ Function> func) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashSet<>();
+ }
+ return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
+ }
+
+ public static Set convertSetByFlatMap(Collection from,
+ Function super T, ? extends U> mapper,
+ Function> func) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashSet<>();
+ }
+ return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet());
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return convertMap(from, keyFunc, Function.identity());
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc, Supplier extends Map> supplier) {
+ if (CollUtil.isEmpty(from)) {
+ return supplier.get();
+ }
+ return convertMap(from, keyFunc, Function.identity(), supplier);
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1);
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return convertMap(from, keyFunc, valueFunc, mergeFunction, HashMap::new);
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, Supplier extends Map> supplier) {
+ if (CollUtil.isEmpty(from)) {
+ return supplier.get();
+ }
+ return convertMap(from, keyFunc, valueFunc, (v1, v2) -> v1, supplier);
+ }
+
+ public static Map convertMap(Collection from, Function keyFunc, Function valueFunc, BinaryOperator mergeFunction, Supplier extends Map> supplier) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return from.stream().collect(Collectors.toMap(keyFunc, valueFunc, mergeFunction, supplier));
+ }
+
+ public static Map> convertMultiMap(Collection from, Function keyFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(t -> t, Collectors.toList())));
+ }
+
+ public static Map> convertMultiMap(Collection from, Function keyFunc, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return from.stream()
+ .collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toList())));
+ }
+
+ // 暂时没想好名字,先以 2 结尾噶
+ public static Map> convertMultiMap2(Collection from, Function keyFunc, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return new HashMap<>();
+ }
+ return from.stream().collect(Collectors.groupingBy(keyFunc, Collectors.mapping(valueFunc, Collectors.toSet())));
+ }
+
+ public static Map convertImmutableMap(Collection from, Function keyFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return Collections.emptyMap();
+ }
+ ImmutableMap.Builder builder = ImmutableMap.builder();
+ from.forEach(item -> builder.put(keyFunc.apply(item), item));
+ return builder.build();
+ }
+
+ /**
+ * 对比老、新两个列表,找出新增、修改、删除的数据
+ *
+ * @param oldList 老列表
+ * @param newList 新列表
+ * @param sameFunc 对比函数,返回 true 表示相同,返回 false 表示不同
+ * 注意,same 是通过每个元素的“标识”,判断它们是不是同一个数据
+ * @return [新增列表、修改列表、删除列表]
+ */
+ public static List> diffList(Collection oldList, Collection newList,
+ BiFunction sameFunc) {
+ List createList = new LinkedList<>(newList); // 默认都认为是新增的,后续会进行移除
+ List updateList = new ArrayList<>();
+ List deleteList = new ArrayList<>();
+
+ // 通过以 oldList 为主遍历,找出 updateList 和 deleteList
+ for (T oldObj : oldList) {
+ // 1. 寻找是否有匹配的
+ T foundObj = null;
+ for (Iterator iterator = createList.iterator(); iterator.hasNext(); ) {
+ T newObj = iterator.next();
+ // 1.1 不匹配,则直接跳过
+ if (!sameFunc.apply(oldObj, newObj)) {
+ continue;
+ }
+ // 1.2 匹配,则移除,并结束寻找
+ iterator.remove();
+ foundObj = newObj;
+ break;
+ }
+ // 2. 匹配添加到 updateList;不匹配则添加到 deleteList 中
+ if (foundObj != null) {
+ updateList.add(foundObj);
+ } else {
+ deleteList.add(oldObj);
+ }
+ }
+ return asList(createList, updateList, deleteList);
+ }
+
+ public static boolean containsAny(Collection> source, Collection> candidates) {
+ return org.springframework.util.CollectionUtils.containsAny(source, candidates);
+ }
+
+ public static T getFirst(List from) {
+ return !CollectionUtil.isEmpty(from) ? from.get(0) : null;
+ }
+
+ public static T findFirst(Collection from, Predicate predicate) {
+ return findFirst(from, predicate, Function.identity());
+ }
+
+ public static U findFirst(Collection from, Predicate predicate, Function func) {
+ if (CollUtil.isEmpty(from)) {
+ return null;
+ }
+ return from.stream().filter(predicate).findFirst().map(func).orElse(null);
+ }
+
+ public static > V getMaxValue(Collection from, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return null;
+ }
+ assert !from.isEmpty(); // 断言,避免告警
+ T t = from.stream().max(Comparator.comparing(valueFunc)).get();
+ return valueFunc.apply(t);
+ }
+
+ public static > V getMinValue(List from, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return null;
+ }
+ assert from.size() > 0; // 断言,避免告警
+ T t = from.stream().min(Comparator.comparing(valueFunc)).get();
+ return valueFunc.apply(t);
+ }
+
+ public static > T getMinObject(List from, Function valueFunc) {
+ if (CollUtil.isEmpty(from)) {
+ return null;
+ }
+ assert from.size() > 0; // 断言,避免告警
+ return from.stream().min(Comparator.comparing(valueFunc)).get();
+ }
+
+ public static > V getSumValue(Collection from, Function valueFunc,
+ BinaryOperator accumulator) {
+ return getSumValue(from, valueFunc, accumulator, null);
+ }
+
+ public static > V getSumValue(Collection from, Function valueFunc,
+ BinaryOperator accumulator, V defaultValue) {
+ if (CollUtil.isEmpty(from)) {
+ return defaultValue;
+ }
+ assert !from.isEmpty(); // 断言,避免告警
+ return from.stream().map(valueFunc).filter(Objects::nonNull).reduce(accumulator).orElse(defaultValue);
+ }
+
+ public static void addIfNotNull(Collection coll, T item) {
+ if (item == null) {
+ return;
+ }
+ coll.add(item);
+ }
+
+ public static Collection singleton(T obj) {
+ return obj == null ? Collections.emptyList() : Collections.singleton(obj);
+ }
+
+ public static List newArrayList(List> list) {
+ return list.stream().flatMap(Collection::stream).collect(Collectors.toList());
+ }
+
+}
\ No newline at end of file
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/ExcelUtils.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/ExcelUtils.java
new file mode 100644
index 0000000..aaac020
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/ExcelUtils.java
@@ -0,0 +1,46 @@
+package net.shapelight.common.utils;
+
+import com.guwan.excel.EasyExcel;
+import com.guwan.excel.converters.longconverter.LongStringConverter;
+import com.guwan.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+public class ExcelUtils {
+
+ /**
+ * 将列表以 Excel 响应给前端
+ *
+ * @param response 响应
+ * @param filename 文件名
+ * @param sheetName Excel sheet 名
+ * @param head Excel head 头
+ * @param data 数据列表
+ * @param 泛型,保证 head 和 data 类型的一致性
+ * @throws IOException 写入失败的情况
+ */
+ public static void write(HttpServletResponse response, String filename, String sheetName,
+ Class head, List data) throws IOException {
+ // 输出 Excel
+ EasyExcel.write(response.getOutputStream(), head)
+ .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
+ .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度
+ .sheet(sheetName).doWrite(data);
+ // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8.name()));
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+ }
+
+ public static List read(MultipartFile file, Class head) throws IOException {
+ return EasyExcel.read(file.getInputStream(), head, null)
+ .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
+ .doReadAllSync();
+ }
+
+}
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppParentWxController.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppParentWxController.java
index 2054435..fd1a031 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppParentWxController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppParentWxController.java
@@ -1,3 +1,4 @@
+/*
package net.shapelight.modules.appparent.controller;
import com.alibaba.fastjson.JSONObject;
@@ -109,3 +110,4 @@ public class AppParentWxController {
}
}
+*/
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java
index 6e603e6..c78be72 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java
@@ -1,6 +1,8 @@
package net.shapelight.modules.fegin;
import com.alibaba.fastjson.JSONObject;
+
+
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java
index ed1b4ee..26a95d2 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceController.java
@@ -9,14 +9,14 @@ import net.shapelight.common.handler.CustomizeTableNameHandler;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.common.utils.R;
import net.shapelight.common.utils.SnowflakeIdWorker;
+import net.shapelight.modules.mobile.dto.mobileDevice.MobileDeviceAddDto;
+import net.shapelight.modules.mobile.dto.mobileDevice.MobileDeviceQueryDto;
import net.shapelight.modules.mobile.entity.MobileDevice;
import net.shapelight.modules.mobile.service.MobileDeviceService;
import net.shapelight.modules.sys.controller.AbstractController;
+import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@@ -30,34 +30,50 @@ public class DeviceController extends AbstractController {
MobileDeviceService mobileDeviceService;
- @PostMapping("list")
+ @GetMapping("list")
@ApiOperation("设备列表")
@ApiImplicitParams({
- @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true),
- @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true),
+ @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "Long",required = true),
+ @ApiImplicitParam(name="size",value = "每页页数",paramType = "query",dataType = "Long",required = true),
@ApiImplicitParam(name = "name", value = "设备名称", paramType = "query", dataType = "String"),
- @ApiImplicitParam(name = "status", value = "设备状态", paramType = "query", dataType = "Integer"),
- @ApiImplicitParam(name = "cellName", value = "学校名称", paramType = "query", dataType = "String"),
- @ApiImplicitParam(name = "deptId", value = "设备区域名称", paramType = "query", dataType = "String")
+ @ApiImplicitParam(name = "groupId", value = "设备组id", paramType = "query", dataType = "Long"),
+ @ApiImplicitParam(name = "apkVersion", value = "apk版本", paramType = "query", dataType = "String")
})
- public R list(@RequestBody Map params) {
+ public R list(@RequestParam(defaultValue = "1") Long page,
+ @RequestParam(defaultValue = "10") Long size,
+ @RequestParam(required = false) String name,
+ @RequestParam(required = false) Long groupId,
+ @RequestParam(required = false) String apkVersion) {
//params.put("tenantId",getUser().getTenantId());
- CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
+ /* CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
PageUtils page = mobileDeviceService.queryPage(params);
- CustomizeTableNameHandler.removeData();
- return R.ok().put("data",page);
+ CustomizeTableNameHandler.removeData();*/
+
+ System.out.println("page = " + page);
+ System.out.println("size = " + size);
+
+ MobileDeviceQueryDto mobileDeviceQueryDto = new MobileDeviceQueryDto();
+ mobileDeviceQueryDto.setCurrent(page);
+ mobileDeviceQueryDto.setSize(size);
+ mobileDeviceQueryDto.setName(name);
+ mobileDeviceQueryDto.setGroupId(groupId);
+ mobileDeviceQueryDto.setApkVersion(apkVersion);
+
+ return R.ok().put("data", mobileDeviceService.list(mobileDeviceQueryDto));
}
@PostMapping("add")
@ApiOperation("设备新增")
- public R add(@RequestBody MobileDevice mobileDevice) {
+ public R add(@RequestBody MobileDeviceAddDto mobileDeviceAddDto) {
//mobileDevice.setTenantId(getUser().getTenantId());
- Long id = new SnowflakeIdWorker().nextId();
- mobileDevice.setId(id);
- CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
- mobileDeviceService.save(mobileDevice);
- CustomizeTableNameHandler.removeData();
- return R.ok();
+ // Long id = new SnowflakeIdWorker().nextId();
+ // mobileDevice.setId(id);
+ /* CustomizeTableNameHandler.setData(String.valueOf(getUser().getTenantId()));
+ mobileDeviceService.save(mobileDeviceAddDto);
+ CustomizeTableNameHandler.removeData();*/
+ if (mobileDeviceService.save(mobileDeviceAddDto)) {
+ return R.ok();
+ } else return R.error();
}
@PostMapping("update")
@@ -66,9 +82,10 @@ public class DeviceController extends AbstractController {
return R.ok();
}
- @PostMapping("delete")
+ @DeleteMapping("delete")
@ApiOperation("删除设备")
public R delete(@RequestBody List deviceIdList) {
+ mobileDeviceService.remove(deviceIdList);
return R.ok();
}
}
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java
index 2a3db2f..d1adfee 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/controler/DeviceGroupController.java
@@ -5,17 +5,21 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
-import net.shapelight.common.base.BasePageDTO;
+import net.shapelight.common.utils.BeanUtils;
+//import net.shapelight.common.utils.ExcelUtils;
+import net.shapelight.common.utils.ExcelUtils;
import net.shapelight.common.utils.R;
-import net.shapelight.modules.mobile.dto.DeviceGruopQueryDto;
-import net.shapelight.modules.mobile.dto.MobileDeviceGroupAddDto;
-import net.shapelight.modules.mobile.entity.MobileDeviceGroup;
+import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGruopQueryDto;
+import net.shapelight.modules.mobile.dto.mobileDeviceGroup.MobileDeviceGroupAddDto;
import net.shapelight.modules.mobile.service.MobileDeviceGroupService;
-import org.apache.ibatis.annotations.Delete;
+import net.shapelight.modules.mobile.vo.mobileDeviceGroup.MobileDeviceGroupVo;
import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-import java.util.Map;
@RestController
@RequestMapping("mobile/device/group/")
@@ -27,41 +31,83 @@ public class DeviceGroupController {
@GetMapping("list")
@ApiOperation("话机设备组列表")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "Long",required = true),
+ @ApiImplicitParam(name="size",value = "每页条数",paramType = "query",dataType = "Long",required = true),
+ @ApiImplicitParam(name = "groupId", value = "设备组id", paramType = "query", dataType = "Long"),
+ @ApiImplicitParam(name = "status", value = "设备状态", paramType = "query", dataType = "Integer"),
+ })
public R list(@RequestParam(defaultValue = "1") Long page,
- @RequestParam(defaultValue = "1") Long size,
+ @RequestParam(defaultValue = "10") Long size,
@RequestParam(required = false) Long groupId,
@RequestParam(required = false) Integer status) {
- DeviceGruopQueryDto deviceGruopQueryDto = new DeviceGruopQueryDto();
- deviceGruopQueryDto.setCurrent(page);
- deviceGruopQueryDto.setSize(size);
- deviceGruopQueryDto.setGroupId(groupId);
- deviceGruopQueryDto.setStatus(status);
-
-
-
- return R.ok().put("data", mobileDeviceGroupService.list(deviceGruopQueryDto));
-
+ MobileDeviceGruopQueryDto mobileDeviceGruopQueryDto = new MobileDeviceGruopQueryDto();
+ mobileDeviceGruopQueryDto.setCurrent(page);
+ mobileDeviceGruopQueryDto.setSize(size);
+ mobileDeviceGruopQueryDto.setGroupId(groupId);
+ mobileDeviceGruopQueryDto.setStatus(status);
+ return R.ok().put("data", mobileDeviceGroupService.list(mobileDeviceGruopQueryDto));
}
@PostMapping("add")
@ApiOperation("设备组新增")
public R add(@RequestBody MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
- return R.ok();
+
+ if (mobileDeviceGroupService.add(mobileDeviceGroupAddDto)){
+ return R.ok();
+ }else return R.error();
+
}
@DeleteMapping("remove")
@ApiOperation("设备组删除")
@ApiImplicitParam(name = "groupId",value = "设备组ID",paramType = "query",dataType = "List",required = true)
public R remove(@RequestBody List groupId) {
+
+ mobileDeviceGroupService.remove(groupId);
return R.ok();
+
}
@PutMapping("update")
@ApiOperation("设备组更新")
- public R update(@RequestBody MobileDeviceGroup mobileDeviceGroup) {
+ public R update(@RequestBody MobileDeviceGroupAddDto mobileDeviceGroupAddDto) {
+ mobileDeviceGroupService.update(mobileDeviceGroupAddDto);
return R.ok();
}
+
+ @PostMapping("/export-excel")
+ public void exportDeviceGroupExcel(@RequestBody List exportId, HttpServletResponse response)
+ throws IOException {
+
+ List mobileDeviceGroupVos =
+ mobileDeviceGroupService.exportByIds(exportId);
+
+ // 导出 Excel
+ ExcelUtils.write(response, "设备组信息.xls", "数据",
+ MobileDeviceGroupVo.class, mobileDeviceGroupVos);
+
+ }
+
+
+ @GetMapping("/export")
+ public void exportDemo(HttpServletResponse response)
+ throws IOException {
+
+ List exportId = new ArrayList<>(Arrays.asList(1306928534018588678L));
+
+ List mobileDeviceGroupVos =
+ mobileDeviceGroupService.exportByIds(exportId);
+
+ // 导出 Excel
+ ExcelUtils.write(response, "设备组信息.xls", "数据",
+ MobileDeviceGroupVo.class, mobileDeviceGroupVos);
+
+ }
+
+
+
}
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/coverter/StatusConverter.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/coverter/StatusConverter.java
new file mode 100644
index 0000000..5d4f269
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/coverter/StatusConverter.java
@@ -0,0 +1,31 @@
+package net.shapelight.modules.mobile.coverter;
+
+
+import com.guwan.excel.converters.Converter;
+import com.guwan.excel.enums.CellDataTypeEnum;
+import com.guwan.excel.metadata.GlobalConfiguration;
+import com.guwan.excel.metadata.data.WriteCellData;
+import com.guwan.excel.metadata.property.ExcelContentProperty;
+
+public class StatusConverter implements Converter