Commit fe0da9b5 authored by Quxl's avatar Quxl

x

parent 2989bec3
......@@ -7,6 +7,6 @@ import com.egolm.common.jdbc.Page;
public interface LogService {
List<Map<String, Object>> queryLogList(String type, Page page);
List<Map<String, Object>> queryLogList(String type, String username, Page page);
}
......@@ -10,6 +10,7 @@ import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.LogService;
import com.egolm.film.util.SqlWhere;
@Service
public class LogServiceImpl implements LogService {
......@@ -18,8 +19,11 @@ public class LogServiceImpl implements LogService {
JdbcTemplate jdbcTemplate;
@Override
public List<Map<String, Object>> queryLogList(String type, Page page) {
return jdbcTemplate.limit("select l.*, le.ext from fc_logs l left join fc_logs_ext le on le.path = l.path" + (StringUtil.isNotBlank(type) ? " where l.type = '" + type.toUpperCase() + "'" : ""), page);
public List<Map<String, Object>> queryLogList(String type, String username, Page page) {
SqlWhere where = new SqlWhere().eq("t.type", type).eq("t.username", username);
String sql = "select l.*, le.ext, ifnull(ifnull(u.username, m.username), a.realname) username from fc_logs l left join fc_logs_ext le on le.path = l.path left join fc_user u on u.uid = l.loginid and l.type = 'USER' left join fc_member m on m.id = l.loginid and l.type = 'MEMBER' left join fc_admin a on a.adminid = l.loginid and l.type = 'ADMIN'";
sql = "select t.* from (" + sql + ") t" + StringUtil.join(" and ", " where ", "", "", where.getStringList());
return jdbcTemplate.limit(sql, page, where.getObjectArray());
}
}
......@@ -31,14 +31,15 @@ public class AdminLogController {
@ApiOperation("查询日志")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="type", value="ADMIN,MEMBER,USER"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="username"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="limit", value="分页大小"),
})
public Object list(String type, Long index, Long limit) {
public Object list(String type, String username, Long index, Long limit) {
index = index == null ? 1 : index;
limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
List<Map<String, Object>> list = service.queryLogList(type, page);
List<Map<String, Object>> list = service.queryLogList(type, username, page);
return Rjx.jsonOk().setData(list);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment