1. 创建 Mysql 存储过程 , 这是个复杂查询加上了判断 , 比较复杂
Créer la procédure SearchallList (dans TradingAreaid Varchar (50), dans catégoriename varchar (100), en intelligencesort tinyint non signé, dans PriceBegin double, dans PriceEnd Double, dans CommodityName Varchar (200), dans Flag Tinyint Unsigned) BeginIf BusinessId, B.Shop_Name, B.Total_score, B.Shop_Logo, B.Average_Consume, D.Category_Name, B.Shop_AddressfromUser_Business_Commodity B.User_Business_idleft JOWn Service_Category D sur D.Category_id = C.Category_One_idwhere1 = 1Andif (catégorieName n'est pas la longueur nulland (Trim (catégorieName))> 0, D.Category_name = CategoryName, 1 = 1) andIf (PriceBeg 0,B.average_consume <= priceEnd,1 = 1)ANDIF (commodityName IS NOT NULLAND LENGTH(TRIM(commodityName)) > 0,A. NAME LIKE concat('%', commodityName, '%'),1 = 1)AND B.is_delete = 0AND B.shop_setup_state = 1AND A.is_delete = 0AND C.is_delete = 0AND D.is_delete = 0group bya.user_business_idorder parcase IntelligenceSorwhen 1 alors'b.total_order desc'when 2 alors'b.total_score desc'when 3 alors'b.create_time desc'business_id BusinessId, B.Shop_Name, B.Total_score, B.Shop_Logo, B.Average_Consume, D.Category_Name, B.Shop_AddressfromUser_Business_Commodity B.User_Business_idleft JOINS Service_Category D sur D.Category_id = C.Category_Two_idwhere1 = 1Andif (CatégoryName n'est pas la longueur de Nulland (Trim (CatégoryName)> 0, D.Category_name = catégoriename, 1 = 1) et le prix (PriceBeg 0,B.average_consume <= priceEnd,1 = 1)ANDIF (commodityName IS NOT NULLAND LENGTH(TRIM(commodityName)) > 0,A. NAME LIKE concat('%', commodityName, '%'),1 = 1)AND B.is_delete = 0AND B.shop_setup_state = 1AND A.is_delete = 0AND C.is_delete = 0AND D.is_delete = 0group bya.user_business_idorder parcase IntelligenceRortwhen 1 alors'b.total_order desc'when 2 alors'b.total_score desc'when 3 alors'b.create_time desc'else'b.create_time as'end; end if; end;2. 查看存储过程是否创建成功 :
Afficher l'état de la procédure;
3.Sqlmapper : :
<select id = "searchallList1" Paramettermap = "searchallListmap" statuttype = "callable" resultType = "com.dongjia168.platform.vo.erp.crm.businessshopResp"> Appel searchallList (# {TradingAreAid}, # {catégorieName}, # {IntelligenceStort}, # {PriceBegin}, # {PriceEnd}, # {CommodityName}, # {Flag}); </lect><Parametermap id = "searchalllistmap" type = "com.dongjia168.platform.vo.erp.crm.businessshopreq"> <paramètre propriété = "TradingAreAid" jdbcType = "varchar" mode = "dans" /> <paramètre propriété = "catégorie" jdbcType = "varCha Property = "IntelligenceStOrt" jdbcType = "Integer" mode = "dans" /> <paramètre Property = "PriceBegin" JDBCTYPE = "double" mode = "dans" /> <Paramètre Property = "PriceDend" JDBCTYPE = "DOUBLE" MODE = "Dans" /> <paramètre propriété = "CommodityName" JDBCTYPE = "VARCHAR propriété = "Flag" jdbcType = "Integer" mode = "dans" /> </ Parametermap>
其他和直接调用 SQL 语句一样了
以上这篇 mybatis 应用 mysql 存储过程查询数据实例就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持武林网。