|
package com.ekexiu.portal.ware;
import org.jfw.apt.annotation.DefaultValue;
import org.jfw.apt.annotation.Nullable;
import org.jfw.apt.orm.annotation.dao.Column;
import org.jfw.apt.orm.annotation.dao.DAO;
import org.jfw.apt.orm.annotation.dao.method.From;
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
import org.jfw.apt.orm.annotation.dao.method.Select;
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
import org.jfw.apt.orm.annotation.dao.method.Where;
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
import org.jfw.apt.orm.annotation.dao.method.operator.QueryList;
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
import org.jfw.apt.orm.annotation.dao.param.In;
import org.jfw.apt.orm.annotation.dao.param.LessThan;
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
import org.jfw.apt.orm.annotation.dao.param.UnEquals;
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
import org.jfw.util.PageQueryResult;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
@DAO
public abstract class WareDao {
@Insert
public abstract int insert(Connection con, Ware ware) throws SQLException;
@Insert
public abstract int insert(Connection con, WareRes res) throws SQLException;
@DeleteWith
@From(WareRes.class)
public abstract int deleteWareRes(Connection con, String id) throws SQLException;
@DeleteWith
@From(WareRes.class)
public abstract int deleteWithRes(Connection con, String id, String resource) throws SQLException;
@Insert
public abstract int insert(Connection con, WarePro pro) throws SQLException;
@DeleteWith
@From(WarePro.class)
public abstract int deleteWarePro(Connection con, String id) throws SQLException;
@DeleteWith
@From(WarePro.class)
public abstract int deleteWithPro(Connection con, String id, String professor) throws SQLException;
@Update
public abstract int update(Connection con, Ware ware) throws SQLException;
@UpdateWith
@From(Ware.class)
@Where("STATE<>'0'")
@SetSentence("STATE = '0'")
// @IncludeFixSet
public abstract int logicDelete(Connection con, String id) throws SQLException;
@UpdateWith
@From(Ware.class)
@SetSentence("PAGE_VIEWS=PAGE_VIEWS+1")
public abstract int incPageViews(Connection con, String id) throws SQLException;
@SelectList
public abstract List<WarePro> queryPro(Connection con, String id) throws SQLException;
@SelectList
public abstract List<WareRes> queryRes(Connection con, String id) throws SQLException;
@DefaultValue("0")
@QueryVal
@Column(value = "COUNT(1)", handlerClass = LongHandler.class)
@From(WareRes.class)
public abstract long countRes(Connection con, String id) throws SQLException;
@DefaultValue("0")
@QueryVal
@Column(value = "COUNT(1)", handlerClass = LongHandler.class)
@From(WarePro.class)
public abstract long countPro(Connection con, String id) throws SQLException;
@DefaultValue("0")
@QueryVal
@Column(value = "COUNT(1)", handlerClass = LongHandler.class)
@From(Ware.class)
@Where("STATE='1'")
public abstract long countPublish(Connection con, String category, String owner) throws SQLException;
@SelectOne
@Nullable
public abstract Ware queryById(Connection con, String id) throws SQLException;
@SelectOne
@Nullable
public abstract Ware queryByShareId(Connection con, long shareId) throws SQLException;
@SelectList
public abstract List<Ware> queryById(Connection con, @In String[] id) throws SQLException;
@LimitSelect
@Where("STATE='1'")
public abstract List<Ware> queryPublish(Connection con, String category, String owner, @LessThan String modifyTime, int rows) throws SQLException;
@PageSelect
@OrderBy("ORDER By STATE DESC,MODIFY_TIME DESC")
@Where("(STATE='1' OR STATE ='2') AND CATEGORY='1'")
public abstract PageQueryResult<Ware> pageQuery(Connection con,
@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?" }, isAnd = false) String key,
String owner, int pageSize, int pageNo) throws SQLException;
@QueryList
@Select(Ware.class)
@Where("(STATE='1' OR STATE ='2') AND CATEGORY='2'")
@From(Ware.class)
public abstract List<CountWare> queryByOwner(Connection con,
@Nullable @GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?" }, isAnd = false) String key,
String owner) throws SQLException;
@LimitSelect
@OrderBy(" ORDER BY PAGE_VIEWS DESC")
@Where("STATE='1'")
public abstract List<Ware> queryByOwnerWithPageViews(Connection con, String category, String owner, @Nullable @UnEquals String id, int rows)
throws SQLException;
@LimitSelect
@OrderBy("ORDER BY MODIFY_TIME DESC")
@Where("STATE='1'")
public abstract List<Ware> queryByResource(Connection con,
@SqlColumn(handlerClass = StringHandler.class, value = { "ID IN (SELECT ID FROM WARE_RES WHERE RESOURCE=?)" }) String id, int rows)
throws SQLException;
@LimitSelect
@OrderBy("ORDER BY MODIFY_TIME DESC")
@Where("STATE='1'")
public abstract List<Ware> queryByArticle(Connection con,
@SqlColumn(handlerClass = StringHandler.class, value = { "ID IN (SELECT WARE FROM ARTICLE_WARE WHERE ID=?)" }) String id, int rows)
throws SQLException;
@LimitSelect
@Where("STATE='1'")
@OrderBy(cols = { @LimitColumn(value = "sortFirst", asc = false, handlerClass = LongHandler.class), @LimitColumn(value = "modifyTime", asc = false),
@LimitColumn(value = "id", asc = false) }, value = "")
public abstract List<Ware> indexSearch(Connection con, @Nullable
@GroupSqlColumn(handlerClass = StringHandler.class, value = { "NAME LIKE ?", "CNT LIKE ?", "KEYWORDS LIKE ?",
"CATEGORY='1' AND OWNER IN(SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)",
"CATEGORY ='2' AND OWNER IN(SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)" }, additional = 1, isAnd = false, force = true) String key,
long sortFirst, String modifyTime, String id, int rows) throws SQLException;
}
|