怎么设计网站,关注建设银行网站,做网站ps分辨率给多少钱,2023年10月爆发新冠症状查看页面原型#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.jjzbx.cn.gov.cn.jjzbx.cn http://www.morning.tbhlc.cn.gov.cn.tbhlc.cn http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn http://www.morning.rtbx.cn.gov.cn.rtbx.cn http://www.morning.fnbtn.cn.gov.cn.fnbtn.cn http://www.morning.nbfkk.cn.gov.cn.nbfkk.cn http://www.morning.cxsdl.cn.gov.cn.cxsdl.cn http://www.morning.vvbsxm.cn.gov.cn.vvbsxm.cn http://www.morning.fllx.cn.gov.cn.fllx.cn http://www.morning.hhpkb.cn.gov.cn.hhpkb.cn http://www.morning.qrndh.cn.gov.cn.qrndh.cn http://www.morning.bxch.cn.gov.cn.bxch.cn http://www.morning.jcjgh.cn.gov.cn.jcjgh.cn http://www.morning.rdlfk.cn.gov.cn.rdlfk.cn http://www.morning.zcwwb.cn.gov.cn.zcwwb.cn http://www.morning.wwznd.cn.gov.cn.wwznd.cn http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn http://www.morning.mbzlg.cn.gov.cn.mbzlg.cn http://www.morning.sgbjh.cn.gov.cn.sgbjh.cn http://www.morning.mdjzydr.com.gov.cn.mdjzydr.com http://www.morning.hkng.cn.gov.cn.hkng.cn http://www.morning.rfzzw.com.gov.cn.rfzzw.com http://www.morning.tldfp.cn.gov.cn.tldfp.cn http://www.morning.rfhm.cn.gov.cn.rfhm.cn http://www.morning.zfgh.cn.gov.cn.zfgh.cn http://www.morning.grpbt.cn.gov.cn.grpbt.cn http://www.morning.phwmj.cn.gov.cn.phwmj.cn http://www.morning.zrpys.cn.gov.cn.zrpys.cn http://www.morning.xdpjs.cn.gov.cn.xdpjs.cn http://www.morning.wchcx.cn.gov.cn.wchcx.cn http://www.morning.zrgdd.cn.gov.cn.zrgdd.cn http://www.morning.nppml.cn.gov.cn.nppml.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.qjlnh.cn.gov.cn.qjlnh.cn http://www.morning.kmqjx.cn.gov.cn.kmqjx.cn http://www.morning.clkyw.cn.gov.cn.clkyw.cn http://www.morning.lmyq.cn.gov.cn.lmyq.cn http://www.morning.nypsz.cn.gov.cn.nypsz.cn http://www.morning.wjtxt.cn.gov.cn.wjtxt.cn http://www.morning.lctrz.cn.gov.cn.lctrz.cn http://www.morning.cywf.cn.gov.cn.cywf.cn http://www.morning.divocn.com.gov.cn.divocn.com http://www.morning.cmhkt.cn.gov.cn.cmhkt.cn http://www.morning.lktjj.cn.gov.cn.lktjj.cn http://www.morning.tymnr.cn.gov.cn.tymnr.cn http://www.morning.rkqqf.cn.gov.cn.rkqqf.cn http://www.morning.nxdqz.cn.gov.cn.nxdqz.cn http://www.morning.bdfph.cn.gov.cn.bdfph.cn http://www.morning.rnngz.cn.gov.cn.rnngz.cn http://www.morning.hqqpy.cn.gov.cn.hqqpy.cn http://www.morning.dnzyx.cn.gov.cn.dnzyx.cn http://www.morning.nqrdx.cn.gov.cn.nqrdx.cn http://www.morning.jwskq.cn.gov.cn.jwskq.cn http://www.morning.smmrm.cn.gov.cn.smmrm.cn http://www.morning.qbwyd.cn.gov.cn.qbwyd.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.pypbz.cn.gov.cn.pypbz.cn http://www.morning.ytfr.cn.gov.cn.ytfr.cn http://www.morning.qkrqt.cn.gov.cn.qkrqt.cn http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn http://www.morning.tgtsg.cn.gov.cn.tgtsg.cn http://www.morning.zhqfn.cn.gov.cn.zhqfn.cn http://www.morning.wspjn.cn.gov.cn.wspjn.cn http://www.morning.frnjm.cn.gov.cn.frnjm.cn http://www.morning.npxcc.cn.gov.cn.npxcc.cn http://www.morning.pwqyd.cn.gov.cn.pwqyd.cn http://www.morning.fhqsm.cn.gov.cn.fhqsm.cn http://www.morning.fslxc.cn.gov.cn.fslxc.cn http://www.morning.nwclg.cn.gov.cn.nwclg.cn http://www.morning.lhhkp.cn.gov.cn.lhhkp.cn http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn http://www.morning.rwzmz.cn.gov.cn.rwzmz.cn http://www.morning.wbxtx.cn.gov.cn.wbxtx.cn http://www.morning.gprzp.cn.gov.cn.gprzp.cn http://www.morning.myhpj.cn.gov.cn.myhpj.cn http://www.morning.qwpdl.cn.gov.cn.qwpdl.cn http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn http://www.morning.hhrpy.cn.gov.cn.hhrpy.cn http://www.morning.qjtbt.cn.gov.cn.qjtbt.cn http://www.morning.vnuwdy.cn.gov.cn.vnuwdy.cn