项目实训第四周第二次
作者:互联网
项目实训第四周第二次记录
1.任务安排
完成了基本的要求,对于申诉管理和报修管理,在测试的过程中,发现了异常情况,导致向用户重复发送了多条消息并且使得用户的违约次数成为了负数。
2.任务分析
通过分析以及和前端同学进行沟通发现,由于前端同学没有设置操作成功后的提示信息,导致前端管理员对于同一个申诉请求多次进行了同意操作。在一开始的设计过程中,我认为同意申诉请求这一操作一旦完成之后,就会在前端展示的待审核的申诉请求列表中消失,从而无法再次进行申诉请求操作。因此,当前端传递给后端appeal_id时,默认该条申诉记录是待审核。但是这样不合理的,即使前端对于操作成功有相应的措施。比如可以通过Postman发送post请求之后,此时的appeal_id可以是任意的,并不能确定这条申诉请求是待审核的还是已经审核过了的。因此,我们需要在一开始根据传递给后端的appeal_id判断当前申诉请求的状态是否是待审核的。如何该申诉请求不是待审核的,那么将返回给前端0,而对于申诉请求是待审核的,那么将根据操作的数量返回对应的值。对于申诉请求的拒绝操作,保修操作的同意,拒绝和维修座位操作也是类似的。
3.具体代码
3.1 AppealService
@Transactional
public int agree_appeal(String appeal_id)
{
String appeal_result=appealMapper.find_appeal_result_by_appeal_id(Integer.valueOf(appeal_id));
int result = 0;
if(appeal_result.equals("2"))
{
result += appealMapper.update_appeal_result_and_remark(Integer.valueOf(appeal_id),
"1", "");
Date date = new Date();
String user_openid = appealMapper.find_user_openid_by_appeal_id(Integer.valueOf(appeal_id));
int user_pick_seat_id = appealMapper.find_user_pick_seat_id_by_appeal_id(Integer.valueOf(appeal_id));
result += appealMapper.update_sign_in_and_sign_out_by_user_pick_seat_id(user_pick_seat_id,
"1", "1", "0");
int defaults = appealMapper.find_defaults_by_user_openid(user_openid);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String message_content = "您于" +
df.format(appealMapper.find_appeal_time_by_appeal_id(Integer.valueOf(appeal_id))) +
"提交的名为" + appealMapper.find_act_name_by_appeal_id(Integer.valueOf(appeal_id)) + "活动的申诉已经通过";
result += appealMapper.add_message_record(user_openid, "申诉成功", message_content, "0", date);
result += appealMapper.update_defaults_by_user_openid(user_openid);
//违约次数原本为3,现在减1变成2。处于临界状态。
if (defaults == 3) {
String act_id = appealMapper.find_act_id_by_user_openid(user_openid);
if (act_id.isEmpty()) {
//说明用户因为违约导致禁止参与所有活动,现在违约解除,移出黑名单
result += appealMapper.delete_blacklist_record(user_openid);
result += appealMapper.add_message_record(user_openid, "黑名单解除",
"您已经从黑名单中移除,请保持良好的选座习惯", "0", date);
} else {
result += appealMapper.update_isall_by_user_openid(user_openid, "0");
}
}
}
return result;
}
public int disagree_appeal(String appeal_id,String appeal_remark)
{
String appeal_result=appealMapper.find_appeal_result_by_appeal_id(Integer.valueOf(appeal_id));
int result=0;
if(appeal_result.equals("2"))
{
result += appealMapper.update_appeal_result_and_remark(Integer.valueOf(appeal_id),
"0", appeal_remark);
String user_openid = appealMapper.find_user_openid_by_appeal_id(Integer.valueOf(appeal_id));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String message_content = "您于" +
df.format(appealMapper.find_appeal_time_by_appeal_id(Integer.valueOf(appeal_id))) +
"提交的名为" + appealMapper.find_act_name_by_appeal_id(Integer.valueOf(appeal_id)) + "活动的申诉没有通过";
result += appealMapper.add_message_record(user_openid, "申诉失败", message_content, "0", date);
}
return result;
}
3.2 RepairService
@Transactional
public int agree_repair(String repair_id)
{
String repaired=repairMapper.find_repaired_by_repair_id(Integer.valueOf(repair_id));
int result=0;
if(repaired.equals("2"))
{
//将维修请求从待审核变成未修复
result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "0");
//将座位状态从可能损坏变为已损坏
result += repairMapper.update_seat_status_by_repair_id(Integer.valueOf(repair_id), "4");
String user_openid = repairMapper.find_user_openid_by_repair_id(Integer.valueOf(repair_id));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(repairMapper.find_time_by_repair_id(Integer.valueOf(repair_id)));
int seat_id = repairMapper.find_seat_id_by_repair_id(Integer.valueOf(repair_id));
String room_name = repairMapper.find_room_name_by_seat_id(seat_id);
int seat_no = repairMapper.find_seat_no_by_seat_id(seat_id);
String message_title = "报修审核通知";
String message_content = "您于" + time + "提交的教室名称为" + room_name + "中座位编号为"
+ seat_no + "的座位报修请求已经通过。请耐心等待座位维修完成";
Date date = new Date();
result += repairMapper.add_message_record(user_openid, message_title, message_content, "0", date);
}
return result;
}
@Transactional
public int disagree_repair(String repair_id)
{
String repaired=repairMapper.find_repaired_by_repair_id(Integer.valueOf(repair_id));
int result=0;
if(repaired.equals("2"))
{
//将维修请求从待审核变成已修复
result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "1");
//将座位状态从可能损坏变为可正常使用
result += repairMapper.update_seat_status_by_repair_id(Integer.valueOf(repair_id), "1");
//将用户的报修状态变为0,表示用户不可报修
result += repairMapper.update_repair_status_by_repair_id(Integer.valueOf(repair_id), "0");
String user_openid = repairMapper.find_user_openid_by_repair_id(Integer.valueOf(repair_id));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(repairMapper.find_time_by_repair_id(Integer.valueOf(repair_id)));
int seat_id = repairMapper.find_seat_id_by_repair_id(Integer.valueOf(repair_id));
String room_name = repairMapper.find_room_name_by_seat_id(seat_id);
int seat_no = repairMapper.find_seat_no_by_seat_id(seat_id);
String message_title = "报修审核通知";
String message_content = "您于" + time + "提交的教室名称为" + room_name + "中座位编号为"
+ seat_no + "的座位报修请求没有通过.由于您的违规操作,您将不可进行报修操作.";
Date date = new Date();
result += repairMapper.add_message_record(user_openid, message_title, message_content, "0", date);
}
return result;
}
@Transactional
public int repair_seat(String repair_id)
{
String repaired=repairMapper.find_repaired_by_repair_id(Integer.valueOf(repair_id));
int result=0;
if(repaired.equals("0"))
{
//将维修请求从未修复变成已修复
result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "1");
//将座位状态从已损坏变为可正常使用
result += repairMapper.update_seat_status_by_repair_id(Integer.valueOf(repair_id), "1");
String user_openid = repairMapper.find_user_openid_by_repair_id(Integer.valueOf(repair_id));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(repairMapper.find_time_by_repair_id(Integer.valueOf(repair_id)));
int seat_id = repairMapper.find_seat_id_by_repair_id(Integer.valueOf(repair_id));
String room_name = repairMapper.find_room_name_by_seat_id(seat_id);
int seat_no = repairMapper.find_seat_no_by_seat_id(seat_id);
String message_title = "座位维修通知";
String message_content = "您于" + time + "提交的教室名称为" + room_name + "中座位编号为"
+ seat_no + "的座位已经完成维修,您可以正常使用该座位.";
Date date = new Date();
result += repairMapper.add_message_record(user_openid, message_title, message_content, "0", date);
}
return result;
}
标签:repair,appeal,String,seat,实训,第二次,四周,id,result 来源: https://blog.csdn.net/YLHYWXHN/article/details/119006869