Browse Source

白名单接口

brealinxx 5 months ago
parent
commit
05fbc1136c

+ 156 - 0
src/main/java/com/xjrsoft/module/base/controller/WhitelistManagementController.java

@@ -0,0 +1,156 @@
+package com.xjrsoft.module.base.controller;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xjrsoft.common.constant.GlobalConstant;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.common.model.result.RT;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.base.dto.AddWhitelistManagementDto;
+import com.xjrsoft.module.base.dto.UpdateWhitelistManagementDto;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.alibaba.excel.EasyExcel;
+import com.xjrsoft.module.base.entity.TreeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+
+import com.xjrsoft.module.base.dto.WhitelistManagementPageDto;
+import com.xjrsoft.module.base.entity.WhitelistManagement;
+import com.xjrsoft.module.base.service.IWhitelistManagementService;
+import com.xjrsoft.module.base.vo.WhitelistManagementPageVo;
+
+import com.xjrsoft.module.base.vo.WhitelistManagementVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/base" + "/whitelistManagement")
+@Api(value = "/base"  + "/whitelistManagement",tags = "白名单管理代码")
+@AllArgsConstructor
+public class WhitelistManagementController {
+
+
+    private static final Logger log = LoggerFactory.getLogger(WhitelistManagementController.class);
+    private final IWhitelistManagementService whitelistManagementService;
+
+    @GetMapping(value = "/page")
+    @ApiOperation(value="白名单管理列表(分页)")
+    @SaCheckPermission("whitelistmanagement:detail")
+    public RT<PageOutput<WhitelistManagementPageVo>> page(@Valid WhitelistManagementPageDto dto){
+        Page<WhitelistManagementPageVo> page = whitelistManagementService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<WhitelistManagementPageVo> pageOutput = ConventPage.getPageOutput(page, WhitelistManagementPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+    @GetMapping(value = "/info")
+    @ApiOperation(value="根据id查询白名单管理信息")
+    @SaCheckPermission("whitelistmanagement:detail")
+    public RT<WhitelistManagementVo> info(@RequestParam Long id){
+        WhitelistManagement whitelistManagement = whitelistManagementService.getById(id);
+        if (whitelistManagement == null) {
+           return RT.error("找不到此数据!");
+        }
+        return RT.ok(BeanUtil.toBean(whitelistManagement, WhitelistManagementVo.class));
+    }
+
+
+    @PostMapping
+    @ApiOperation(value = "新增白名单管理")
+    @SaCheckPermission("whitelistmanagement:add")
+    public RT<Boolean> add(@Valid @RequestBody AddWhitelistManagementDto dto){
+        WhitelistManagement whitelistManagement = BeanUtil.toBean(dto, WhitelistManagement.class);
+        boolean isSuccess = whitelistManagementService.save(whitelistManagement);
+    return RT.ok(isSuccess);
+    }
+
+    @PutMapping
+    @ApiOperation(value = "修改白名单管理")
+    @SaCheckPermission("whitelistmanagement:edit")
+    public RT<Boolean> update(@Valid @RequestBody UpdateWhitelistManagementDto dto){
+
+        WhitelistManagement whitelistManagement = BeanUtil.toBean(dto, WhitelistManagement.class);
+        return RT.ok(whitelistManagementService.updateById(whitelistManagement));
+
+    }
+
+    @DeleteMapping
+    @ApiOperation(value = "删除白名单管理")
+    @SaCheckPermission("whitelistmanagement:delete")
+    public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
+        return RT.ok(whitelistManagementService.removeBatchByIds(ids));
+
+    }
+
+    @GetMapping("/structure")
+    @ApiOperation(value = "获取年级班级树结构")
+    public ResponseEntity<List<TreeNode>> getTreeStructure() {
+        List<TreeNode> treeStructure = whitelistManagementService.getTreeStructure();
+        return ResponseEntity.ok(treeStructure);
+    }
+
+    @PostMapping("/import")
+    @ApiOperation(value = "导入")
+    public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
+        List<WhitelistManagementPageVo> savedDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(WhitelistManagementPageVo.class).sheet().doReadSync();
+        List<WhitelistManagement> whitelistManagements = new ArrayList<>();
+        List<String> errorLogs = new ArrayList<>();
+
+        for (WhitelistManagementPageVo vo : savedDataList) {
+            try {
+                if (whitelistManagementService.checkExist(vo.getCredentialNumber())) continue;
+
+                String name = whitelistManagementService.GetName(vo.getName()).toString();
+                String credentialNumber = whitelistManagementService.GetCredentialNumber(vo.getCredentialNumber()).toString();
+                Long userId = whitelistManagementService.getUserId(credentialNumber);
+                Long phone = whitelistManagementService.GetPhone(Long.parseLong(vo.getPhone().toString()));
+
+                if (!name.isEmpty() && !credentialNumber.isEmpty() && !phone.toString().isEmpty()) {
+                    WhitelistManagement whitelistManagement = new WhitelistManagement();
+                    whitelistManagement.setCreateDate(new Date());
+                    whitelistManagement.setDeleteMark(0);
+                    whitelistManagement.setEnabledMark(0);
+                    whitelistManagement.setUserId(userId);
+                    whitelistManagement.setName(name);
+                    whitelistManagement.setCredentialNumber(credentialNumber);
+                    whitelistManagement.setPhone(phone);
+                    whitelistManagements.add(whitelistManagement);
+                }
+            } catch (Exception e) {
+                errorLogs.add(String.format("[意外错误(检查输入的是否正确且存在,输入错误可能返回 null)] 姓名: %s, 身份证: %s, 手机号: %s - 错误信息:%s", vo.getName(), vo.getCredentialNumber(), vo.getPhone(), e.getMessage()));
+            }
+        }
+
+        Boolean result = whitelistManagementService.saveBatch(whitelistManagements);
+        if (!errorLogs.isEmpty()) {
+            String detailedMessage = String.format("[导入完成但存在问题(检查输入的是否正确且存在,输入错误可能返回 null)] ", String.join("; ", errorLogs));
+            return RT.error(400, detailedMessage);
+        }
+
+        return RT.ok(result);
+    }
+
+}

