The second time in the fourth week of project training

1. Task arrangement

The basic requirements have been completed. For the complaint management and repair request management, during the test, abnormal conditions have been found, resulting in multiple messages repeatedly sent to the user, and the number of defaults of the user has become negative.

2. Task analysis

Through analysis and communication with the front-end students, it is found that the front-end students did not set the prompt message after successful operation, resulting in the front-end administrator agreeing to the same appeal request for many times. In the initial design process, I think that once the operation of agreeing to the appeal request is completed, it will disappear from the list of appeal requests to be reviewed displayed at the front end, so the appeal request operation cannot be carried out again. Therefore, the current end is passed to the back-end app eal_ ID, the appeal record is to be approved by default. However, this is unreasonable, even if the front end has corresponding measures for successful operation. For example, after you send a post request through Postman, you can click the app at this time_ The ID can be arbitrary, and it is not certain whether the appeal request is pending or has been reviewed. Therefore, we need to start with the app passed to the back end_ ID determines whether the status of the current appeal request is pending approval. If the appeal request is not to be approved, it will be returned to the front end 0. If the appeal request is to be approved, the corresponding value will be returned according to the number of operations. The rejection of appeal request, the consent of warranty operation, rejection and maintenance seat operation are similar.

3. Specific code

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 = "You in" +
                    df.format(appealMapper.find_appeal_time_by_appeal_id(Integer.valueOf(appeal_id))) +
                    "The submitted is named" + appealMapper.find_act_name_by_appeal_id(Integer.valueOf(appeal_id)) + "The appeal of the event has been passed";
            result += appealMapper.add_message_record(user_openid, "Successful appeal", message_content, "0", date);
            result += appealMapper.update_defaults_by_user_openid(user_openid);
            //The number of defaults was originally 3, but now minus 1 becomes 2. In a critical state.
            if (defaults == 3) {
                String act_id = appealMapper.find_act_id_by_user_openid(user_openid);
                if (act_id.isEmpty()) {
                    //It means that the user is prohibited from participating in all activities due to breach of contract. Now the breach is lifted and removed from the blacklist
                    result += appealMapper.delete_blacklist_record(user_openid);
                    result += appealMapper.add_message_record(user_openid, "Blacklist lifting",
                            "You have been removed from the blacklist. Please keep good seat selection habits", "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 = "You in" +
                    df.format(appealMapper.find_appeal_time_by_appeal_id(Integer.valueOf(appeal_id))) +
                    "Submitted named" + appealMapper.find_act_name_by_appeal_id(Integer.valueOf(appeal_id)) + "The appeal of the campaign was not passed";
            result += appealMapper.add_message_record(user_openid, "Appeal failed", 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"))
         {
             //Change a repair request from pending to unrepaired
             result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "0");
             //Change the seat status from possible damage to damaged
             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 = "Repair request audit notice";
             String message_content = "You in" + time + "The submitted classroom name is" + room_name + "The middle seat number is"
                     + seat_no + "Your seat repair request has been passed. Please wait patiently for the seat to be repaired";
             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"))
        {
            //Change repair request from pending to repaired
            result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "1");
            //Change the seat status from possible damage to normal use
            result += repairMapper.update_seat_status_by_repair_id(Integer.valueOf(repair_id), "1");
            //Change the repair request status of the user to 0, which means that the user cannot apply for repair
            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 = "Repair request audit notice";
            String message_content = "You in" + time + "The submitted classroom name is" + room_name + "The middle seat number is"
                    + seat_no + "Your seat repair request failed.Due to your illegal operation,You will not be able to apply for repair.";
            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"))
        {
            //Change a repair request from never repaired to repaired
            result += repairMapper.update_repaired_by_repair_id(Integer.valueOf(repair_id), "1");
            //Change the seat status from damaged to normal use
            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 = "Seat maintenance notice";
            String message_content = "You in" + time + "The submitted classroom name is" + room_name + "The middle seat number is"
                    + seat_no + "Your seat has been repaired,You can use this seat normally.";
            Date date = new Date();
            result += repairMapper.add_message_record(user_openid, message_title, message_content, "0", date);
        }
        return result;
    }

Keywords: Java Spring Boot

Added by Sentosa on Sun, 16 Jan 2022 00:50:37 +0200