YangeIT大约 6 分钟tlias智能学习辅助系统MysqlApifoxServletHTTPGETPOST

1. 接口开发

1.1 分页查询护理服务列表 🎯

分页查询护理服务列表

  1. 阅读接口文档和效果图

接口文档:

image
image

点击查看在线接口文档 👈

最终效果图:

image
image

代码操作

开发流程:

  1. 编写Controller代码
  2. 编写Mapper接口和Mapper映射配置文件
  3. 微信小程序测试
1 在Controller中添加方法
image
image

注意: 可以通过@Autowired注解,从IOC容器中获取指定类型的对象并赋值给成员变量

1.2 护理服务详情查询 🎯

护理服务详情查询

  1. 阅读接口文档和效果图

接口文档:

image
image

点击查看在线接口文档 👈

最终效果图:image

代码操作

开发流程:

  1. 编写Controller代码
  2. 编写Mapper接口和Mapper映射配置文件
  3. 微信小程序测试
1 在Controller中添加方法
image
image

注意: 可以通过@Autowired注解,从IOC容器中获取指定类型的对象并赋值给成员变量

1.3. 我的家人

前言

image
image
  • 请求路径: http://127.0.0.1:9995/customer/user/my
  • 请求方式:GET
  • 请求参数:无
  • 响应格式:application/json;charset=UTF-8
  • 响应数据:👇
{
    "msg": "操作成功",
    "code": 200,
    "data": [
        {
            "id": 15,
            "familyMemberId": 10,//家属id
            "elderId": 1,//老人id
            "createTime": null,
            "updateTime": null,
            "createBy": null,
            "updateBy": null,
            "remark": null,
            "elderName": "刘备"//老人姓名
        },
        {
            "id": 14,
            "familyMemberId": 10,
            "elderId": 6,
            "createTime": null,
            "updateTime": null,
            "createBy": null,
            "updateBy": null,
            "remark": null,
            "elderName": "刘爱国"
        }
    ]
}

1.Controller代码如下:👇

/**
 * 我的家人列表-用于下拉列选择家人
 */
@GetMapping("/my")
@ApiOperation(value = "我的家人列表")
public AjaxResult  my(HttpServletRequest request) {
    Integer userId = getUserId(request);
    if (userId == 0){
        return AjaxResult.error("请先登录");
    }
    List<FamilyMemberElderVo> memberElders = familyMemberElderMapper.selectByMemberId(Long.valueOf(userId));

    return AjaxResult.success(memberElders);
}

2.FamilyMemberMapper接口代码如下:👇

@Mapper
public interface FamilyMemberElderMapper extends BaseMapper<FamilyMemberElder> {
    List<FamilyMemberElderVo> selectByMemberId(Long userId);
}

3.FamilyMemberMapper.xml映射文件代码如下:👇

image
image

测试截图: image

1.4 查询取消预约数量

前言

代码操作


@GetMapping("/cancelled-count")
@ApiOperation("查询取消预约数量")
public AjaxResult getCancelledReservationCount(HttpServletRequest request) {
    Integer userId = getUserId(request);
    if (userId == 0) {
        return AjaxResult.error("请先登录");
    }
    QueryWrapper<Reservation> queryWrapper = new QueryWrapper<Reservation>();
    queryWrapper.eq("create_by", userId);
    //查询当前用户取消的预约数量
    queryWrapper.eq("status", 2);


    Long count = reservationMapper.selectCount(queryWrapper);
    return AjaxResult.success(count);
}

1.5 查询每个时间段剩余预约次数

前言

代码操作

1.6 新增预约 🎯

新增预约

  1. 阅读接口文档和效果图

接口文档:image

点击查看在线接口文档 👈

最终效果图:

image
image

代码操作

开发流程:

  1. 编写Controller代码
  2. 编写Mapper接口和Mapper映射配置文件
  3. 微信小程序测试
1 在ReservationController中添加方法
//新增预约
@PostMapping("/customer/reservation")
public Result addReservation(@RequestBody HashMap<String,Object> params){
    //补全数据
    //1.补全状态
    params.put("status",0);
    //2.补全创建时间
    params.put("createTime", LocalDateTime.now());
    //3.补全更新时间
    params.put("updateTime",LocalDateTime.now());

    //调用mapper完成添加
    reservationMapper.insert(params);
    return Result.success();
}

注意: 可以通过@Autowired注解,从IOC容器中获取指定类型的对象并赋值给成员变量

总结

课堂作业

  1. 参考接口文档和上述步骤,完成新增分页查询🎤

1.7 预约列表分页查询 🎯

预约列表分页查询

  1. 阅读接口文档和效果图

接口文档:image

点击查看在线接口文档 👈

最终效果图:

image
image

代码操作

开发流程:

  1. 准备资料
  2. 编写Controller代码
  3. 编写Mapper接口和Mapper映射配置文件
  4. 微信小程序测试
1. 定义实体类PageResult,封装分页查询结果

/**
 * 分页结果包装
 *
 * @author itheima
 */
@Data
public class PageResult<T> {
    private Long total ;//总条数
    private Integer pageSize ;//每页条数
    private Long pages ;//总页码
    private Integer page ;//页码当前页码
    private List<T> records;//当前页数据

    public PageResult() {
    }

    public PageResult(Long total, Integer pageSize, Long pages, Integer page, List<T> records) {
        this.total = total;
        this.pageSize = pageSize;
        this.pages = pages;
        this.page = page;
        this.records = records;
    }

}

总结

课堂作业

  1. 参考接口文档和上述步骤,完成分页查询🎤
  2. 思考分页插件PageHelper的作用是什么?他做了哪些工作?

1.8 取消预约 🎯

新增预约

  1. 阅读接口文档和效果图

接口文档:image

点击查看在线接口文档 👈

最终效果图:

image
image

代码操作

开发流程:

  1. 编写Controller代码
  2. 编写Mapper接口和Mapper映射配置文件
  3. 微信小程序测试
1 在ReservationController中添加方法
image
image

注意: 可以通过@Autowired注解,从IOC容器中获取指定类型的对象并赋值给成员变量

总结

课堂作业

  1. 参考接口文档和上述步骤,完成取消订单🎤