+ 48 - 0
src/main/java/com/xjrsoft/module/base/dto/AddWhitelistManagementDto.java

@@ -0,0 +1,48 @@
+package com.xjrsoft.module.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Date;
+
+
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+public class AddWhitelistManagementDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 用户id
+    */
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+    * 姓名
+    */
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 身份证
+    */
+    @ApiModelProperty("身份证")
+    private String credentialNumber;
+    /**
+    * 手机号
+    */
+    @ApiModelProperty("手机号")
+    private Long phone;
+
+}

+ 32 - 0
src/main/java/com/xjrsoft/module/base/dto/UpdateWhitelistManagementDto.java

@@ -0,0 +1,32 @@
+package com.xjrsoft.module.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.List;
+import java.util.Date;
+
+
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+public class UpdateWhitelistManagementDto extends AddWhitelistManagementDto {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    private Long id;
+}

+ 40 - 0
src/main/java/com/xjrsoft/module/base/dto/WhitelistManagementPageDto.java

@@ -0,0 +1,40 @@
+package com.xjrsoft.module.base.dto;
+
+import com.tencentcloudapi.cam.v20190116.models.StrategyInfo;
+import com.xjrsoft.common.page.PageInput;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+* @title: 白名单管理分页查询入参
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class WhitelistManagementPageDto extends PageInput {
+
+    @ApiModelProperty("学号")
+    private String credentialNumber;
+
+    @ApiModelProperty("姓名")
+    private String name;
+
+    @ApiModelProperty("手机号码")
+    private Long phone;
+
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+    @ApiModelProperty("就读方式")
+    private String readWay;
+}

+ 12 - 0
src/main/java/com/xjrsoft/module/base/entity/TreeNode.java

@@ -0,0 +1,12 @@
+package com.xjrsoft.module.base.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TreeNode {
+    private String id;
+    private String name;
+    private List<TreeNode> children;
+}

+ 22 - 0
src/main/java/com/xjrsoft/module/base/entity/WhiteBaseClass.java

