1. 创建 mysql 存储过程 , 这是个复杂查询加上了判断 , 比较复杂
Create Procedure SearchAllList (in TradingAingareaid varchar (50) in CategoryName varchar (100) in Intelligencesort TinyInt Unsigned, in PriceBegin Double, in Priceend Double, in CommodityName varchar (200) in Flag Tinyint unsigned) beginfn = 0 theSelectb.user_boussisshnin BusinessId, B.Shop_Name, B.Total_Score, B.Shop_Logo, b.Aververy_consume, d.category_name, b.shop_addressfromUser_business_commodity aleft join user_business b auf b.user_business_business_Idle_IdleTly -Idleft -Ufer_Business_Business_Intel_Business_Business_Business_Business. B.user_business_idleft join Service_Category D auf d.category_id = category_one_idwhere1 = 1andif (CategoryName ist nicht nulland länge (trimoryName)> 0, d.category_name = categoryName, 1 = 1) und if. priceBin! 0, b.Aververage_consume <= priceend, 1 = 1) und if (CommodityName ist nicht nulland Länge (Trim (CommodityName)> 0, a. Name wie concat ('%', commodityName, '%'), 1 = 1) und b.is_delete = 0and b.Shop_Set = 1 und 1AnddaN = 1And.- und 1Ards = 1And.- und 1Ards = 1Arddel = 0Ands = 1Ands = 0Ands = 0Ands = 0Ands = 0And. 0GROUP BYA.user_business_idORDER BYCASE intelligenceSortWHEN 1 THEN'B.total_order DESC'WHEN 2 THEN'B.total_score DESC'WHEN 3 THEN'B.create_time DESC'ELSE'B.create_time ASC'END;ELSESELECTB.user_business_id BusinessId, B.Shop_Name, B.Total_Score, B.Shop_Logo, b.Aververy_consume, d.category_name, b.shop_addressfromUser_business_commodity aleft join user_business b auf b.user_business_business_Idle_IdleTly -Idleft -Ufer_Business_Business_Intel_Business_Business_Business_Business. B.user_business_idleft join Service_Category D auf d.category_id = category_two_idwhere1 = 1andif (CategoryName ist nicht nulland länge (trimoryName)> 0, d.category_name = categoryName, 1 = 1) und if. ifgin (PriceBegin! 0, b.Aververage_consume <= priceend, 1 = 1) und if (CommodityName ist nicht nulland Länge (Trim (CommodityName)> 0, a. Name wie concat ('%', commodityName, '%'), 1 = 1) und b.is_delete = 0and b.Shop_Set = 1 und 1AnddaN = 1And.- und 1Ards = 1And.- und 1Ards = 1Arddel = 0Ands = 1Ands = 0Ands = 0Ands = 0Ands = 0And. 0group bya.user_business_idorder bycase IntelligencenWhen 1 then'b.total_order deswhen 2 then'b.total_score desc'when 3 then'b.create_time Desc'else'b.create_time asc't; Ende if;2. 查看存储过程是否创建成功 :
Verfahrensstatus anzeigen;
3.SQLMapper 文件 :
<select id = "SearchAllList1" ParameterMap = "SearchAllListMap" AnweisungType = "Callable" resultType = "com.dongjia168.Platform.vo.erp.crm.businessShopresp" SearchAllList (#{tradingAraid},#{categoryName},#{Intelligencesort},#{PriceBin},#{Priceend},#{commodityName},#{flag}); </select><parameterMap id = "SearchAllListMap" type = "com.dongjia168.Platform.vo.erp.crm.businessShopreq"> <parameter Property = "tradingAraid" jdbctype = "varchar" modus "in"/> <parameter probium "categoryname" jdbctype = "varchary" in "/> <" in "/> <" in "/> <" in "/> <" in "/> <" in "pharchname" jdbctype Property = "IntelligencenSort" jdbctype = "Integer" modus = "in"/> <parameter property = "priceBegin" jdbctype = "double" modus = "in"/> <parameter Properation = "priceend" jdbctype = "double" modus "/> <parameter probiode =" comodityname "in" comodityname "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in" in "in der Eigenschaft = "Flag" jdbcType = "Integer" modus = "in"/> </parametermap>
其他和直接调用 sql 语句一样了
以上这篇 mybatis 应用 mysql 存储过程查询数据实例就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持武林网。 也希望大家多多支持武林网。