|
@@ -0,0 +1,165 @@
|
|
|
+
|
|
|
+ * Author: wangjian
|
|
|
+ * 生成controller
|
|
|
+ */
|
|
|
+package com.tofly.zmrq.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.tofly.common.core.entity.ResultRespone;
|
|
|
+import com.tofly.common.core.util.StringUtil;
|
|
|
+import com.tofly.common.log.annotation.ToFlyAppLog;
|
|
|
+import com.tofly.zmrq.entity.Userdevice;
|
|
|
+import com.tofly.zmrq.entity.UserdeviceUpdate;
|
|
|
+import com.tofly.zmrq.service.UserdeviceService;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+ * 用户设备信息表
|
|
|
+ *
|
|
|
+ * @author admin
|
|
|
+ * @date Mon May 24 00:00:00 CST 2021
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/userdevice")
|
|
|
+@Api(tags="用户设备信息表接口")
|
|
|
+public class UserdeviceController {
|
|
|
+
|
|
|
+ private final UserdeviceService userdeviceService;
|
|
|
+
|
|
|
+
|
|
|
+ * 分页查询
|
|
|
+ * @param page 分页对象
|
|
|
+ * @param userdevice 用户设备信息表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/page" )
|
|
|
+ @ApiOperation(value = "分页查询")
|
|
|
+ public ResultRespone getUserdevicePage(Page page, @ModelAttribute Userdevice userdevice) {
|
|
|
+ return ResultRespone.success(userdeviceService.page(page, Wrappers.<Userdevice>lambdaQuery()
|
|
|
+ .like(StringUtil.isNotEmpty(userdevice.getUserCode()),Userdevice::getUserCode,userdevice.getUserCode())
|
|
|
+ .or().like(StringUtil.isNotEmpty(userdevice.getUserCode()),Userdevice::getAddress,userdevice.getUserCode())
|
|
|
+ .or().like(StringUtil.isNotEmpty(userdevice.getUserCode()),Userdevice::getUserName,userdevice.getUserCode())
|
|
|
+ .or().like(StringUtil.isNotEmpty(userdevice.getUserCode()),Userdevice::getVoltageRegulatorCode,userdevice.getVoltageRegulatorCode())));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id查询用户设备信息表
|
|
|
+ * @param id id
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}" )
|
|
|
+ @ApiOperation(value = "通过ID查询")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
|
|
|
+ })
|
|
|
+ public ResultRespone getById(@PathVariable("id" ) Long id) {
|
|
|
+ return ResultRespone.success(userdeviceService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/listByCodes" )
|
|
|
+ @ApiOperation(value = "通过设备编码批量查询")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "codes", value = "codes字符串用逗号隔开", required = true, dataType = "String")
|
|
|
+ })
|
|
|
+ public ResultRespone<List<Userdevice>> getListByCodes(@RequestParam("codes")String codes){
|
|
|
+ List<String> list = Arrays.asList(codes.split(","));
|
|
|
+ return ResultRespone.success(userdeviceService.list(Wrappers.<Userdevice>lambdaQuery()
|
|
|
+ .in(Userdevice::getVoltageRegulatorCode,list)));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 新增用户设备信息表
|
|
|
+ * @param userdevice 用户设备信息表
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @ToFlyAppLog(title="新增用户设备信息表" )
|
|
|
+ @ApiOperation(value = "新增用户设备信息表")
|
|
|
+ @PostMapping
|
|
|
+ public ResultRespone save(@RequestBody Userdevice userdevice) {
|
|
|
+ return ResultRespone.success(userdeviceService.save(userdevice));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 修改用户设备信息表
|
|
|
+ * @param userdevice 用户设备信息表
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @ToFlyAppLog(title="修改用户设备信息表" )
|
|
|
+ @ApiOperation(value = "修改用户设备信息表")
|
|
|
+ @PutMapping
|
|
|
+ public ResultRespone updateById(@RequestBody Userdevice userdevice) {
|
|
|
+ return ResultRespone.success(userdeviceService.updateById(userdevice));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id删除用户设备信息表
|
|
|
+ * @param id id
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @ToFlyAppLog(title="通过id删除用户设备信息表" )
|
|
|
+ @ApiOperation(value = "通过ID删除用户设备信息表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
|
|
|
+ })
|
|
|
+ @DeleteMapping("/{id}" )
|
|
|
+ public ResultRespone removeById(@PathVariable Long id) {
|
|
|
+ return ResultRespone.success(userdeviceService.removeById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id批量删除用户设备信息表
|
|
|
+ * @param ids id
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @ToFlyAppLog(title="通过id批量删除用户设备信息表" )
|
|
|
+ @ApiOperation(value = "通过ID批量删除用户设备信息表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "ids", value = "批量删除,多个id以逗号隔开", required = true, dataType = "String")
|
|
|
+ })
|
|
|
+ @DeleteMapping("/deleteByIds" )
|
|
|
+ public ResultRespone removeById(String ids) {
|
|
|
+ return ResultRespone.success(userdeviceService.removeByIds(Arrays.asList(ids.split(","))));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ToFlyAppLog(title="通过Excel批量导入数据" )
|
|
|
+ @ApiOperation(value = "通过Excel批量导入数据")
|
|
|
+ @PostMapping(value = "/excel",headers = "content-type=multipart/form-data")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "isUpdate", value = "是否对比之前数据,0:不对比,直接新增 1:对比重复数据", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public ResultRespone uploadByExcel(String isUpdate,MultipartFile file){
|
|
|
+ return ResultRespone.success(userdeviceService.uploadByExcel(isUpdate,file));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id批量修改用户设备
|
|
|
+ * @param userdeviceUpdate
|
|
|
+ * @return ResultRespone
|
|
|
+ */
|
|
|
+ @ToFlyAppLog(title="通过id批量修改用户设备" )
|
|
|
+ @ApiOperation(value = "通过id批量修改用户设备")
|
|
|
+ @PutMapping("/updateByIds" )
|
|
|
+ public ResultRespone updateByIds(@RequestBody UserdeviceUpdate userdeviceUpdate) {
|
|
|
+ List<Long> ids = Arrays.stream(userdeviceUpdate.getIds().split(",")).map(s->Long.parseLong(s)).collect(Collectors.toList());
|
|
|
+ for (Long id : ids) {
|
|
|
+ userdeviceUpdate.setId(id);
|
|
|
+ userdeviceService.updateById(userdeviceUpdate);
|
|
|
+ }
|
|
|
+ return ResultRespone.success(true);
|
|
|
+ }
|
|
|
+}
|