package com.example.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.ZufanghetongInfo;
import com.example.dao.ZufanghetongInfoDao;
import com.example.service.ZufanghetongInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.ZufanghetongInfoVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.example.service.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/zufanghetongInfo")
public class ZufanghetongInfoController {
@Resource
private ZufanghetongInfoService zufanghetongInfoService;
@Resource
private ZufanghetongInfoDao zufanghetongInfoDao;
@PostMapping
public Result<ZufanghetongInfo> add(@RequestBody ZufanghetongInfoVo zufanghetongInfo) {
//mixmajixami
zufanghetongInfoService.add(zufanghetongInfo);
return Result.success(zufanghetongInfo);
}
//youtixing1
//youtixing2
@GetMapping("/getByDiqu")
public Result<List<Map<String,String>>> qidu() {
return Result.success(zufanghetongInfoService.findByDiqu());
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
zufanghetongInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody ZufanghetongInfoVo zufanghetongInfo) {
zufanghetongInfoService.update(zufanghetongInfo);
return Result.success();
}
//@PutMapping("/update2")
// public Result update2(@RequestBody ZufanghetongInfoVo zufanghetongInfo) {
// zufanghetongInfoService.update2(zufanghetongInfo);
// return Result.success();
// }
@GetMapping("/{id}")
public Result<ZufanghetongInfo> detail(@PathVariable Long id) {
ZufanghetongInfo zufanghetongInfo = zufanghetongInfoService.findById(id);
return Result.success(zufanghetongInfo);
}
@GetMapping("/changeStatus/{id}")
public Result<ZufanghetongInfo> changeStatus(@PathVariable Long id) {
zufanghetongInfoService.changeStatus(id);
return Result.success();
}
@GetMapping
public Result<List<ZufanghetongInfoVo>> all() {
return Result.success(zufanghetongInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<ZufanghetongInfoVo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(zufanghetongInfoService.findPage(name, pageNum, pageSize, request));
}
@GetMapping("/pageqt/{name}")
public Result<PageInfo<ZufanghetongInfoVo>> pageqt(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize,
HttpServletRequest request) {
return Result.success(zufanghetongInfoService.findPageqt(name, pageNum, pageSize, request));
}
// @PostMapping("/register")
// public Result<ZufanghetongInfo> register(@RequestBody ZufanghetongInfo zufanghetongInfo) {
// if (StrUtil.isBlank(zufanghetongInfo.getName()) || StrUtil.isBlank(zufanghetongInfo.getPassword())) {
// throw new CustomException(ResultCode.PARAM_ERROR);
// }
// return Result.success(zufanghetongInfoService.add(zufanghetongInfo));
// }
/**
* 批量通过excel添加信息
* @param file excel文件
* @throws IOException
*/
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
List<ZufanghetongInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(ZufanghetongInfo.class);
if (!CollectionUtil.isEmpty(infoList)) {
// 处理一下空数据
List<ZufanghetongInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getZujinjiezhiriqi())).collect(Collectors.toList());
for (ZufanghetongInfo info : resultList) {
zufanghetongInfoService.add(info);
}
}
return Result.success();
}
//yoxutonxgjitu
@GetMapping("/getExcelModel")
public void getExcelModel(HttpServletResponse response) throws IOException {
// 1. 生成excel
Map<String, Object> row = new LinkedHashMap<>();
row.put("fangwubianhao", "A房屋编号");
row.put("xiangxidizhi", "A详细地址");
row.put("chuzufangxingming", "A出租方姓名");
row.put("chuzufangzhengjianhao", "A出租方证件号");
row.put("yonghuming", "A用户名");
row.put("chengzufangxingming", "A承租方姓名");
row.put("qizushijian", "A起租时间");
row.put("tuizushijian", "A退租时间");
row.put("meiyuezujin", "A每月租金");
row.put("zujinjiezhiriqi", "A租金截至日期");
row.put("status", "是");
row.put("level", "zufanghetong");
List<Map<String, Object>> list = CollUtil.newArrayList(row);
// 2. 写excel
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(list, true);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename=zufanghetongInfoModel.xlsx");
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
writer.close();
IoUtil.close(System.out);
}
@GetMapping("/getExcel")
public void getExcel(HttpServletResponse response) throws IOException {
// 1. 生成excel
Map<String, Object> row = new LinkedHashMap<>();
row.put("fangwubianhao", "A房屋编号");
row.put("xiangxidizhi", "A详细地址");
row.put("chuzufangxingming", "A出租方姓名");
row.put("chuzufangzhengjianhao", "A出租方证件号");
row.put("yonghuming", "A用户名");
row.put("chengzufangxingming", "A承租方姓名");
row.put("qizushijian", "A起租时间");
row.put("tuizushijian", "A退租时间");
row.put("meiyuezujin", "A每月租金");
row.put("zujinjiezhiriqi", "A租金截至日期");
row.put("status", "是");
row.put("level", "权限");
List<Map<String, Object>> list = CollUtil.newArrayList(row);
List<Map<String, Object>> daochuexcellist = zufanghetongInfoDao.daochuexcel();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : daochuexcellist) {
list.add(map);
}
// 2. 写excel
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(list, true);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java项目实战,Java项目开发实例,基于springboot的毕设 【项目技术】 java+mysql+b/s+springboot 【实现功能】 分为前台和后台管理者。 后台: 系统用户管理,新闻数据管理,用户管理,房东管理,租房合同管理,下载中心管理,房源管理。 前台:用户,房源信息,下载中心,房产新闻,房东。
资源推荐
资源详情
资源评论
收起资源包目录
Java毕业设计-基于springboot的房源出租信息系统(源码+演示视频).zip (913个子文件)
alipay_md5.asp 11KB
alipay_md5.asp 11KB
alipay_function.asp 6KB
alipay_function.asp 6KB
alipay_notify.asp 5KB
alipay_notify.asp 5KB
alipay_service.asp 2KB
alipay_service.asp 2KB
bootstrap-responsiv 16KB
bootstrap-responsiv 16KB
datepicker.c 4KB
datepicker.c 4KB
ShenqingzufangInfoController.class 13KB
ZufanghetongInfoController.class 13KB
FangyuanxinxiInfoController.class 13KB
XinwentongzhiInfoController.class 13KB
FangdongInfoController.class 13KB
YonghuInfoController.class 13KB
XiazaizhongxinInfoController.class 13KB
XitongjianjieInfoController.class 12KB
YonghuxinxiInfoController.class 12KB
LiuyanbanInfoController.class 12KB
AccountController.class 11KB
AdminInfoController.class 9KB
NxSystemFileController.class 8KB
FangdongInfoService.class 6KB
YonghuInfoService.class 6KB
EchartsController.class 5KB
YonghuxinxiInfoService.class 5KB
XinwentongzhiInfoService.class 5KB
XiazaizhongxinInfoService.class 5KB
AdminInfoService.class 5KB
FangyuanxinxiInfoService.class 5KB
CommentInfoService.class 4KB
ShenqingzufangInfoService.class 4KB
AdminInfo.class 4KB
ZufanghetongInfoService.class 4KB
FangyuanxinxiInfo.class 4KB
YonghuxinxiInfo.class 4KB
XitongjianjieInfoService.class 4KB
XinwentongzhiInfo.class 4KB
FangdongInfo.class 4KB
YonghuInfo.class 4KB
CollectInfoController.class 4KB
ZufanghetongInfo.class 4KB
LiuyanbanInfoService.class 4KB
CommentInfoController.class 4KB
RichtextInfoController.class 3KB
ShenqingzufangInfo.class 3KB
CollectInfoService.class 3KB
RichtextInfoService.class 3KB
XiazaizhongxinInfo.class 3KB
NxSystemFileInfoService.class 3KB
LiuyanbanInfo.class 3KB
CollectInfo.class 3KB
CommentInfo.class 3KB
Account.class 3KB
Result.class 2KB
EchartsData.class 2KB
ResultCode.class 2KB
MyInterceptor.class 2KB
XitongjianjieInfo.class 2KB
ZufanghetongInfoDao.class 2KB
ShenqingzufangInfoDao.class 2KB
XiazaizhongxinInfoDao.class 2KB
FangyuanxinxiInfoDao.class 2KB
GlobalExceptionHandler.class 2KB
XinwentongzhiInfoDao.class 2KB
FangdongInfoDao.class 2KB
EchartsData$Data.class 2KB
YonghuInfoDao.class 2KB
WebMvcConfig.class 2KB
CommentInfoDao.class 1KB
EchartsData$Series.class 1KB
MyInterceptorConfig.class 1KB
AuthorityInfo.class 1KB
NxSystemFileInfo.class 1KB
CollectInfoDao.class 1KB
RichtextInfo.class 1KB
LiuyanbanInfoDao.class 1KB
YonghuxinxiInfoDao.class 1KB
AuthorityInfo$Model.class 1KB
CustomException.class 1KB
XitongjianjieInfoDao.class 1KB
AdminInfoDao.class 928B
Application.class 793B
NxSystemFileInfoDao.class 773B
RichtextInfoDao.class 641B
ShenqingzufangInfoVo.class 336B
XiazaizhongxinInfoVo.class 336B
XitongjianjieInfoVo.class 332B
XinwentongzhiInfoVo.class 332B
FangyuanxinxiInfoVo.class 332B
ZufanghetongInfoVo.class 328B
YonghuxinxiInfoVo.class 324B
LiuyanbanInfoVo.class 316B
FangdongInfoVo.class 312B
RichtextInfoVo.class 312B
CollectInfoVo.class 308B
YonghuInfoVo.class 304B
共 913 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
岛上程序猿
- 粉丝: 2266
- 资源: 4154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功