SysLogController
@RequestMapping("/sysLog")
@Controller
public class SysLogController {
@Autowired
private ISysLogService sysLogService;
@RequestMapping("/findAll.do")
public ModelAndView findAll() throws Exception {
ModelAndView mv = new ModelAndView();
List<SysLog> sysLogs = sysLogService.findAll();
mv.addObject("sysLogs", sysLogs);
mv.setViewName("syslog-list");
return mv;
}
}
Service
@Service
@Transactional
public class SysLogServiceImpl implements ISysLogService {
@Autowired
private ISysLogDao sysLogDao;
@Override
public void save(SysLog log) throws Exception {
sysLogDao.save(log);
}
@Override
public List<SysLog> findAll() throws Exception {
return sysLogDao.findAll();
}
}
Dao
public interface ISysLogDao {
@Select("select * from syslog")
@Results({
@Result(id=true,column="id",property="id"),
@Result(column="visitTime",property="visitTime"),
@Result(column="ip",property="ip"),
@Result(column="url",property="url"),
@Result(column="executionTime",property="executionTime"),
@Result(column="method",property="method"),
@Result(column="username",property="username")
})
public List<SysLog> findAll() throws Exception;
@Insert("insert into syslog(visitTime,username,ip,url,executionTime,method) values(#
{visitTime},#{username},#{ip},#{url},#{executionTime},#{method})")
public void save(SysLog log) throws Exception;
}