Browse Source

用户历史记录

qianxb 1 year ago
parent
commit
72f2b05714

+ 58 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/UserHistory.java

@@ -0,0 +1,58 @@
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/10/26 9:57
+ **/
+@Data
+@TableName("m_user_history")
+@ApiModel(value = "协议附件信息表", description = "协议附件信息表")
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserHistory implements Serializable {
+
+    private static final long serialVersionUID = 345634634L;
+
+    @ApiModelProperty("主键id")
+    @TableId(
+            value = "id",
+            type = IdType.ASSIGN_ID
+    )
+    private Long id;
+
+    /**
+     * 最后编辑所在合同段
+     */
+    @ApiModelProperty(value = "最后编辑所在合同段")
+    private Long userId;
+
+    /**
+     * 最后编辑所在合同段
+     */
+    @ApiModelProperty(value = "最后编辑所在合同段")
+    private Long projectId;
+
+    /**
+     * 最后编辑所在合同段
+     */
+    @ApiModelProperty(value = "最后编辑所在合同段")
+    private Long contractId;
+
+    /**
+     * 最后编辑所在合同段
+     */
+    @ApiModelProperty(value = "最后编辑所在根节点")
+    private String endNode;
+}

+ 58 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/UserHistoryController.java

@@ -0,0 +1,58 @@
+package org.springblade.manager.controller;
+
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.api.R;
+import org.springblade.manager.entity.UserHistory;
+import org.springblade.manager.service.IUserHistoryService;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/userHistory")
+@Api(value = "用户填报历史接口", tags = "用户填报历史接口")
+public class UserHistoryController {
+
+    private final IUserHistoryService historyService;
+
+    /**
+     * 查询当前用户填报历史
+     */
+    @GetMapping("/getUserHistory")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "查询当前用户在当前合同段填报历史", notes = "传入项目和合同段")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "contractId", value = "合同段id", required = true)
+    })
+    public R<UserHistory> getUserHistory(Long projectId,Long contractId) {
+        UserHistory userHistory = historyService.getUserHistory(projectId, contractId);
+        return R.data(userHistory);
+    }
+
+    /**
+     * 保存用户填报历史
+     */
+    @PostMapping("/saveUserHistory")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "保存用户填报历史", notes = "传入项目和合同段和节点标识")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "contractId", value = "合同段id", required = true),
+            @ApiImplicitParam(name = "endNode", value = "最后编辑所在根节点", required = true)
+    })
+    public R<UserHistory> saveUserHistory(@RequestBody UserHistory userHistory) {
+        historyService.saveUserHistory(userHistory);
+        return R.success("保存成功");
+    }
+
+
+
+}

+ 32 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/UserHistoryMapper.java

@@ -0,0 +1,32 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.manager.entity.UserHistory;
+
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface UserHistoryMapper extends BaseMapper<UserHistory> {
+
+
+}

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/UserHistoryMapper.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="org.springblade.manager.mapper.UserHistoryMapper">
+
+</mapper>

+ 38 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IUserHistoryService.java

@@ -0,0 +1,38 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.manager.entity.UserHistory;
+
+
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface IUserHistoryService extends IService<UserHistory> {
+
+
+    UserHistory getUserHistory(Long projectId, Long contractId);
+
+    void saveUserHistory(UserHistory userHistory);
+}

+ 61 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/UserHistoryServiceImpl.java

@@ -0,0 +1,61 @@
+package org.springblade.manager.service.impl;
+
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.manager.entity.UserHistory;
+import org.springblade.manager.mapper.UserHistoryMapper;
+import org.springblade.manager.service.IUserHistoryService;
+import org.springframework.stereotype.Service;
+
+
+@Service
+@AllArgsConstructor
+public class UserHistoryServiceImpl extends ServiceImpl<UserHistoryMapper, UserHistory> implements IUserHistoryService {
+
+
+
+    /**
+     * 查询当前用户填报历史
+     */
+    @Override
+    public UserHistory getUserHistory(Long projectId, Long contractId) {
+        //获取当前用户
+        Long userId = AuthUtil.getUserId();
+        UserHistory history = this.getOne(new LambdaQueryWrapper<UserHistory>()
+                .eq(UserHistory::getUserId, userId)
+                .eq(UserHistory::getProjectId, projectId)
+                .eq(UserHistory::getContractId, contractId));
+        if (history == null){
+            throw new ServiceException("未查询到当前合同段的填报历史,请先填写表单");
+        }
+        return history;
+    }
+
+    /**
+     * 保存用户填报历史
+     */
+    @Override
+    public void saveUserHistory(UserHistory userHistory) {
+        //先查看用户在当前合同段下是否有填报历史
+        //获取当前用户
+        Long userId = AuthUtil.getUserId();
+        UserHistory history = this.getOne(new LambdaQueryWrapper<UserHistory>()
+                .eq(UserHistory::getUserId, userId)
+                .eq(UserHistory::getProjectId, userHistory.getProjectId())
+                .eq(UserHistory::getContractId, userHistory.getContractId()));
+        if (history == null){
+            //没有则新增
+            userHistory.setUserId(userId);
+            this.save(userHistory);
+        }else {
+            //如果有就更新
+            history.setEndNode(userHistory.getEndNode());
+            this.updateById(history);
+        }
+    }
+}