@RequestMapping("/apply_positions")
public String applyPositions(@RequestParam("id") int id){
String s_account=SecurityUtils.getSubject().getPrincipal().toString();
Student student=studentService.getOne(s_account);
Position position=positionService.getOne(id);
StudentPosition studentPosition=new StudentPosition();
studentPosition.setStudent(student);
studentPosition.setPosition(position);
studentPosition.setApplicationStatus(ApplicationStatus.APPLIED);
studentPositionService.save(studentPosition);
return "redirect:/student/browse_positions";
}
像这种 我要整个都封装在studentPositionService的save方法里吗,
我也是新手,也是才看的,说下自己的理解!首先是全部封装肯定没问题的,还有就是把那几个set属性抽象出来成为一个方法,然后调用,或者用第三方的jar包也能设置吧,当然如果是学到了mybati用它也可以!请大神指点
可以不用,controller层可以进行一些数据校验并封装数据,service只进行纯粹的业务处理
都可以,controller与service写业务逻辑都行
都可以 Controller负责跳转页面以及得数据 service主要就是处理数据了