Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Repository
- public interface PayCashierOrderDao {
- @SelectProvider(type = PayCashierOrderDaoProvider.class, method = "findByCondition")
- List<PayCashierOrder> queryByConditions(@Param("id") long id,
- @Param("orderInfoId") long orderInfoId,
- @Param("cashierId") long cashierId,
- @Param("orderId") String orderId);
- @Insert("INSERT INTO `cashier_order`\n" +
- "(\n" +
- "`order_info_id`,\n" +
- "`cashier_id`,\n" +
- "`order_id`)\n" +
- "VALUES\n" +
- "(\n" +
- "#{payCashierOrder.orderInfoId},\n" +
- "#{payCashierOrder.cashierId},\n" +
- "#{payCashierOrder.orderId});\n")
- //设置返回自增KEY
- @Options(useGeneratedKeys = true, keyProperty = "payCashierOrder.id")
- int insertOne(@Param("payCashierOrder") PayCashierOrder payCashierOrder);
- @Update("UPDATE `cashier_order`\n" +
- "SET\n" +
- "`order_info_id` = #{payCashierOrder.orderInfoId},\n" +
- "WHERE `id` = #{payCashierOrder.id};\n")
- int updateOneOrderInfoId(@Param("payCashierOrder") PayCashierOrder payCashierOrder);
- class PayCashierOrderDaoProvider {
- //传递参数时,只接收Map类型参数
- public String findByCondition(Map<String, String> params) {
- return new SQL() {{
- SELECT("`id` AS id");
- SELECT("`order_info_id` AS orderInfoId");
- SELECT("`cashier_id` AS cashierId");
- SELECT("`order_id` AS orderId");
- FROM("cashier_order");
- if (Integer.valueOf(params.get("id")) > 0) {
- WHERE("id=#{id}");
- }
- if (Integer.valueOf(params.get("orderInfoId")) > 0) {
- WHERE("order_info_id=#{orderInfoId}");
- }
- if (Integer.valueOf(params.get("cashierId")) > 0) {
- WHERE("cashier_id=#{cashierId}");
- }
- if (StringUtils.isNotBlank(params.get("orderId"))) {
- WHERE("order_id=#{orderId}");
- }
- }}.toString();
- }
- }
- }
Add Comment
Please, Sign In to add comment