当前位置:网站首页>internship:逐渐迈向项目开发
internship:逐渐迈向项目开发
2022-07-01 19:00:00 【ahyo】
之前写的接口只是用于返回json格式数据,一开始不会去参与正式的项目编写代码,而是负责人会发一些文本具体内容就是json格式数据,先以集合框架来编写。之后在理解了一定的业务逻辑后编写接口实现数据回显,进一步再把之前用map list等集合框架实现的,封装成类其中需要加上swagger之类的注解,也即今天所需要做的。
经过几次的试错,逐渐把整个给参考的项目代码深入了解,具体的springboot在干什么以及MyBatis-Plus的便捷之处,以及建立在MyBatis使用基础之上如何的理解MyBatis-Plus的运作机制。以及整个项目所看见的实体类,一部分是依据数据库表建立的,一部分是word文档或者Excel表提取到的。当然这里给的是json格式数据文本,直接转实体类即可,蛮好的工具集成网站。分清Json格式数据的花括号和中括号 所代表的意思,是整个类包含了其他实体类的实例化 还是分开的单独实体类。
较之前的map写的 改为实体类来实现:
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class ModuleDemoInfo {
@ApiModelProperty(value = "xaxis")
private List<Integer> xaxis;
private Yaxis1 yaxis=new Yaxis1();
private Yaxis1 yaxis11=new Yaxis1();
private Yaxis1 yaxis12=new Yaxis1();
@ApiModelProperty(value = "yaxis1")
private List<Yaxis1> yaxis1;
@ApiModelProperty(value = "yaxis2")
private List yaxis2;
public ModuleDemoInfo()
{
}
@Data
@Accessors(chain = true)
public class Yaxis1
{
@ApiModelProperty(value = "ybgg")
private double ybgg;
@ApiModelProperty(value = "zfxjj")
private double zfxjj;
@ApiModelProperty(value = "gyzcjy")
private double gyzcjy;
@ApiModelProperty(value = "shbzjj")
private double shbzjj;
@ApiModelProperty(value = "total")
private double total;
public Yaxis1()
{
}
}
}
service接口实现类:
@Override
public List<ModuleDemoInfo> arg2() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
List<ModuleDemoInfo> list=new ArrayList<>();
List<Integer> intList=new ArrayList<>();
ModuleDemoInfo moduleDemoInfo=new ModuleDemoInfo();
List list1=new ArrayList();
moduleDemoInfo.getYaxis().setGyzcjy(0.29);
moduleDemoInfo.getYaxis().setZfxjj(1404.3);
moduleDemoInfo.getYaxis().setShbzjj(0.0);
moduleDemoInfo.getYaxis().setYbgg(137631.17);
moduleDemoInfo.getYaxis().setTotal(139035.76);
moduleDemoInfo.getYaxis11().setGyzcjy(0.0);
moduleDemoInfo.getYaxis11().setZfxjj(0.0);
moduleDemoInfo.getYaxis11().setShbzjj(0.0);
moduleDemoInfo.getYaxis11().setYbgg(0.0);
moduleDemoInfo.getYaxis11().setTotal(0.0);
moduleDemoInfo.getYaxis12().setGyzcjy(0.0);
moduleDemoInfo.getYaxis12().setZfxjj(0.0);
moduleDemoInfo.getYaxis12().setShbzjj(0.0);
moduleDemoInfo.getYaxis12().setYbgg(0.0);
moduleDemoInfo.getYaxis12().setTotal(0.0);
list1.add(moduleDemoInfo.getYaxis());
list1.add( moduleDemoInfo.getYaxis11());
list1.add(moduleDemoInfo.getYaxis12());
intList.add(2022);
intList.add(2021);
intList.add(2020);
moduleDemoInfo.setXaxis(intList);
moduleDemoInfo.setYaxis1(list1);
moduleDemoInfo.setYaxis2(list1);
list.add(moduleDemoInfo);
return list;
}
接口:
@RequestMapping("/Demo")
@RestController
@Api(tags = "demo 1/2")
@Validated
@Slf4j
public class DemoController {
@Resource
private DemoService demoService;
@RequestMapping(value = "/arg1",method = RequestMethod.GET)
@ApiOperation(value = "详细坐标参数")
@ApiOperationSupport(order=2)
public ResponseData<List<ModuleDemoInfo>> listResponseData() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
return new ResponseData<>(demoService.arg2());
}
}
边栏推荐
- STC 32-bit 8051 single chip microcomputer development example tutorial three program compilation setting and download
- list分割成满足和不满足条件的集合(partitioningBy)
- Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?
- GC garbage collection
- ORA-01950
- Realize pyramids through JS (asterisk pyramid, palindrome symmetric digital pyramid)
- [C language] explain the usage of memset() function in detail
- 渗透工具-TrustedSec 公司的渗透测试框架 (PTF)
- [untitled]
- The large list set is divided into multiple small list sets in equal proportion
猜你喜欢
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road
3D全景模型展示可视化技术演示
RichView TRVDocParameters 页面参数设置
Class loading mechanism
Simple but modern server dashboard dashdot
Use Zadig to build a continuous delivery platform from 0 to 1
Object creation
Flask 常用组件
优质笔记软件综合评测和详细盘点(一) Notion、Obsidian、RemNote、FlowUs
基于图的 Affinity Propagation 聚类计算公式详解和代码示例
随机推荐
list分割成满足和不满足条件的集合(partitioningBy)
牛客编程题--必刷101之字符串(高效刷题,举一反三)
A quietly rising domestic software, low-key and powerful!
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
3D panoramic model display visualization technology demonstration
强大、好用、适合程序员/软件开发者的专业编辑器/笔记软件综合评测和全面推荐
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
[AI server setup] CUDA environment
数据分析师听起来很高大上?了解这几点你再决定是否转型
How can a programmer grow rapidly
上大学后明白了哪些坑人的事?
Modsim basic use (Modbus simulator)
PowerDesigner design name and comment replacement
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
list大集合等比分割成多个小list集合
math_利用微分算近似值
Hls4ml/vivado HLS error reporting solution
Unreal Engine packaging project
What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
Anaconda installs the virtual environment to the specified path