@@ -0,0 +1,22 @@
+package com.xjrsoft.module.base.entity;
+
+public class WhiteBaseClass {
+    private String id;
+    private String name;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 22 - 0
src/main/java/com/xjrsoft/module/base/entity/WhiteBaseGrade.java

@@ -0,0 +1,22 @@
+package com.xjrsoft.module.base.entity;
+
+public class WhiteBaseGrade {
+    private String id;
+    private String name;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 86 - 0
src/main/java/com/xjrsoft/module/base/entity/WhitelistManagement.java

@@ -0,0 +1,86 @@
+package com.xjrsoft.module.base.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.github.yulichang.annotation.EntityMapping;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Date;
+
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+@TableName("whitelist_management")
+@ApiModel(value = "whitelist_management", description = "白名单管理")
+public class WhitelistManagement implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    @TableId
+    private Long id;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createDate;
+    /**
+    * 修改时间
+    */
+    @ApiModelProperty("修改时间")
+    @TableField(fill = FieldFill.UPDATE)
+    private Date modifyDate;
+    /**
+    * 删除标记
+    */
+    @ApiModelProperty("删除标记")
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer deleteMark;
+    /**
+    * 有效标志
+    */
+    @ApiModelProperty("有效标志")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer enabledMark;
+    /**
+    * 用户id
+    */
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+    * 姓名
+    */
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 身份证
+    */
+    @ApiModelProperty("身份证")
+    private String credentialNumber;
+    /**
+    * 手机号
+    */
+    @ApiModelProperty("手机号")
+    private Long phone;
+
+
+}

+ 45 - 0
src/main/java/com/xjrsoft/module/base/mapper/WhitelistManagementMapper.java

@@ -0,0 +1,45 @@
+package com.xjrsoft.module.base.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.base.dto.WhitelistManagementPageDto;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.WhiteBaseClass;
+import com.xjrsoft.module.base.entity.WhiteBaseGrade;
+import com.xjrsoft.module.base.entity.WhitelistManagement;
+import com.xjrsoft.module.base.service.impl.WhitelistManagementServiceImpl;
+import com.xjrsoft.module.base.vo.WhitelistManagementPageVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Mapper
+public interface WhitelistManagementMapper extends MPJBaseMapper<WhitelistManagement> {
+
+    Page<WhitelistManagementPageVo> getPage(Page<Object> objectPage, WhitelistManagementPageDto dto);
+
+    String getName(String name);
+
+    String getCredentialNumber(String credentialNumber);
+
+    Long getPhone(long phone);
+
+    Long getUserId(String credentialNumber);
+
+    boolean checkExits(String credentialNumber);
+
+    @Select("SELECT id, name FROM base_grade")
+    List<WhiteBaseGrade> getAllGrades();
+
+    @Select("SELECT id, name FROM base_class WHERE grade_id = #{gradeId}")
+    List<WhiteBaseClass> getClassesByGradeId(@Param("gradeId") String gradeId);
+}
+

+ 35 - 0
src/main/java/com/xjrsoft/module/base/service/IWhitelistManagementService.java

@@ -0,0 +1,35 @@
+package com.xjrsoft.module.base.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.base.dto.WhitelistManagementPageDto;
+import com.xjrsoft.module.base.entity.TreeNode;
+import com.xjrsoft.module.base.entity.WhitelistManagement;
+import com.xjrsoft.module.base.vo.WhitelistManagementPageVo;
+import lombok.Data;
+import java.util.List;
+import java.util.Objects;
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+
+public interface IWhitelistManagementService extends MPJBaseService<WhitelistManagement> {
+    Page<WhitelistManagementPageVo> getPage(Page<Object> objectPage, WhitelistManagementPageDto dto);
+
+    String GetName(String name);
+
+    String GetCredentialNumber(String credentialNumber);
+
+    Long GetPhone(long l);
+
+    Long getUserId(String credentialNumber);
+
+    boolean checkExist(String credentialNumber);
+
+    List<TreeNode> getTreeStructure();
+}

+ 87 - 0
src/main/java/com/xjrsoft/module/base/service/impl/WhitelistManagementServiceImpl.java

@@ -0,0 +1,87 @@
+package com.xjrsoft.module.base.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.module.base.dto.WhitelistManagementPageDto;
+import com.xjrsoft.module.base.entity.TreeNode;
+import com.xjrsoft.module.base.entity.WhiteBaseClass;
+import com.xjrsoft.module.base.entity.WhiteBaseGrade;
+import com.xjrsoft.module.base.entity.WhitelistManagement;
+import com.xjrsoft.module.base.mapper.WhitelistManagementMapper;
+import com.xjrsoft.module.base.service.IWhitelistManagementService;
+import com.xjrsoft.module.base.vo.WhitelistManagementPageVo;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+* @title: 白名单管理
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Service
+@AllArgsConstructor
+public class WhitelistManagementServiceImpl extends MPJBaseServiceImpl<WhitelistManagementMapper, WhitelistManagement> implements IWhitelistManagementService {
+    private final WhitelistManagementMapper whitelistManagementMapper;
+
+    @Override
+    public Page<WhitelistManagementPageVo> getPage(Page<Object> objectPage, WhitelistManagementPageDto dto) {
+        return whitelistManagementMapper.getPage(objectPage, dto);
+    }
+
+    @Override
+    public String GetName(String name) {
+        return whitelistManagementMapper.getName(name);
+    }
+
+    @Override
+    public String GetCredentialNumber(String credentialNumber) {
+        return whitelistManagementMapper.getCredentialNumber(credentialNumber);
+    }
+
+    @Override
+    public Long GetPhone(long phone) {
+        return whitelistManagementMapper.getPhone(phone);
+    }
+
+    @Override
+    public Long getUserId(String credentialNumber) {
+        return whitelistManagementMapper.getUserId(credentialNumber);
+    }
+
+    @Override
+    public boolean checkExist(String credentialNumber) {
+        return whitelistManagementMapper.checkExits(credentialNumber);
+    }
+
+    @Override
+    public List<TreeNode> getTreeStructure() {
+        List<WhiteBaseGrade> grades = whitelistManagementMapper.getAllGrades();
+        List<TreeNode> treeNodes = new ArrayList<>();
+
+        for (WhiteBaseGrade grade : grades) {
+            TreeNode gradeNode = new TreeNode();
+            gradeNode.setId(grade.getId());
+            gradeNode.setName(grade.getName());
+
+            List<WhiteBaseClass> classes = whitelistManagementMapper.getClassesByGradeId(grade.getId());
+            List<TreeNode> classNodes = new ArrayList<>();
+
+            for (WhiteBaseClass clazz : classes) {
+                TreeNode classNode = new TreeNode();
+                classNode.setId(clazz.getId());
+                classNode.setName(clazz.getName());
+                classNodes.add(classNode);
+            }
+
+            gradeNode.setChildren(classNodes);
+            treeNodes.add(gradeNode);
+        }
+
+        return treeNodes;
+    }
+}

+ 98 - 0
src/main/java/com/xjrsoft/module/base/vo/WhitelistManagementPageVo.java

@@ -0,0 +1,98 @@
+package com.xjrsoft.module.base.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import com.xjrsoft.common.annotation.Trans;
+import com.xjrsoft.common.enums.TransType;
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+* @title: 白名单管理分页列表出参
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+public class WhitelistManagementPageVo {
+
+    /**
+    * 主键编号
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("主键编号")
+    private String id;
+    /**
+    * 创建时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+    /**
+    * 修改时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("修改时间")
+    private Date modifyDate;
+    /**
+    * 删除标记
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("删除标记")
+    private Integer deleteMark;
+    /**
+    * 有效标志
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("有效标志")
+    private Integer enabledMark;
+    /**
+    * 用户id
+    */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+    * 姓名
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("姓名")
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 身份证
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("身份证")
+    @ApiModelProperty("身份证")
+    private String credentialNumber;
+    /**
+    * 手机号
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("手机号")
+    @ApiModelProperty("手机号")
+    private Long phone;
+
+    @ApiModelProperty("性别")
+    private String gender;
+
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ApiModelProperty("就读方式")
+    private String readWay;
+
+    @ApiModelProperty("班主任")
+    private String teacher;
+}

+ 49 - 0
src/main/java/com/xjrsoft/module/base/vo/WhitelistManagementVo.java

@@ -0,0 +1,49 @@
+package com.xjrsoft.module.base.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Date;
+
+/**
+* @title: 白名单管理表单出参
+* @Author brealinxx
+* @Date: 2024-06-24
+* @Version 1.0
+*/
+@Data
+public class WhitelistManagementVo {
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    private Long id;
+    /**
+    * 用户id
+    */
+    @ApiModelProperty("用户id")
+    private Long userId;
+    /**
+    * 姓名
+    */
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 身份证
+    */
+    @ApiModelProperty("身份证")
+    private String credentialNumber;
+    /**
+    * 手机号
+    */
+    @ApiModelProperty("手机号")
+    private Long phone;
+
+
+
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -599,7 +599,7 @@ public class OutInRecordUtil {
                     LocalDateTime recordTimeDate = LocalDateTime.parse(recordTimeStr, formatter);
                     String attendanceStatus = discernStudentStatus(recordTimeDate, status, Long.valueOf(idNum));
                     studentInsertRecord(Long.valueOf(idNum), faceImportMapper.GetTeacherIdByPersonId(Long.valueOf(idNum)),
-                            faceImportMapper.GetClassIdByPersonId(Long.valueOf(idNum)), ApiUtil.GetRedirectURL(extEventPictureURL), recordTimeStr, status,eventId, attendanceStatus);
+                            faceImportMapper.GetClassIdByPersonId(Long.valueOf(idNum)), ApiUtil.GetRedirectURL(extEventPictureURL), recordTimeStr, status, eventId, attendanceStatus);
                 }
             }
         } catch (Exception e) {

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环境 dev|pre|prod
   profiles:
-    active: pre
+    active: dev
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 82 - 0
src/main/resources/mapper/base/WhitelistManagement.xml

@@ -0,0 +1,82 @@
+<?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.xjrsoft.module.base.mapper.WhitelistManagementMapper">
+    <select id="getPage" parameterType="com.xjrsoft.module.base.dto.WhitelistManagementPageDto" resultType="com.xjrsoft.module.base.vo.WhitelistManagementPageVo">
+        SELECT t.id, t.credential_number as credentialNumber, t.name, t.phone,
+            CASE
+               WHEN t1.gender = 'SB1001' THEN '男'
+               WHEN t1.gender = 'SB1002' THEN '女'
+               ELSE '其他'
+            END AS gender, t3.name as className, t4.name as readWay, t5.name as teacher, t3.id as classId
+        from whitelist_management t
+        left JOIN xjr_user t1 ON t1.id = t.user_id
+        left join base_student_school_roll t2 on t2.user_id = t.user_id
+        left join base_class t3 on t3.id = t2.class_id
+        left join xjr_dictionary_detail t4 on t4.code = t2.stduy_status
+        left join xjr_user t5 ON t5.id = t3.teacher_id
+        WHERE t.delete_mark = 0
+        <if test="dto.credentialNumber != null">
+            AND t.credential_number = #{dto.credentialNumber}
+        </if>
+        <if test="dto.name != null">
+            AND t.name = #{dto.name}
+        </if>
+        <if test="dto.phone != null">
+            AND t.phone = #{dto.phone}
+        </if>
+        <if test="dto.readWay != null">
+            AND t4.code = #{dto.readWay}
+        </if>
+        <if test="dto.classId != null">
+            AND t3.id = #{dto.classId}
+        </if>
+    </select>
+
+    <select id="getName" resultType="java.lang.String">
+        select name
+        from xjr_user
+        where delete_mark = 0
+        <if test="name != null">
+            AND name = #{name}
+        </if>
+    </select>
+
+    <select id="getCredentialNumber" resultType="java.lang.String">
+        select credential_number
+        from xjr_user
+        where delete_mark = 0
+        <if test="credentialNumber != null">
+            AND credential_number = #{credentialNumber}
+        </if>
+    </select>
+
+    <select id="getPhone" resultType="java.lang.Long">
+        select mobile
+        from xjr_user
+        where delete_mark = 0
+        <if test="phone != null">
+            AND mobile = #{phone}
+        </if>
+    </select>
+
+    <select id="getUserId" resultType="java.lang.Long">
+        select id
+        from xjr_user
+        where delete_mark = 0
+        <if test="credentialNumber != null">
+            AND credential_number = #{credentialNumber}
+        </if>
+    </select>
+
+    <select id="checkExits" resultType="java.lang.Boolean">
+        select case when count(1) > 0 then true else false end
+        from whitelist_management
+        where delete_mark = 0
+        <if test="credentialNumber != null">
+            AND credential_number = #{credentialNumber}
+        </if>
+    </select>
+
+</mapper>

+ 1 - 1
src/main/resources/mapper/teacher/TeacherFaceImportMapper.xml

@@ -46,10 +46,10 @@
         select t.hikvision_id
         from hikvision_data t
         left join car_message_apply t1 on t1.user_id = t.source_id
+        where t1.status = 1
         <if test="id != null">
             and t1.id = #{id}
         </if>
-        and t1.status = 1
     </select>
 
     <select id="IsStudentTypeByPersonId" parameterType="long" resultType="java.lang.String">

+ 25 - 0
src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

@@ -3312,4 +3312,29 @@ public class FreeMarkerGeneratorTest {
 
         apiGeneratorService.generateCodes(params);
     }
+
+    @Test
+    public void gcWhiteListManagement() throws IOException {
+        List<TableConfig> tableConfigs = new ArrayList<>();
+        TableConfig mainTable = new TableConfig();
+        mainTable.setTableName("whitelist_management");//init_sql中的表名
+        mainTable.setIsMain(true);//是否是主表,一般默认为true
+        mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
+        mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
+        tableConfigs.add(mainTable);
+
+        ApiGenerateCodesDto params = new ApiGenerateCodesDto();
+        params.setAuthor("brealinxx");//作者名称
+        params.setPackageName("base");//包名
+        params.setTableConfigs(tableConfigs);
+        params.setPage(true);//是否生成分页接口
+        params.setImport(true);//是否生成导入接口
+        params.setExport(false);//是否生成导出接口
+        params.setOutMainDir(true);//是否生成在主目录,前期测试可设置成false
+        params.setDs(ds);
+
+        IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
+
+        apiGeneratorService.generateCodes(params);
+    }
 }