基于ssm框架的选手退赛申请表代码
时间: 2023-07-29 16:08:33 浏览: 33
以下是一个基于SSM框架的选手退赛申请表的代码示例。需要注意的是,这只是一个示例,实际的代码可能会因为具体业务需求而有所不同。
1. Controller层代码:
```java
@Controller
@RequestMapping("/player")
public class PlayerController {
@Autowired
private PlayerService playerService;
// 显示选手退赛申请表页面
@RequestMapping("/showQuitForm")
public String showQuitForm(Model model) {
model.addAttribute("quitForm", new QuitForm());
return "quitForm";
}
// 处理选手退赛申请表提交
@RequestMapping(value = "/submitQuitForm", method = RequestMethod.POST)
public String submitQuitForm(@ModelAttribute QuitForm quitForm, Model model) {
int playerId = quitForm.getPlayerId();
String reason = quitForm.getReason();
playerService.applyQuit(playerId, reason);
model.addAttribute("msg", "退赛申请已提交");
return "result";
}
}
```
2. Service层代码:
```java
@Service
public class PlayerService {
@Autowired
private PlayerMapper playerMapper;
// 选手申请退赛
public void applyQuit(int playerId, String reason) {
Player player = playerMapper.selectByPrimaryKey(playerId);
if (player != null) {
player.setStatus("quit");
player.setReason(reason);
playerMapper.updateByPrimaryKeySelective(player);
}
}
}
```
3. Mapper层代码:
```java
public interface PlayerMapper {
int deleteByPrimaryKey(Integer id);
int insert(Player record);
int insertSelective(Player record);
Player selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Player record);
int updateByPrimaryKey(Player record);
}
```
4. 页面代码:
```html
<form action="${pageContext.request.contextPath}/player/submitQuitForm" method="post">
<label>选手ID:</label>
<input type="text" name="playerId"/><br/><br/>
<label>退赛原因:</label>
<textarea name="reason" rows="5" cols="50"></textarea><br/><br/>
<input type="submit" value="提交"/>
</form>
```
以上代码仅供参考,具体实现还需根据实际情况进行调整。