申诉功能实现
判断申诉的记录是否违约,将用户申诉添加到appeal表
Controller层实现
@RestController
@RequestMapping("/appeal")
public class AddAppealController {
@Autowired
AddAppealService addAppealService;
@GetMapping ("/addAppeals")//提交申诉
public int addAppeals(HttpServletRequest request, int act_id,String room_name, int seat_no,String appeal_desc){
String user_openid = (String) request.getAttribute("openid");
return addAppealService.addAppeal(user_openid,act_id,room_name,seat_no,appeal_desc);
}
}
Service层实现
@Service
public class AddAppealService {
@Autowired
AddAppealMapper addAppealMapper;
public int addAppeal(String user_openid,int act_id,String room_name,int seat_no,String appeal_desc){
int seat_id = addAppealMapper.getSeatId(room_name,seat_no);
int act_room_seat_id = addAppealMapper.getActRoomSeatId(act_id,seat_id);
int user_pick_seat_id = addAppealMapper.getUserPickSeatId(user_openid,act_room_seat_id);
Date appeal_time = new Date();//获取申诉时间
String act_name = addAppealMapper.getActName(act_id);//获取活动名
return addAppealMapper.addAppeal(user_pick_seat_id,act_name+"座位"+seat_no+"申诉理由:"+appeal_desc,appeal_time);
}
}
Mapper层实现
@Mapper
public interface AddAppealMapper {
@Select("SELECT seat_id FROM seat WHERE room_name = #{room_name} and seat_no = #{seat_no}")
int getSeatId(String room_name,int seat_no);
//查询seat_id
@Select("SELECT act_room_seat_id FROM act_room_seat WHERE act_id = #{act_id} and seat_id = #{seat_id}")
int getActRoomSeatId(int act_id,int seat_id);
//查询act_room_seat_id
@Select("SELECT user_pick_seat_id FROM user_pick_seat WHERE user_openid = #{user_openid} and act_room_seat_id = #{act_room_seat_id}")
int getUserPickSeatId(String user_openid,int act_room_seat_id);
//查询user_pick_seat_id
@Select("SELECT act_name FROM activity WHERE act_id = #{act_id}")
String getActName(int act_id);
//查询活动名
@Insert("INSERT INTO appeal (user_pick_seat_id,appeal_desc,appeal_time) VALUES (#{user_pick_seat_id},#{appeal_desc},#{appeal_time})")
int addAppeal(int user_pick_seat_id,String appeal_desc,Date appeal_time);
//将用户申诉添加到appeal,result和remark列空着
}