项目实训第三周第三次
2021/7/17 23:19:42
本文主要是介绍项目实训第三周第三次,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
项目实训第三周第三次记录
- 1.任务安排
- 2.任务分析
- 2.1显示待审核的申诉请求
- 2.2同意申诉请求
- 2.3拒绝申诉请求
- 3.具体代码
- 3.1AppealMapper
- 3.2AppealService
- 3.3AppealController
1.任务安排
需要完成申诉管理,主要用于管理未签到用户的申诉请求。管理员可以同意用户的申诉请求并修正签到信息,或者拒绝用户的申诉请求并填写拒绝理由。
2.任务分析
2.1显示待审核的申诉请求
找出所有审核申诉的结果为审核中申诉请求。返回给前端所需要的信息,并以对象数组的形式提供给前端,包括申诉id,教学名称,教室名称, 座位号,申诉人用户名 ,申诉时间,申诉缘由。其中申诉id可以不显示在前端,主要用于前端进行同意或拒绝操作时向唯一确定是哪一条申诉请求。排序方式按照申诉时间排序,时间早的申诉会排在前面。
2.2同意申诉请求
如果管理员同意用户的申诉请求,需要将申诉的结果从审核中变成已通过,并发消息告知该用户申诉已经通过。然后将用户对应的活动签到记录修改成已签到,已签退,未违约。然后去获取用户的违约次数,如果用户的违约次数是3,说明用户此时在黑名单里面,申诉成功之后违约次数就会减一,所以此时处于一个临界状态。再去根据用户的user_openid去查看黑名单表,如果用户被禁止参加的活动id不为空,那么就将是否禁止参加全部活动从1变成0,如果用户被禁止参加的活动id为空,那么就直接该条记录删除。并发送消息告知该用户已经被移出黑名单。
2.3拒绝申诉请求
如果管理员同意用户的申诉请求,需要将申诉的结果从审核中变成未通过。并发送消息告知该用户申诉没有通过。
3.具体代码
3.1AppealMapper
@Mapper public interface AppealMapper { @Select("select appeal_id from appeal where appeal_result=\"2\" order by appeal_time") public int[] find_nodeal_appeal_id(); @Select("select appeal_desc from appeal where appeal_id=#{appeal_id}") public String find_appeal_desc_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select username from user where user_openid=(select user_openid from " + "user_pick_seat where user_pick_seat_id=(select user_pick_seat_id from " + "appeal where appeal_id=#{appeal_id}))") String find_username_by_appeal_id(@Param("appeal_id") int appeal_id); @Update("update appeal set appeal_result=#{appeal_result},appeal_remark={appeal_remark} " + "where appeal_id=#{appeal_id}") int update_appeal_result_and_remark(@Param("appeal_id") int appeal_id , @Param("appeal_result") String appeal_result, @Param("appeal_remark") String appeal_remark); @Select("select user_openid from user_pick_seat where user_pick_seat_id=" + "(select user_pick_seat_id from appeal where appeal_id=#{appeal_id})") String find_user_openid_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select defaults from user where user_openid=#{user_openid}") int find_defaults_by_user_openid(@Param("user_openid") String user_openid); @Update("update user set defaults=defaults-1 where user_openid=#{user_openid}") int update_defaults_by_user_openid(@Param("user_openid") String user_openid); @Select("select isall from blacklist where user_openid=#{user_openid}") String find_isall_by_user_openid(@Param("user_openid") String user_openid); @Select("select act_id from blacklist where user_openid=#{user_openid}") String find_act_id_by_user_openid(@Param("user_openid") String user_openid); @Delete("delete from blacklist where user_openid=#{user_openid}") int delete_blacklist_record(@Param("user_openid") String user_openid); @Update("update blacklist set isall=#{isall} where user_openid=#{user_openid}") int update_isall_by_user_openid(@Param("user_openid") String user_openid, @Param("isall") String isall); @Insert("insert into message(user_openid,message_title,message_content,hasRead,time) " + "values(#{user_openid},#{message_title},#{message_content},#{hasRead},#{time})") public int add_message_record(@Param("user_openid") String user_openid,@Param("message_title") String message_title, @Param("message_content") String message_content,@Param("hasRead") String hasRead, @Param("time") Date time); @Select("select appeal_time from appeal where appeal_id=#{appeal_id}") Date find_appeal_time_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select act_name from activity where act_id=(select act_id from act_room_seat " + "where act_room_seat_id=(select act_room_seat_id from user_pick_seat where user_pick_seat_id=" + "(select user_pick_seat_id from appeal where appeal_id=#{appeal_id})))") String find_act_name_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select room_name from act_room_seat where act_room_seat_id=(select act_room_seat_id " + "from user_pick_seat where user_pick_seat_id=" + "(select user_pick_seat_id from appeal where appeal_id=#{appeal_id}))") String find_room_name_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select seat_no from seat where seat_id=(select seat_id from act_room_seat where " + "act_room_seat_id=(select act_room_seat_id from user_pick_seat where user_pick_seat_id=" + "(select user_pick_seat_id from appeal where appeal_id=#{appeal_id})))") int find_seat_no_by_appeal_id(@Param("appeal_id") int appeal_id); @Select("select user_pick_seat_id from appeal where appeal_id=#{appeal_id}") int find_user_pick_seat_id_by_appeal_id(@Param("appeal_id") int appeal_id); @Update("update user_pick_seat set sign_in=#{sign_in},sign_out=#{sign_out}," + "defaults=#{defaults} where user_pick_seat_id=#{user_pick_seat_id}") int update_sign_in_and_sign_out_by_user_pick_seat_id(@Param("user_pick_seat_id") int user_pick_seat_id, @Param("sign_in") String sign_in, @Param("sign_out") String sign_out, @Param("defaults") String defaults); }
3.2AppealService
@Service public class AppealService { @Autowired AppealMapper appealMapper; public Appeal_Record[] find_nodeal_appeal() { int[] appeal_ids=appealMapper.find_nodeal_appeal_id(); Appeal_Record[] appeal_records=new Appeal_Record[appeal_ids.length]; for(int i=0;i<appeal_ids.length;i++) { int appeal_id=appeal_ids[i]; String act_name=appealMapper.find_act_name_by_appeal_id(appeal_id); String room_name=appealMapper.find_room_name_by_appeal_id(appeal_id); int seat_no=appealMapper.find_seat_no_by_appeal_id(appeal_id); String username=appealMapper.find_username_by_appeal_id(appeal_id); Date appeal_time=appealMapper.find_appeal_time_by_appeal_id(appeal_id); String appeal_desc=appealMapper.find_appeal_desc_by_appeal_id(appeal_id); appeal_records[i]=new Appeal_Record(appeal_id,act_name,room_name,seat_no,username,appeal_time,appeal_desc); } return appeal_records; } @Transactional public int agree_appeal(String appeal_id) { int result=0; 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) { int result=0; 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.3AppealController
@CrossOrigin @Api(tags = "申诉管理") @RestController @RequestMapping(value = "/manage/appealmanage") public class AppealController { @Autowired AppealService appealService; @GetMapping("/find_nodeal_appeal") @ApiOperation(value = "获取所有的未处理的申诉请求") public Appeal_Record[] find_nodeal_appeal(){ return appealService.find_nodeal_appeal(); } @PostMapping("/agree_appeal") @ApiOperation(value = "同意申诉请求") public int agree_appeal(@Param("appeal_id") String appeal_id) { return appealService.agree_appeal(appeal_id); } @PostMapping("/disagree_appeal") @ApiOperation(value = "拒绝申诉请求") public int disagree_appeal(@Param("appeal_id") String appeal_id,@Param("appeal_remark") String appeal_remark) { return appealService.disagree_appeal(appeal_id,appeal_remark); } }
这篇关于项目实训第三周第三次的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南