package com.yy.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.Quarter;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yy.dao.TestUserDao;
import com.yy.enums.ResponseEnum;
import com.yy.pojo.TestUser;
import com.yy.service.Impl.TestUserServiceImpl;
import com.yy.service.TestUserService;
import com.yy.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author young
* @date 2022/8/26 9:36
* @description:
*/
@Slf4j
@RestController
@RequestMapping("/mysql")
public class TestUserController {
private static final DateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private TestUserServiceImpl testUserService;
@Autowired
private TestUserDao Mapper;
/* 自主测试 */
@GetMapping("/test/{id}")
public R<Boolean> test(@PathVariable Integer id){
return R.ok(testUserService.tests(id));
}
/**
* 增加一个test用户
*
* @param testUser
* @return
*/
@PostMapping("/addOne")
public R<Boolean> addUser(TestUser testUser) {
boolean save = testUserService.save(testUser);
return R.ok(save);
}
/**
* 批量添加test用户
*
* @param
* @return
*/
@PostMapping("/addMore")
public R<Boolean> addBatch() {
List<TestUser> list = new ArrayList<>();
TestUser user1 = new TestUser("黎治跃", true, "韩家墩五号", new Date());
TestUser user2 = new TestUser("李帅", false, "李家墩号", new Date());
TestUser user3 = new TestUser("刘超琪", false, "刘家墩五号", new Date());
TestUser user4 = new TestUser("刘亮", true, "刘家墩号", new Date());
list.add(user1);
list.add(user2);
list.add(user3);
list.add(user4);
boolean b = testUserService.saveBatch(list);
return R.ok(b);
}
/**
* 通过删除一个用户
*
* @param id
* @return
*/
@DeleteMapping("/deleteOne/{id}")
public R<Boolean> removeUser(@PathVariable Integer id) {
boolean remove = testUserService.removeById(id);
return R.ok(remove);
}
/**
* 批量删除指定id的数据
*
* @param
* @return
*/
@DeleteMapping("/deleteMore/{ids}")
public R<Boolean> deleteBatch(@PathVariable("ids") Integer... ids) {
List<Integer> list = Arrays.asList(ids);
boolean batch = testUserService.removeBatchByIds(list);
return R.ok(batch);
}
/**
* 更新指定id的信息
*
* @param id
* @return
*/
@PostMapping("/updateOne/{id}")
public R<Boolean> updateOne(@RequestParam Integer id) {
TestUser user = new TestUser(id);
user.setName("张三").setSex(false).setAddress("北京朝阳路5号").setCreateTime(new Date());
boolean b = testUserService.updateById(user);
return R.ok(b);
}
/**
* 查找指定id信息
*
* @param id
* @return
*/
@GetMapping("/getOne/{id}")
public R<TestUser> selectOne(@PathVariable Integer id) {
TestUser user = testUserService.getById(id);
return R.ok(user);
}
/**
* 返回所有数据
*
* @return
*/
@GetMapping("/getAll")
public R<List<TestUser>> getAll() {
return R.ok(testUserService.list());
}
/**
* 查找多条消息
*
* @param ids
* @return
*/
@GetMapping("/getMore/{ids}")
public R<List<TestUser>> selectMore(@PathVariable Integer... ids) {
List<TestUser> testUsers = testUserService.listByIds(Arrays.asList(ids));
return R.ok(testUsers);
}
/**
* 查询name中包含inName,sex为inSex的信息,并只返回id,name,sex
*
* @param inName 输入的name
* @param inSex 输入的sex
* @return
*/
@GetMapping("/likeSelect/{num}/{sex}")
public R<List<TestUser>> likeSelect(@PathVariable("num") Integer inName, @PathVariable("sex") Boolean inSex) {
QueryWrapper<TestUser> wrapper = new QueryWrapper<>();
wrapper.select("id", "name", "sex").like("name", inName).in("sex", inSex);
List<TestUser> list = testUserService.list(wrapper);
return R.ok(list);
}
/**
* 返回地址中包含的数字并且输入id大于一定数或者createTime为空的数据
*
* @param inId 指定id
* @param address 地址包含的数
* @return
*/
@GetMapping("getLike/{id}/{num}")
public R<List<TestUser>> getLike(@PathVariable("id") Integer inId, @PathVariable("num") Integer address) {
QueryWrapper<TestUser> wrapper = new QueryWrapper<>();
wrapper.like("address", address).and(wq -> wq.isNull("createTime").or().ge("id", inId));
return R.ok(testUserService.list(wrapper));
}
/**
* 多条件匹配
*
* @param objName 输入指定的名字
* @param sex 输入指定的性别
* @return
*/
@GetMapping("/AllEq/{name}/{sex}")
public R<List<TestUser>> allEq(@PathVariable("name") Object objName, @PathVariable("sex") Boolean sex) {
QueryWrapper<TestUser> wrapper = new QueryWrapper<>();
Map<String, Object> map = new HashMap<>();
map.put("name", objName);
map.put("sex", sex);
wrapper.allEq(map);
return R.ok(testUserService.list(wrapper));
}
/**
* 把查询条件按map形式展现出来
*
* @param mName 输入指定的名字
* @param mSex 输入指定的性别
* @return
*/
@GetMapping("/map/{name}/{sex}")
public R<List<Map<String, Object>>> map(@PathVariable("name") Object mName, @PathVariable("sex") Boolean mSex) {
QueryWrapper<TestUser> wrapper = new QueryWrapper<>();
wrapper.like("name", mName).in("sex", mSex);
System.out.println("maps测试如下:" + "\n");
List<Map<String, Object>> maps = testUserService.listMaps(wrapper);
maps.forEach(System.out::println);
return R.ok(maps);
}
/**
* objs测试
* @param name
* @param address
* @return 符合条件的id集合
*/
@GetMapping("/objs/{name}/{address}")
public R<List<Object>> objs(@PathVariable("name") Object name, @PathVariable("address") Object address) {
QueryWrapper<TestUser> wrapper = new QueryWrapper<>();
wrapper.like("name", name).like("address", address);
System.out.println("objs测试如下:" + "\n");
List<Object> objects = testUserService.listObjs(wrapper);
objects.forEach(System.out::println);
return R.ok(objects);
}
/**
* lambda测试
*
* @param sex 指定性别
* @param address 指定地址
* @return
*/
@GetMapping("/lambda/{sex}/{address}")
public R<List<TestUser>> lambdaTest(@PathVariable Boolean sex, @PathVariable Object address) {
Lambd
没有合适的资源?快使用搜索试试~ 我知道了~
springboot整合其他技术栈(redis缓存,mongodb,exsyexcel,Mybatis-plus)
共489个文件
xml:177个
class:43个
java:42个
需积分: 13 0 下载量 190 浏览量
2022-09-17
09:34:34
上传
评论
收藏 57.51MB ZIP 举报
温馨提示
在这个项目中简单实现了springboot对redis缓存,Mybatis-Plus,mongodb等数据库相关的技术点,实现数据获取,可以直接在以后的项目中仿照使用。并且整合了exsyexcel等数据文件导入导出功能,后续会继续汇总整合一些其他业务技术功能的测试,加强技术集成实践水平。
资源详情
资源评论
资源推荐
收起资源包目录
springboot整合其他技术栈(redis缓存,mongodb,exsyexcel,Mybatis-plus) (489个子文件)
0087a1694dbfdcd6bad8820e3dfd1bff066820a6 255B
010854dfefedaff48b8a8d6e468d5daadb31b7 107B
02c55ec0afd29bb62a8347d3beaf4a5f6a61a4f8 179B
036d051f34e66fd7878b8da0fdff9e3cada38091 88B
038df2113841534aba98792c7b7e40179a5e9f 469B
0451b49e5b878d59c6a7dfb4b802401bda77a8 61B
09ef08342f945a9bb93b11a9ed823be778e32a 575B
0a4907929046c10c48f1b3aa8533e7b350d5ffaf 0B
0aa9c4f62c47edec6090dc349495de63f583c3 231B
0b116baa8fb145bb518c722daef1416295b021 350B
0b6020ddb0c8349c0a015156eaad0b8573f8a8 1KB
0dab5c3ba82aba4c1ef016217bcef287525474 181B
0ed0ffcecfea156f8b825f1825bdaa974b44df 235B
1270e6589aec9921bb3b4a1eccec5a76809393 1KB
1713a249563465ba2f04dd2e55b979eef0be85 636B
17d9de45fdfd1f2316b7b281e865e57c768127ef 87B
1a273f73b7a477b0745593641bd708a6182c7ad5 0B
1a86ed918a73cc64fd33b0fcc735c844955ffe 45B
1ae32efc9613723bdf81df6ac88d42ecaaed41 91B
1b62bbdb6f40bec719c0078aa79db005c372ab 80B
1d5fd9b8be3079a72ddf3c038f070834afc3d8 312B
1dfc4f1ae3438e1a0b48fe0a78d1aff4a44ecb 45B
1eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 4KB
1fa4eb00eb56e06f1d6e64c20c285fa37f0fc39e 69B
1fd4b031d52bfb639ff99d6bc05d48a540fce5 161B
207c20b322c1383160c8a308c1cd674b2bf94a 167B
21a8c05dd3ba5018400f32195640d1e9ae3774 61B
2257ce8620896635732b4fb34f5fabb60dfa4d 656B
23b7bf8801c4a7ffa2b173322697fb86eddaa335 272B
24387610ae4e8648b9dac19dc3c103d95eeee43b 177B
249cd9ab0116c22f93242575396d81c008eec1aa 79B
259742898d83801f51379ba82fdec20254a5ac 44B
2862dc0af05eb156a805f9434fdcaddd24b420fd 812B
2c0dcdef3d886cbbc1c96e23f00d981dc00e26 79B
2d572ce90e5085986bdd9c9204b9404f028084 130B
2d6f859f84cd428ac84b96182a1d879bcaa6f2 79B
2f10346f81ac08e2b54c502bca8bae15bd8d0c 74B
2f1924e3cea418edadc25da328e8e823b1a786 79B
2fe84069c61af1db9c85a4d9d7b153973d2882 3KB
310640de4bd4bf4e61b36c2bcdaf6df2d86b6a 1KB
32a9af630e69d13e0bb51fad4f41ab15475b67 373B
39ed8901f4fb951eef7bf89c1a03b2f8646409 500B
3e6e25f7c0b2ab3e5c2ea2089c2c3eb27297ed 1KB
3eaf4797eb49b86f2999910e6b7c6d4d9d8747 581B
42af7924dc9fb08d8bc351b25e4f1cc2762c64 330B
43aba12a509ad281d3584fd27accbf358076c2 45B
442292b8a7efeabbe4cc176709b833b1792140ec 0B
44b1a0064a4e82a930daea0df5c92b9ec57650c9 2KB
44c2647da88194ee82c8830d1d9f405fce0284 61B
469f1bb006fe8b9c7e213c4726fe31dcb45fa8 206B
49689faefa1f01d67cb21ac75e8bf9215d3968 161B
4b09230bc34bf35520108a5b0662a47a17b6dd12 565B
4ffa9a511c713fb980620385746b48dee89079 219B
52fa8eb2aca8d5db5ad1947edeccff967a81ff 233B
5360fc6217821d46d0c127083ee4d4af489535 330B
554b0fc7ee4a66cc79b99896b15162404eed78b2 85B
558d7855f411a16f1b333b3c517f081b313862 255B
5d0f7b90470cf084a55e551dadf2690c5f3b5595 226B
5e09ff1873dafb7a769afb579713373143a53f 80B
5eb6ba269cd38f8965cef786729790945d9537 2KB
617a648ada2eeddff34528777c2e3de869d3c3 4KB
61d1038e7e36965d22eaf8156ad33b3dd02a85 330B
692ff6b86196b998689090296e2c4e8dd62e89 127B
6991ff90976e064087792b2446230b77bc6c11 803B
6b25a937987e0243bcdc7f355fbd92edaf0f1e 245B
6b5431b4c3cab50323a3f558003fd0abd87dad 3KB
6bb91ccceecda7fbf001afbb51dfca364f9b8d 215B
6cda469f252cbb6828e70c043d4c681d5df718 133B
70531ceea0cb3f68b6ce4cbc9d7d6687ff2e36 126B
70fe2891ad3ddc8cb37bd90c157ffb0896d6f6 171B
73d19ebf3a729d0297e8cd3dcf3660cae21367dc 290B
74cbff41cc0b0827f3f52712e8da79799ca917 251B
7a223f2d1568bb8849a56ca14b44329657a33f 264B
7a8e8405443a059504a4a7e6c1058fc55ce77e 917B
7b597cf69045f362d14cb7d8fe9ebe5da63f2f 45B
7d3c4f32a109d06597d8911d84d58e406dd60e 766B
7dbdeae0d371ce7570eca11f945e829dbce48f3b 374B
805fb723ec7b192125212c3540dc7fbd176bde 160B
80b0867b54ec70dcb91b540dbe85d65224f5b9 47B
83d2512c389c38087bf37724ff99360afae243af 271B
84bc18ca7a80483a020730d39e317c394773b3 963B
84ded4c5c2391d864ce12c0227d89bc7f52613 1KB
860cd5b030a3e99085058d66938e2568b017ff 568B
865ca311e0a777bc46c36b68061ad65f30728d83 276B
8a2e39e85f06d17478f212fa5b3f672a132a55ab 118B
8a9609c973031e8e57119e2f50b32c6fb15f5b 121B
8c123bf129c8627b99a1d8c5aacd70c7540ecb23 683B
8caccaf2cc2a8c09ccac0f7ceaaa4d56f1c320 374B
8d4eabe92cef351040b72d7cf02c524d0cb4f2 802B
8e1a994f8684991415c6b81c9b6bc7db66867475 899B
8f1a5ffd913c1eef2b4476428631eebf64f4d5 681B
903fe10c11902e9153e8ac3776eb505a7d1e2e 44B
953ba2725988b2c81355240176956ed0a99e1d 545B
9716c4a196087ec3d908bab72f634385669853 258B
974206a0a79fd361c90ddf229ed7f240daaeb5 359B
97b5fefaf27615c14ff5231cee3788f8eae404 935B
97fa7c7301985a9901ccc7a28430da83cc1f8b 178B
98e207c0e56d34bab8ce7d1f828499df2086dcc5 207B
9a11b6b694cf07db3703c2f5ad5de68a3d5169 935B
9abc6c7b7287958fe7e6ead346f57789bc69e5 131B
共 489 条
- 1
- 2
- 3
- 4
- 5
深情不及里子
- 粉丝: 373
- 资源: 31
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0