软件工程项目实训 贰
软件工程项目实训(2021-3-21~2021-4)
继续完成相关数据库与程序底层交接的程序设计工作。
一、本阶段工作进展
1.确定流程
- 事务状态state
1
2
3
4public static final Integer STATE_READY = 10; //准备好可以审批
public static final Integer STATE_APPROVING = 11; //审批中
public static final Integer STATE_APPROVE_FAILED = 12; //审批失败
public static final Integer STATE_END = 13; //审批结束 - 事务类型kind
1
2public static final Integer KIND_REIMBURSEMENT_AUDIT = 20; //报销审计
public static final Integer KIND_FOLLOW_UP_AUDIT = 21; //跟踪审计 - 提示信息
1
2OK("00200","成功"),
USER_INPUT_ERROR("00400", "用户输入错误");
2. 整理对象属性
1 | public class User { |
1 | public class MaterialLog { |
1 | public class ApprovalLog { |
1 | public class Affair { |
3. 构建修正MySQL数据库相关表单
- user表
MaterialLog 表
外键ApprovalLog 表
外键Affair 表
外键二、实现相关连接
后端底层 DAO 层通过 mapper 与 MySQL 数据库进行连接。通过 MyBatis 简介明了地实现连接的相关函数。
以下为原始实现,后来修改了,已失效
AffairChangeMapper 实现返回值为 AffairChange 对象,插入新的AffairChange1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<mapper namespace="com.shenji.audit.dao.AffairChangeMapper" >
<resultMap id="BaseResultMap" type="com.shenji.audit.model.AffairChange" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="kind" property="kind" jdbcType="INTEGER" />
<result column="date" property="date" jdbcType="DATE" />
<result column="author_id" property="authorId" jdbcType="BIGINT" />
<result column="affair_id" property="affairId" jdbcType="BIGINT" />
<result column="message" property="message" jdbcType="VARCHAR" />
</resultMap>
<insert id="insertOne">
insert into affair_change values (
#{id},
#{kind},
#{date},
#{authorId},
#{affairId},
#{message}
)
</insert>
</mapper>
AffairMapper 实现返回值为 Affair 对象,从数据库按照id查找Affair,插入新的Affair,更新Affair1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<mapper namespace="com.shenji.audit.dao.AffairMapper" >
<resultMap id="BaseResultMap" type="com.shenji.audit.model.Affair" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="kind" property="kind" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" />
<result column="start_time" property="startTime" jdbcType="DATE" />
<result column="end_time" property="endTime" jdbcType="DATE" />
<result column="approver_id" property="approverId" jdbcType="BIGINT" />
<result column="promoter_id" property="promoterId" jdbcType="BIGINT" />
</resultMap>
<select id="getAffairById" resultMap="BaseResultMap">
SELECT *
FROM affair
WHERE id=#{affairId}
</select>
<insert id="insertOne">
insert into affair values (
#{id},
#{name},
#{remark},
#{kind},
#{state},
#{startTime},
#{endTime},
#{approverId},
#{promoterId}
)
</insert>
<update id="updateState" parameterType="com.shenji.audit.model.Affair">
update affair
<set>
<if test="state != null">
state = #{state},
</if>
</set>
where id = #{affairId}
</update>
</mapper>
MaterialMapper 实现返回值为 Material 对象,插入新的Material1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<mapper namespace="com.shenji.audit.dao.MaterialMapper" >
<resultMap id="BaseResultMap" type="com.shenji.audit.model.Material" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="affair_id" property="affairId" jdbcType="BIGINT" />
<result column="affair_change_id" property="affairChangeId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="DATE" />
<result column="author_id" property="authorId" jdbcType="BIGINT" />
<result column="content_url" property="contentUrl" jdbcType="VARCHAR" />
</resultMap>
<insert id="insertOne">
insert into material values (
#{id},
#{name},
#{affairId},
#{affairChangeId},
#{createTime},
#{authorId},
#{contentUrl}
)
</insert>
</mapper>
ReportMapper 实现返回值为 Report 对象,根据id查找Report,插入新的Report1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<mapper namespace="com.shenji.audit.dao.ReportMapper" >
<resultMap id="BaseResultMap" type="com.shenji.audit.model.Report" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="content_url" property="contentUrl" jdbcType="VARCHAR" />
<result column="affair_id" property="affairId" jdbcType="BIGINT" />
<result column="state" property="state" jdbcType="INTEGER" />
</resultMap>
<select id="selectOne" resultMap="BaseResultMap">
SELECT *
FROM report
WHERE id=#{reportId}
</select>
<insert id="insertOne">
insert into report values (
#{id},
#{name},
#{contentUrl},
#{affairId},
#{state}
)
</insert>
</mapper>
UserMapper 实现返回值为 User 对象,查询所有User1
2
3
4
5
6
7
8
9
10
11
12
13
<mapper namespace="com.shenji.audit.dao.UserMapper" >
<resultMap id="BaseResultMap" type="com.shenji.audit.model.User" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
</resultMap>
<select id="selectAll" resultMap="BaseResultMap">
SELECT * FROM user;
</select>
</mapper>
三、进行相关接口测试
陈神完成相关服务器后端接口,韬测试相关接口1
http://baixx.site:18080/swagger-ui/#/
接口版本1.0,现已失效
事务接口
获取全部事务 1
创建跟踪审计 1
获取我发起的事务 1
暂时没有id输入,输出了与1相关的项目
获取待我审批的事务
暂时没有id输入,输出了需要1审批的项目
创建报销审计 1
暂时没有approveid和promoterid输入,promoterid固定为2???
关于审批的职位12345,需要谁审批?
创建成功
审批接口
审批事务
出错Internal Server Error,status500
TestApprove-test02-nopass
TestApprove-test02-pass
获取pdf文件
测试
想要生成这个
但是乱码了,我下载(成功)看了看损坏了(文件损坏打不开),猜测是中文编码格式乱码了
上传报告
传空报错
获取源文件列表 1
获取成功
测试空的新项目成功
获取源文件
测试获取审计处新一代物联化信息管理系统建设方案.docx还是乱码了
下载(成功)看了,只有名字乱码了,内容没事,猜测是中文编码格式乱码了
测试不存在的文件,不存在的id
资料接口
获取资料列表
获取空成功
获取相关资料成功
上传资料
暂时必须手动填id,后期自动生成
不需要传入上传人id
填错误id,出错
删除资料文件
未测试
获取资料文件
成功获取相关资料,下载查看没问题
尝试获取不存在的文件
404 not found
获取资料文件列表 1
成功获取相关资料
成功获取不存在的id的空
三、下一阶段工作目标
发现用户安全问题,需要token工具类,进行token代码开发和拦截器过滤器开发









































