下面列出了怎么用org.apache.ibatis.annotations.Select的API类实例代码及写法,或者点击链接到github查看源代码。
@Select({"SELECT configurationApplications.id AS id, " +
" configurations.id AS configurationId, " +
" configurations.name AS configurationName, " +
" configurations.customerId AS customerId, " +
" applications.id AS applicationId, " +
" applications.name AS applicationName, " +
" COALESCE(configurationApplications.showIcon, applications.showIcon) AS showIcon, " +
" applications.id AS applicationVersionId, " +
" applications.id AS versionText, " +
" configurationApplications.remove AS remove, " +
" configurationApplications.action AS action " +
"FROM configurations " +
"INNER JOIN applicationVersions ON applicationVersions.id = #{id} " +
"INNER JOIN applications ON applications.id = applicationVersions.applicationId " +
"LEFT JOIN configurationApplications ON configurations.id = configurationApplications.configurationId AND configurationApplications.applicationVersionId = applicationVersions.id " +
"WHERE configurations.customerId = #{customerId} " +
"ORDER BY LOWER(configurations.name)"})
List<ApplicationVersionConfigurationLink> getApplicationVersionConfigurationsWithCandidates(
@Param("customerId") Integer customerId, @Param("id") Integer applicationVersionId
);
/**
* 通过降级点来查询
*
* @param point
* @return
*/
@Select("select * from point_return_value where app_group_name = #{appGroupName} and app_name = #{appName} " +
"and point = #{point}")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "appGroupName", column = "app_group_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "point", column = "point"),
@Result(property = "returnValueStr", column = "return_value_str"),
@Result(property = "operatorName", column = "operator_name"),
@Result(property = "operatorEmail", column = "operator_email"),
@Result(property = "creatorName", column = "creator_name"),
@Result(property = "creatorEmail", column = "creator_email"),
@Result(property = "modifiedTime", column = "modify_time"),
@Result(property = "createTime", column = "create_time")
})
PointReturnValueDO queryByPoint(@Param("appGroupName") String appGroupName, @Param("appName") String appName,
@Param("point") String point);
/**
* 通过应用组名称来查询
*
* @param appGroupName
* @param appName
* @param sdsSchemeName
* @return
*/
@Select("select * from sds_scheme where app_group_name = #{appGroupName} " +
" and app_name = #{appName} " +
" and sds_scheme_name = #{sdsSchemeName} " +
" order by modify_time desc ")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "appGroupName", column = "app_group_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "sdsSchemeName", column = "sds_scheme_name"),
@Result(property = "operatorName", column = "operator_name"),
@Result(property = "operatorEmail", column = "operator_email"),
@Result(property = "modifiedTime", column = "modify_time"),
@Result(property = "createTime", column = "create_time")
})
SdsSchemeDO queryByGroupName(@Param("appGroupName") String appGroupName, @Param("appName") String appName,
@Param("sdsSchemeName") String sdsSchemeName);
@Select("SELECT c.name " +
"FROM configurationFiles cf " +
"INNER JOIN configurations c ON c.id = cf.configurationId " +
"INNER JOIN uploadedFiles uf ON uf.id = cf.fileId " +
"WHERE c.customerId = #{customerId} " +
"AND uf.filePath = #{fileName}")
List<String> getUsingConfigurations(@Param("customerId") int customerId, @Param("fileName") String fileName);
/**
* 按条件查询心跳数据
*
* @param appGroupName
* @param appName
* @param point
* @param startTime
* @param endTime
* @return
*/
@Select("select * from heartbeat where app_group_name = #{appGroupName} " +
" and app_name = #{appName} " +
" and point = #{point} " +
" and statistics_cycle_time >= #{startTime}" +
" and statistics_cycle_time <= #{endTime}")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "appGroupName", column = "app_group_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "point", column = "point"),
@Result(property = "downgradeNum", column = "downgrade_num"),
@Result(property = "visitNum", column = "visit_num"),
@Result(property = "exceptionNum", column = "exception_num"),
@Result(property = "timeoutNum", column = "timeout_num"),
@Result(property = "maxConcurrentNum", column = "max_concurrent_num"),
@Result(property = "appIp", column = "app_ip"),
@Result(property = "statisticsCycleTime", column = "statistics_cycle_time")
})
List<HeartbeatDO> queryHeartbeatList(@Param("appGroupName") String appGroupName, @Param("appName") String appName,
@Param("point") String point, @Param("startTime") Date startTime, @Param(
"endTime") Date endTime);
@Select({"SELECT configurationApplications.id AS id, " +
" configurations.id AS configurationId, " +
" configurations.name AS configurationName, " +
" configurations.customerId AS customerId, " +
" applications.id AS applicationId, " +
" applications.name AS applicationName, " +
" COALESCE(configurationApplications.showIcon, applications.showIcon) AS showIcon, " +
" configurationApplications.remove AS remove, " +
" latestAppVersion.version AS latestVersionText, " +
" currentAppVersion.version AS currentVersionText, " +
" (configurationApplications.configurationId IS NOT NULL AND applications.latestVersion <> configurationApplications.applicationVersionId) AS outdated, " +
" configurationApplications.action AS action " +
"FROM configurations " +
" LEFT JOIN applications ON applications.id = #{id} " +
" INNER JOIN applicationVersions AS latestAppVersion ON latestAppVersion.applicationId = applications.id AND latestAppVersion.id=applications.latestversion " +
" LEFT JOIN configurationApplications ON configurations.id = configurationApplications.configurationId AND " +
" applications.id = configurationApplications.applicationId " +
" LEFT JOIN applicationVersions AS currentAppVersion ON currentAppVersion.applicationId = applications.id AND currentAppVersion.id=configurationApplications.applicationVersionId " +
"WHERE configurations.customerId = #{customerId} " +
"ORDER BY LOWER(configurations.name)"})
List<ApplicationConfigurationLink> getApplicationConfigurations(@Param("customerId") Integer customerId,
@Param("id") Integer applicationId);
/**
* 根据年份和物料id获取进出仓记录
*/
@Select("SELECT materialsSell.id as id,materials.materialsName as materialsName,materialsSellDetail.total as total,materialsSell.type as type,DATE(materialsSell.date) as date,user.username as username "
+ "FROM materialsSell,materialsSellDetail,user,materials "
+ "WHERE "
+ "materialsSell.id = materialsSellDetail.materialsSellId "
+ "AND materialsSell.userId = user.id "
+ "AND materials.id = materialsSellDetail.materialsId "
+ "AND YEAR(materialsSell.date) = #{year} "
+ "AND materials.id = #{materialsId}")
public List<InOutDataVo> getBillDateByYearAndMaterial(@Param("materialsId") String materialsId, @Param("year") String year);
/**
* 查询所有降级预案
*
* @param appGroupName
* @param appName
* @return
*/
@Select("select * from sds_scheme where app_group_name = #{appGroupName} and app_name = #{appName} order by "
+ "modify_time desc ")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "appGroupName", column = "app_group_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "sdsSchemeName", column = "sds_scheme_name"),
@Result(property = "operatorName", column = "operator_name"),
@Result(property = "operatorEmail", column = "operator_email"),
@Result(property = "modifiedTime", column = "modify_time"),
@Result(property = "createTime", column = "create_time")
})
List<SdsSchemeDO> queryAllSdsScheme(@Param("appGroupName") String appGroupName,
@Param("appName") String appName);
/**
* 查询下一章节ID
* @param bookId
* @param currentSortNumber
* @return
*/
@Select("select id from book_chapter " +
" where book_id=#{bookId} " +
" and sort_number > #{currentSortNumber} " +
" order by sort_number asc limit 1")
Integer selectNextChapterId(@Param("bookId") Integer bookId,
@Param("currentSortNumber") Integer currentSortNumber);
@Select({"SELECT COUNT(*) AS cnt " +
"FROM applications " +
"INNER JOIN customers ON customers.id = applications.customerId " +
"INNER JOIN applicationVersions ON applicationVersions.id = applications.latestVersion " +
"WHERE (applications.customerId = #{customerId})" +
"AND (applicationVersions.url=#{url}) "})
long countAllApplicationsByUrl(@Param("customerId") int customerId, @Param("url") String url);
@Select({SELECT_BY_VERSION_BASE +
"WHERE (customerId = #{customerId} OR customers.master = TRUE )" +
"AND pkg = #{pkg} " +
"AND applicationVersions.version=#{version}"})
List<Application> findByPackageIdAndVersion(@Param("customerId") int customerId,
@Param("pkg") String pkg,
@Param("version") String version);
@Select("select * from user where id =#{id}")
User findById(@Param("id") String id);
@Select("SELECT * FROM cargo WHERE id = #{id}")
CargoDO find(@Param("id") String id);
@Select("SELECT customerId, pluginId FROM pluginsDisabled ORDER BY customerId, pluginId")
List<DisabledPlugin> getDisabledPluginsForAllCustomers();
@Select("<script>select s.id,c.money,c.name,c.condition,c.use_end_time as useEndTime from store_coupon_list s left join store_coupon c " +
"on s.cid=c.id where s.uid=#{userId} and s.status=0" +
" <if test='orderTotalPrice > 0'>and c.condition <![CDATA[<= ]]> #{orderTotalPrice}</if>" +
" and c.use_start_time <![CDATA[<= ]]> now() and c.use_end_time <![CDATA[>= ]]> now()</script>")
List<CouponDTO> couponList(@Param("userId") int userId,
@Param("orderTotalPrice") double orderTotalPrice);
@Select("select GROUP_CONCAT(`key` ORDER BY store_count desc SEPARATOR '_') as keystr" +
" from store_spec_goods_price where goods_id=#{goodsId}")
String goodsSpecKey(int goodsId);
@Select("<script> SELECT a.name,b.id,b.spec_id as specId,b.item FROM store_spec AS a " +
"INNER JOIN store_spec_item AS b ON a.id = b.spec_id " +
"WHERE b.id IN " +
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item} </foreach>" +
"ORDER BY b.id </script>")
List<ItemDTO> goodsSpec(List<String> keys);
@Select("select user_id from user where user_name=#{user_name} and user_password=#{user_password}")
public String getUserById(@Param("user_name") String user_name, @Param("user_password") String user_password);
@Select("SELECT r.role_name,ur.role_id \n" +
"FROM (sys_role r LEFT JOIN sys_user_role ur ON r.role_id = ur.role_id ) \n" +
"LEFT JOIN sys_user u ON u.user_id = ur.user_id WHERE u.user_id = #{userId}")
List<SysUserRole> selectUserRoleListByUserId(Integer userId);
@Select("select *from account")
public List<Account> findAll();
@Select("select user_name from user where user_name=#{user_name}")
public String rearchUserName(@Param("user_name") String user_name);
@Select("SELECT EXISTS (SELECT 1 FROM customers WHERE id > 1 LIMIT 1)")
boolean isMultiTenant();
@Select("<script>select m.* from menu m LEFT OUTER JOIN roles_menus t on m.id= t.menu_id LEFT OUTER JOIN role r on r.id = t.role_id where m.type!=2 and r.id in <foreach collection=\"roleIds\" index=\"index\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item}</foreach> order by m.sort asc</script>")
List<Menu> selectListByRoles(@Param("roleIds") List<Long> roleIds);
@Select("select user_name from user where user_name=#{user_name} and user_password=#{user_password}")
public String login(@Param("user_name") String user_name, @Param("user_password") String user_password);
@Select("SELECT DISTINCT parent_artifactid FROM maven_childNodes WHERE parent_artifactid = #{artifact_id} AND parent_groupid = #{group_id}")
public String getParentArtifactId(@Param("artifact_id")String artifact_id, @Param("group_id")String group_id);
/**
* 分页查询降级点策略
*
* @param appGroupName
* @param appName
* @param point
* @param sdsSchemeName
* @param start
* @param size
* @return
*/
@Select("<script> select * from point_strategy " +
"<where> " +
" <if test='appGroupName != null and appGroupName.length > 0'> and app_group_name = #{appGroupName} </if>" +
" <if test='appName != null and appName.length > 0'> and app_name = #{appName} </if> " +
" <if test='sdsSchemeName != null and sdsSchemeName.length > 0'> and sds_scheme_name = "
+ "#{sdsSchemeName} </if>" +
" <if test='point != null and point.length > 0'> and point like concat('%', #{point}, '%') </if> " +
"</where>" +
" order by modify_time desc " +
" limit #{start}, #{size} </script>")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "appGroupName", column = "app_group_name"),
@Result(property = "appName", column = "app_name"),
@Result(property = "point", column = "point"),
@Result(property = "sdsSchemeName", column = "sds_scheme_name"),
@Result(property = "visitThreshold", column = "visit_threshold"),
@Result(property = "concurrentThreshold", column = "concurrent_threshold"),
@Result(property = "exceptionThreshold", column = "exception_threshold"),
@Result(property = "exceptionRateThreshold", column = "exception_rate_threshold"),
@Result(property = "exceptionRateStart", column = "exception_rate_start"),
@Result(property = "timeoutThreshold", column = "timeout_threshold"),
@Result(property = "timeoutCountThreshold", column = "timeout_count_threshold"),
@Result(property = "tokenBucketGeneratedTokensInSecond", column =
"token_bucket_generated_tokens_in_second"),
@Result(property = "tokenBucketSize", column = "token_bucket_size"),
@Result(property = "delayTime", column = "delay_time"),
@Result(property = "retryInterval", column = "retry_interval"),
@Result(property = "downgradeRate", column = "downgrade_rate"),
@Result(property = "pressureTestDowngrade", column = "pressure_test_downgrade"),
@Result(property = "status", column = "status"),
@Result(property = "operatorName", column = "operator_name"),
@Result(property = "operatorEmail", column = "operator_email"),
@Result(property = "creatorName", column = "creator_name"),
@Result(property = "creatorEmail", column = "creator_email"),
@Result(property = "modifiedTime", column = "modify_time"),
@Result(property = "createTime", column = "create_time")
})
List<PointStrategyDO> queryPointStrategyByPage(@Param("appGroupName") String appGroupName,
@Param("appName") String appName, @Param("point") String point,
@Param("sdsSchemeName") String sdsSchemeName, @Param(
"start") Integer start, @Param("size") Integer size);
@Select("select id from slowlog where pid = #{pid}")
public Long getSlowlogByPid(Long pid);
@Select("SELECT Count(*) FROM t_app a where a.is_deleted=0 and a.framework_verison=#{version}")
int totalUseFrameworkConut(@Param("version") int version);
@Select("SELECT status FROM pendingPushes WHERE messageId = #{messageId}")
Integer getDeliveryStatus(@Param("messageId") int messageId);
@Select("SELECT A.id,A.name FROM role A LEFT JOIN user_role B ON A.id=B.role_id WHERE B.user_id=${userId}")
List<Role> getRolesByUserId(@Param("userId") Long userId);