src/main/java/com/zhazhapan/efo/dao/sqlprovider/FileSqlProvider.java
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.zhazhapan.efo.dao.sqlprovider;
import com.zhazhapan.efo.EfoApplication;
import com.zhazhapan.efo.modules.constant.ConfigConsts;
import com.zhazhapan.modules.constant.ValueConsts;
import com.zhazhapan.util.Checker;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;
/**
* @author pantao
* @since 2018/1/19
*/
@Component
public class FileSqlProvider {
public String updateAuthById() {
return CommonSqlProvider.updateAuthById("file");
}
/**
* 生成一条文件基本信息的查询语句
*
* @param userId 用户编号
* @param fileId 文件编号
*
* @return SQL语句
*/
public String getBasicBy(@Param("userId") int userId, @Param("fileId") long fileId, @Param("fileName") String
fileName, @Param("categoryId") int categoryId, @Param("offset") int offset) {
String sql = new SQL() {{
SELECT("f.id,u.username,f.local_url,c.name category_name,f.visit_url,f.download_times," + "f" + "" + "" +
".create_time");
FROM("file f");
JOIN("user u on f.user_id=u.id");
JOIN("category c on f.category_id=c.id");
if (userId > 0) {
WHERE("f.user_id=#{userId}");
}
if (fileId > 0) {
WHERE("f.id=#{fileId}");
} else if (Checker.isNotEmpty(fileName)) {
WHERE("f.local_url like '%" + fileName + "%'");
}
if (categoryId > 0) {
WHERE("c.id=#{categoryId}");
}
ORDER_BY("f." + EfoApplication.settings.getStringUseEval(ConfigConsts.FILE_ORDER_BY_OF_SETTING));
}}.toString();
int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.FILE_PAGE_SIZE_OF_SETTING);
return sql + " limit " + (offset * size) + "," + size;
}
private String getSqlEnds(int offset, String orderBy, String search) {
int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.FILE_PAGE_SIZE_OF_SETTING);
return getSearch(search) + " order by " + (Checker.isEmpty(orderBy) ? EfoApplication.settings
.getStringUseEval(ConfigConsts.FILE_ORDER_BY_OF_SETTING) : orderBy) + " limit " + offset * size
+ "," + size;
}
后面还有 50 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
