ソースを参照

web端vci设备模块

bmmx 1 年間 前
コミット
914045b333

+ 1 - 1
.idea/JavaSceneConfigState.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="SmartInputSourceJavaSceneConfigState">
-    <option name="customChineseScenes" value="{&quot;capsLockState&quot;:false,&quot;code&quot;:&quot;;ApiModelProperty(value);debug(s);Api(tags);BadReqException(message);info(s);BizException(message);ApiOperation()&quot;,&quot;enable&quot;:true,&quot;languageType&quot;:&quot;CHINESE&quot;,&quot;name&quot;:&quot;自定义中文切换&quot;,&quot;tip&quot;:&quot;&quot;}" />
+    <option name="customChineseScenes" value="{&quot;capsLockState&quot;:false,&quot;code&quot;:&quot;;ApiModelProperty(value);debug(s);Api(tags);info(s);BizException(message);ApiOperation();BadReqException(message)&quot;,&quot;enable&quot;:true,&quot;languageType&quot;:&quot;CHINESE&quot;,&quot;name&quot;:&quot;自定义中文切换&quot;,&quot;tip&quot;:&quot;&quot;}" />
   </component>
 </project>

+ 58 - 3
src/main/java/com/om/controller/admin/VciInfoController.java

@@ -1,9 +1,18 @@
 package com.om.controller.admin;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.om.entity.dto.VciQueryPageDTO;
+import com.om.entity.po.VciInfo;
+import com.om.entity.vo.UserVciVO;
+import com.om.entity.vo.VciQueryPageVO;
+import com.om.service.IVciInfoService;
+import com.om.utils.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * <p>
@@ -14,7 +23,53 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2024-02-27
  */
 @RestController
-@RequestMapping("/vci-info")
+@Api(tags = "vci设备信息模块")
+@RequestMapping("/web/vci-info")
 public class VciInfoController {
+    @Resource
+    private IVciInfoService vciInfoService;
+
+    @PostMapping("add")
+    @ApiOperation("新增vci设备")
+    public Result addVci(@RequestBody VciInfo vciInfo){
+        return vciInfoService.addVci(vciInfo);
+    }
+
+    @PostMapping("addList")
+    @ApiOperation("批量新增vci设备")
+    public Result addList(@RequestBody List<VciInfo> vciInfos){
+        return vciInfoService.addList(vciInfos);
+    }
+
+
+    @GetMapping("deleteByNum")
+    @ApiOperation("根据VciNum删除vci设备")
+    public Result deleteByNum(@RequestParam String vciNum){
+        return vciInfoService.deleteByNum(vciNum);
+    }
+
+    @GetMapping("updateState")
+    @ApiOperation("修改vci设备状态")
+    public Result updateState(@RequestParam("id") Integer id ,@RequestParam("state") Integer state){
+        return vciInfoService.updateState(id,state);
+    }
+
+    @GetMapping("getList")
+    @ApiOperation("获取vci设备列表")
+    public Result getList(){
+        return vciInfoService.getList();
+    }
+
+    @GetMapping("getListByUserId")
+    @ApiOperation("根据用户id获取vci设备列表")
+    public Result<List<UserVciVO>> getListByUserId(@RequestParam Integer userId){
+        return vciInfoService.getListByUserId(userId);
+    }
+
+    @PostMapping("getPageList")
+    @ApiOperation("分页获取vci设备列表")
+    public Result<VciQueryPageVO> getPageList(@RequestBody VciQueryPageDTO dto){
+        return vciInfoService.getPageList(dto);
+    }
 
 }

+ 19 - 0
src/main/java/com/om/entity/dto/VciQueryPageDTO.java

@@ -0,0 +1,19 @@
+package com.om.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class VciQueryPageDTO {
+    @ApiModelProperty(value = "当前页码")
+    private Integer pageIndex;
+
+    @ApiModelProperty(value = "每个页码的大小")
+    private Integer pageSize;
+
+    @ApiModelProperty(value = "搜索字段---搜索vci编号")
+    private String vciNum;
+
+}

+ 44 - 0
src/main/java/com/om/entity/po/UserVci.java

@@ -0,0 +1,44 @@
+package com.om.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author bmmx
+ * @since 2024-02-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("user_vci")
+@ApiModel(value="UserVci对象", description="")
+public class UserVci implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "ID")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "客户端用户ID")
+    private Integer userId;
+
+    @ApiModelProperty(value = "VCI设备ID")
+    private Integer vciInfoId;
+
+    @ApiModelProperty(value = "是否为默认VCI设备")
+    private Boolean isDefault;
+
+
+}

+ 18 - 0
src/main/java/com/om/entity/vo/UserVciVO.java

@@ -0,0 +1,18 @@
+package com.om.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class UserVciVO {
+    @ApiModelProperty(value = "客户端用户ID")
+    private Integer userId;
+
+    @ApiModelProperty(value = "客户端用户名")
+    private String username;
+
+    @ApiModelProperty(value = "是否为默认VCI设备")
+    private Boolean isDefault;
+}

+ 32 - 0
src/main/java/com/om/entity/vo/VciQueryPageVO.java

@@ -0,0 +1,32 @@
+package com.om.entity.vo;
+
+import com.om.entity.po.VciInfo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+public class VciQueryPageVO {
+
+    @ApiModelProperty(value = "当前页码")
+    private Integer current;
+
+    @ApiModelProperty(value = "总页码")
+    private Integer pages;
+
+    @ApiModelProperty(value = "每个页码的大小")
+    private Integer size;
+
+    @ApiModelProperty(value = "总数量")
+    private Integer total;
+
+    @ApiModelProperty(value = "是否是查询")
+    private Boolean searchCount = false;
+
+    @ApiModelProperty(value = "结果集")
+    private List<VciInfo> records;
+
+}

+ 16 - 0
src/main/java/com/om/mapper/UserVciMapper.java

@@ -0,0 +1,16 @@
+package com.om.mapper;
+
+import com.om.entity.po.UserVci;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author bmmx
+ * @since 2024-02-28
+ */
+public interface UserVciMapper extends BaseMapper<UserVci> {
+
+}

+ 16 - 0
src/main/java/com/om/service/IUserVciService.java

@@ -0,0 +1,16 @@
+package com.om.service;
+
+import com.om.entity.po.UserVci;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author bmmx
+ * @since 2024-02-28
+ */
+public interface IUserVciService extends IService<UserVci> {
+
+}

+ 19 - 0
src/main/java/com/om/service/IVciInfoService.java

@@ -1,7 +1,13 @@
 package com.om.service;
 
+import com.om.entity.dto.VciQueryPageDTO;
 import com.om.entity.po.VciInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.om.entity.vo.UserVciVO;
+import com.om.entity.vo.VciQueryPageVO;
+import com.om.utils.Result;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +19,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IVciInfoService extends IService<VciInfo> {
 
+    Result addVci(VciInfo vciInfo);
+
+    Result addList(List<VciInfo> vciInfos);
+
+    Result deleteByNum(String vciNum);
+
+    Result updateState(Integer id, Integer state);
+
+    Result getList();
+
+    Result<List<UserVciVO>> getListByUserId(Integer userId);
+
+    Result<VciQueryPageVO> getPageList(VciQueryPageDTO dto);
 }

+ 20 - 0
src/main/java/com/om/service/impl/UserVciServiceImpl.java

@@ -0,0 +1,20 @@
+package com.om.service.impl;
+
+import com.om.entity.po.UserVci;
+import com.om.mapper.UserVciMapper;
+import com.om.service.IUserVciService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author bmmx
+ * @since 2024-02-28
+ */
+@Service
+public class UserVciServiceImpl extends ServiceImpl<UserVciMapper, UserVci> implements IUserVciService {
+
+}

+ 143 - 0
src/main/java/com/om/service/impl/VciInfoServiceImpl.java

@@ -1,11 +1,32 @@
 package com.om.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.om.entity.dto.VciQueryPageDTO;
+import com.om.entity.po.DiagnosticLog;
+import com.om.entity.po.User;
+import com.om.entity.po.UserVci;
 import com.om.entity.po.VciInfo;
+import com.om.entity.vo.DiaLogQueryPageVO;
+import com.om.entity.vo.UserVciVO;
+import com.om.entity.vo.VciQueryPageVO;
+import com.om.exception.BadReqException;
+import com.om.mapper.UserMapper;
 import com.om.mapper.VciInfoMapper;
