AOP日志-查询日志代码实现

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;
}
发布了2210 篇原创文章 · 获赞 50 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/Leon_Jinhai_Sun/article/details/104459831
今日推荐