php-app开发接口加密的示例分析
583
2022-11-20
mybatis Plus 多表联合查询的实现示例
本文主要介绍了mybatis Plus 多表联合查询,分享给大家,具体如下:
//实体类package com.sk.skkill.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@TableName("orders")
@Data
public class Order implements Serializable
{
public static final long serialVersionUID =1L;
private String id;
private String orderName;
private Date createTime;
private Date updateTime;
private String userID;
@TableField(exist = false)
private List
public Order(){
}
public Order(String id, String orderName) {
this.id = id;
this.orderName = orderName;
}
}
//dao层
package com.sk.skkill.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sk.skkill.entity.Order;
import com.sun.javafx.collections.MappingChange;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface OrderMapper extends BaseMapper
{
List
int addOrder(Order order);
//多表联合查询 按条件orderID
@Select("select t1.*,t2.user_name,t2.nick_name from orders t1 LEFT JOIN users t2 ON t1.user_id =t2.id WHERE t1.user_id= #{id}")
List
}
//service层
package com.sk.skkill.service;
imCMRzOport com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sk.skkill.entity.Order;
import java.util.List;
import java.util.Map;
public interface OrderService extends IService
{
List
int addOrder(Order order);
// List
Page
}
//serviceImpl层
package com.sk.skkill.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sk.skkill.entity.Order;
import com.sk.skkill.mapper.OrderMapper;
import com.sk.skkill.service.OrderService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class OrderServiceImpl extends SeCMRzOrviceImpl
{
@Override
public List
return baseMapper.selectList(null);
}
@Override
public int addOrder(Order order) {
return baseMapper.insert(order);
}
@Override
public Page
//新建分页
Page
//返回结果
return page.setRecords(this.baseMapper.orderUserList(page,id));
}
}
//controller层
package com.sk.skkill.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sk.skkill.entity.Order;
import com.sk.skkill.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("order")
public class OrderController
{
@Autowired
private OrderServiceImpl service;
@RequestMapping("selectOrder")
public List
{
return service.selectOrder();
}
@RequestMapping("addOrder")
public int addOrder(Order order){
order=new Order("FGGG","蒙牛MILK");
return service.addOrder(order);
}
@RequestMapping("selectListPage")
public List
{
Page<CMRzO;Map
return page.getRecords();
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~