+import com.om.service.IUserService;
+import com.om.service.IUserVciService;
 import com.om.service.IVciInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.om.utils.Result;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +38,126 @@ import org.springframework.stereotype.Service;
 @Service
 public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> implements IVciInfoService {
 
+    @Resource
+    private UserMapper userMapper;
+
+    @Resource
+    private IUserVciService userVciService;
+
+    @Override
+    public Result addVci(VciInfo vciInfo) {
+        if (BeanUtil.isEmpty(vciInfo)){
+            throw new BadReqException("参数为空");
+        }
+        vciInfo.setCreateTime(LocalDateTime.now());
+        vciInfo.setUpdateTime(LocalDateTime.now());
+        this.save(vciInfo);
+        return Result.ok();
+    }
+
+    @Override
+    public Result addList(List<VciInfo> vciInfos) {
+        if (BeanUtil.isEmpty(vciInfos)){
+            throw new BadReqException("参数为空");
+        }
+
+        for (VciInfo vciInfo : vciInfos) {
+            vciInfo.setCreateTime(LocalDateTime.now());
+            vciInfo.setUpdateTime(LocalDateTime.now());
+        }
+
+        this.saveBatch(vciInfos);
+        return Result.ok();
+    }
+
+    @Override
+    public Result deleteByNum(String vciNum) {
+
+        //根据vciNum查询
+        VciInfo one = this.lambdaQuery()
+                .eq(VciInfo::getVciNum, vciNum)
+                .one();
+
+        if (BeanUtil.isEmpty(one)){
+            throw new BadReqException("vci设备不存在");
+        }
+
+        //删除
+        this.removeById(one);
+        return Result.ok();
+    }
+
+    @Override
+    public Result updateState(Integer id, Integer state) {
+        //根据id查询
+        VciInfo vciInfo = this.getById(id);
+
+        if (BeanUtil.isEmpty(vciInfo)){
+            throw new BadReqException("vci设备不存在");
+        }
+        vciInfo.setState(state);
+        this.updateById(vciInfo);
+        return Result.ok();
+    }
+
+    @Override
+    public Result getList() {
+        List<VciInfo> list = this.list();
+        return Result.ok(list);
+    }
+
+    @Override
+    public Result<List<UserVciVO>> getListByUserId(Integer userId) {
+        //根据userId查询用户
+        User user = userMapper.selectById(userId);
+        if (BeanUtil.isEmpty(user)){
+            throw new BadReqException("该用户不存在");
+        }
+
+        List<UserVci> list = userVciService.lambdaQuery()
+                .eq(UserVci::getUserId, userId)
+                .list();
+
+        if (CollectionUtil.isEmpty(list)){
+            return Result.ok(Collections.emptyList());
+        }
+        List<UserVciVO> vos= new ArrayList<>();
+        for (UserVci userVci : list) {
+            UserVciVO userVciVO = BeanUtil.copyProperties(userVci, UserVciVO.class);
+            userVciVO.setUsername(user.getUsername());
+            vos.add(userVciVO);
+        }
+
+
+        return Result.ok(vos);
+    }
+
+    @Override
+    public Result<VciQueryPageVO> getPageList(VciQueryPageDTO dto) {
+        Integer pageIndex = dto.getPageIndex();
+        Integer pageSize = dto.getPageSize();
+        String vciNum = dto.getVciNum();
+
+
+        Page<VciInfo> page = this.lambdaQuery()
+                .like(vciNum != null, VciInfo::getVciNum, vciNum)
+                .orderByDesc(VciInfo::getCreateTime)
+                .page(new Page<>(pageIndex, pageSize));
+
+        VciQueryPageVO vo = new VciQueryPageVO();
+        vo.setCurrent((int) page.getCurrent());
+        vo.setSize((int) page.getSize());
+        vo.setPages((int) page.getPages());
+        vo.setTotal((int) page.getTotal());
+
+        if (vciNum != null){
+            vo.setSearchCount(true);
+        }
+
+        List<VciInfo> records = page.getRecords();
+        vo.setRecords(records);
+        return Result.ok(vo);
+    }
+
+
 }

+ 5 - 0
src/main/resources/mapper/UserVciMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.om.mapper.UserVciMapper">
+
+</mapper>