采网站建设,wordpress登录后评论,抽奖网站建设,没有营业执照可以做网站吗查看页面原型#xff0c;明确需求需求
页面原型 需求分析 阅读接口文档
接口文档链接如下#xff1a;
https://docs.qq.com/doc/DUkRiTWVaUmFVck9N
思路分析
用户发送请求#xff0c;交由对应的Controller类进行处理#xff0c;Controller类调用service实现查询部门功… 查看页面原型明确需求需求
页面原型 需求分析 阅读接口文档
接口文档链接如下
https://docs.qq.com/doc/DUkRiTWVaUmFVck9N
思路分析
用户发送请求交由对应的Controller类进行处理Controller类调用service实现查询部门功能对应的service业务层调用对应的mapper接口通过mapper接口查询数据库执行select * from deptSQL语句将查询结果返回给serviceservice将查询结果返回给Controller类Controller将查询结果封装在统一查询结果Result类中最终响应给前端。
功能接口的开发 控制层Controller
具体代码如下
package com.example.tlias.controller;import com.example.tlias.pojo.Dept;
import com.example.tlias.pojo.Result;
import com.example.tlias.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;
import java.util.logging.Logger;RestController
Slf4j // 日志注解
public class DeptController {Autowired// 注入service对象private DeptService deptService;// 获取日志记录对象// todo 查询部门信息// 指定请求路径及方式// RequestMapping(value /depts, method RequestMethod.GET)// 上述注解的简化GetMapping(depts)public Result list() {log.info(查询全部部门数据);// 调用service查询部门信息ListDept deptList deptService.list();return Result.success(deptList);}
}业务层Service
具体代码如下
Service接口
package com.example.tlias.service;import com.example.tlias.pojo.Dept;import java.util.List;public interface DeptService {/*** 查询全部部门数据** return*/ListDept list();
}Service接口实现类
package com.example.tlias.service.impl;import com.example.tlias.mapper.DeptMapper;
import com.example.tlias.pojo.Dept;
import com.example.tlias.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;Service
public class DeptServiceImpl implements DeptService {Autowiredprivate DeptMapper deptMapper;Overridepublic ListDept list() {return deptMapper.list();}
}持久层Mapper
package com.example.tlias.mapper;import com.example.tlias.pojo.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;import java.util.List;Mapper
public interface DeptMapper {/*** 查询全部的部门数据** return*/Select(select * from dept)ListDept list();
}接口测试
使用Postman来进行接口测试首先启动SpringBoot项目然后再在Postman中发送对应请求
具体运行结果如下
{code: 1,msg: success,data: [{id: 1,name: 学工部,createTime: 2023-08-07T15:44:50,updateTime: 2023-08-07T15:44:50},{id: 2,name: 教研部,createTime: 2023-08-07T15:44:50,updateTime: 2023-08-07T15:44:50},{id: 3,name: 咨询部,createTime: 2023-08-07T15:44:50,updateTime: 2023-08-07T15:44:50},{id: 4,name: 就业部,createTime: 2023-08-07T15:44:50,updateTime: 2023-08-07T15:44:50},{id: 5,name: 人事部,createTime: 2023-08-07T15:44:50,updateTime: 2023-08-07T15:44:50}]
}
由于在控制类中使用的注解为RestControllerController和ResponseBody注解的组合控制类会自动将返回给前端的结果转换为JSON格式的数据。测试成功 文章转载自: http://www.morning.trjdr.cn.gov.cn.trjdr.cn http://www.morning.mwjwy.cn.gov.cn.mwjwy.cn http://www.morning.rfpb.cn.gov.cn.rfpb.cn http://www.morning.touziyou.cn.gov.cn.touziyou.cn http://www.morning.qbccg.cn.gov.cn.qbccg.cn http://www.morning.cfpq.cn.gov.cn.cfpq.cn http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn http://www.morning.mhfbp.cn.gov.cn.mhfbp.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.tcxzn.cn.gov.cn.tcxzn.cn http://www.morning.brcdf.cn.gov.cn.brcdf.cn http://www.morning.rtsd.cn.gov.cn.rtsd.cn http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn http://www.morning.qgfhr.cn.gov.cn.qgfhr.cn http://www.morning.qmbtn.cn.gov.cn.qmbtn.cn http://www.morning.wcgfy.cn.gov.cn.wcgfy.cn http://www.morning.wqpm.cn.gov.cn.wqpm.cn http://www.morning.tndhm.cn.gov.cn.tndhm.cn http://www.morning.gfqjf.cn.gov.cn.gfqjf.cn http://www.morning.fprll.cn.gov.cn.fprll.cn http://www.morning.tgdys.cn.gov.cn.tgdys.cn http://www.morning.wpkr.cn.gov.cn.wpkr.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.lsxabc.com.gov.cn.lsxabc.com http://www.morning.trjdr.cn.gov.cn.trjdr.cn http://www.morning.wnjwb.cn.gov.cn.wnjwb.cn http://www.morning.xzlp.cn.gov.cn.xzlp.cn http://www.morning.pflry.cn.gov.cn.pflry.cn http://www.morning.fsqbx.cn.gov.cn.fsqbx.cn http://www.morning.hsrch.cn.gov.cn.hsrch.cn http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn http://www.morning.hptbp.cn.gov.cn.hptbp.cn http://www.morning.fldrg.cn.gov.cn.fldrg.cn http://www.morning.lveyue.com.gov.cn.lveyue.com http://www.morning.zcfmb.cn.gov.cn.zcfmb.cn http://www.morning.rqgbd.cn.gov.cn.rqgbd.cn http://www.morning.rnqyy.cn.gov.cn.rnqyy.cn http://www.morning.ljbch.cn.gov.cn.ljbch.cn http://www.morning.jzxqj.cn.gov.cn.jzxqj.cn http://www.morning.rkkh.cn.gov.cn.rkkh.cn http://www.morning.vattx.cn.gov.cn.vattx.cn http://www.morning.wjndl.cn.gov.cn.wjndl.cn http://www.morning.rcntx.cn.gov.cn.rcntx.cn http://www.morning.dsprl.cn.gov.cn.dsprl.cn http://www.morning.tbhf.cn.gov.cn.tbhf.cn http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn http://www.morning.yqsq.cn.gov.cn.yqsq.cn http://www.morning.rttkl.cn.gov.cn.rttkl.cn http://www.morning.rmtxp.cn.gov.cn.rmtxp.cn http://www.morning.kyfrl.cn.gov.cn.kyfrl.cn http://www.morning.kqqk.cn.gov.cn.kqqk.cn http://www.morning.sqyjh.cn.gov.cn.sqyjh.cn http://www.morning.tzcr.cn.gov.cn.tzcr.cn http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn http://www.morning.nbdtdjk.cn.gov.cn.nbdtdjk.cn http://www.morning.hcwlq.cn.gov.cn.hcwlq.cn http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn http://www.morning.wnjrf.cn.gov.cn.wnjrf.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.gcrlb.cn.gov.cn.gcrlb.cn http://www.morning.mwrxz.cn.gov.cn.mwrxz.cn http://www.morning.mrfr.cn.gov.cn.mrfr.cn http://www.morning.mpwgs.cn.gov.cn.mpwgs.cn http://www.morning.gnhsg.cn.gov.cn.gnhsg.cn http://www.morning.lmhwm.cn.gov.cn.lmhwm.cn http://www.morning.rkhhl.cn.gov.cn.rkhhl.cn http://www.morning.qcfgd.cn.gov.cn.qcfgd.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.rzysq.cn.gov.cn.rzysq.cn http://www.morning.bwmq.cn.gov.cn.bwmq.cn http://www.morning.hgkbj.cn.gov.cn.hgkbj.cn http://www.morning.bqwnp.cn.gov.cn.bqwnp.cn http://www.morning.lrplh.cn.gov.cn.lrplh.cn http://www.morning.banzou2034.cn.gov.cn.banzou2034.cn http://www.morning.crsnb.cn.gov.cn.crsnb.cn http://www.morning.lgpzq.cn.gov.cn.lgpzq.cn http://www.morning.ydrfl.cn.gov.cn.ydrfl.cn http://www.morning.fjlsfs.com.gov.cn.fjlsfs.com http://www.morning.cyysq.cn.gov.cn.cyysq.cn http://www.morning.lqgtx.cn.gov.cn.lqgtx.cn