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.YimaishangpinInfo;
import com.example.dao.YimaishangpinInfoDao;
import com.example.service.YimaishangpinInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.YimaishangpinInfoVo;
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 = "/yimaishangpinInfo")
public class YimaishangpinInfoController {
@Resource
private YimaishangpinInfoService yimaishangpinInfoService;
@Resource
private YimaishangpinInfoDao yimaishangpinInfoDao;
@PostMapping
public Result<YimaishangpinInfo> add(@RequestBody YimaishangpinInfoVo yimaishangpinInfo) {
//mixmajixami
yimaishangpinInfoService.add(yimaishangpinInfo);
return Result.success(yimaishangpinInfo);
}
@GetMapping("/tixing")
public Result<Integer> tixing() { Integer count = yimaishangpinInfoService.tixing(); return Result.success(count); }
@GetMapping("/getByDiqu")
public Result<List<Map<String,String>>> qidu() {
return Result.success(yimaishangpinInfoService.findByDiqu());
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
yimaishangpinInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody YimaishangpinInfoVo yimaishangpinInfo) {
yimaishangpinInfoService.update(yimaishangpinInfo);
return Result.success();
}
//@PutMapping("/update2")
// public Result update2(@RequestBody YimaishangpinInfoVo yimaishangpinInfo) {
// yimaishangpinInfoService.update2(yimaishangpinInfo);
// return Result.success();
// }
@GetMapping("/{id}")
public Result<YimaishangpinInfo> detail(@PathVariable Long id) {
YimaishangpinInfo yimaishangpinInfo = yimaishangpinInfoService.findById(id);
return Result.success(yimaishangpinInfo);
}
@GetMapping("/changeStatus/{id}")
public Result<YimaishangpinInfo> changeStatus(@PathVariable Long id) {
yimaishangpinInfoService.changeStatus(id);
return Result.success();
}
@GetMapping
public Result<List<YimaishangpinInfoVo>> all() {
return Result.success(yimaishangpinInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<YimaishangpinInfoVo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(yimaishangpinInfoService.findPage(name, pageNum, pageSize, request));
}
@GetMapping("/pageqt/{name}")
public Result<PageInfo<YimaishangpinInfoVo>> pageqt(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize,
HttpServletRequest request) {
return Result.success(yimaishangpinInfoService.findPageqt(name, pageNum, pageSize, request));
}
// @PostMapping("/register")
// public Result<YimaishangpinInfo> register(@RequestBody YimaishangpinInfo yimaishangpinInfo) {
// if (StrUtil.isBlank(yimaishangpinInfo.getName()) || StrUtil.isBlank(yimaishangpinInfo.getPassword())) {
// throw new CustomException(ResultCode.PARAM_ERROR);
// }
// return Result.success(yimaishangpinInfoService.add(yimaishangpinInfo));
// }
/**
* 批量通过excel添加信息
* @param file excel文件
* @throws IOException
*/
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
List<YimaishangpinInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(YimaishangpinInfo.class);
if (!CollectionUtil.isEmpty(infoList)) {
// 处理一下空数据
List<YimaishangpinInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getShangpinbianhao())).collect(Collectors.toList());
for (YimaishangpinInfo info : resultList) {
yimaishangpinInfoService.add(info);
}
}
return Result.success();
}
@GetMapping("/get/yimaishangpin_tj_shangpinleibie")
Result<List<EchartsData>> yimaishangpin_tj_shangpinleibie() {
List<EchartsData> list = new ArrayList<>();
List<Map<String, Object>> yimaishangpin_tj_shangpinleibieList = yimaishangpinInfoDao.yimaishangpin_tj_shangpinleibie();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : yimaishangpin_tj_shangpinleibieList) {
typeMap.put((String)map.get("aa"), (Double.valueOf((String)map.get("bb").toString())));
}
getPieData("义卖商品按商品类别统计", list, typeMap);
getBarData("义卖商品按商品类别统计", list, typeMap);
return Result.success(list);
}
@GetMapping("/getExcelModel")
public void getExcelModel(HttpServletResponse response) throws IOException {
// 1. 生成excel
Map<String, Object> row = new LinkedHashMap<>();
row.put("shangpinbianhao", "A商品编号");
row.put("shangpinmingcheng", "A商品名称");
row.put("shangpinleibie", "A商品类别");
row.put("jiage", "A价格");
row.put("kucun", "A库存");
row.put("tupian", "A图片");
row.put("beizhu", "A备注");
row.put("status", "是");
row.put("level", "yimaishangpin");
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=yimaishangpinInfoModel.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("shangpinbianhao", "A商品编号");
row.put("shangpinmingcheng", "A商品名称");
row.put("shangpinleibie", "A商品类别");
row.put("jiage", "A价格");
row.put("kucun", "A库存");
row.put("tupian", "A图片");
row.put("beizhu", "A备注");
row.put("status", "是");
row.put("level", "权限");
List<Map<String, Object>> list = CollUtil.newArrayLis
没有合适的资源?快使用搜索试试~ 我知道了~
基于springboot+Web的校园爱心捐赠互助管理系统源码数据库.zip
共1146个文件
js:338个
html:126个
xml:103个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 79 浏览量
2023-06-21
14:32:25
上传
评论
收藏 29.71MB ZIP 举报
温馨提示
源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经
资源推荐
资源详情
资源评论
收起资源包目录
基于springboot+Web的校园爱心捐赠互助管理系统源码数据库.zip (1146个子文件)
additional- 22KB
additional- 22KB
additional-metho 22KB
additional-metho 22KB
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-grid 47KB
bootstrap-grid 47KB
bootstrap-reboo 4KB
bootstrap-reboo 4KB
bootstrap.bundle 75KB
bootstrap.bundle 75KB
bootstrap.min.c 150KB
bootstrap.min.c 150KB
bootstrap-grid.min.c 47KB
bootstrap-grid.min.c 47KB
datepicker.c 4KB
datepicker.c 4KB
YimaishangpinInfoController.class 14KB
XinwentongzhiInfoController.class 13KB
GoumaiInfoController.class 13KB
ZaixianjuanzengInfoController.class 13KB
WupinshenqingInfoController.class 13KB
QiuzhuxinxiInfoController.class 13KB
PinkunshengInfoController.class 13KB
ShangpinleibieInfoController.class 12KB
XitongjianjieInfoController.class 12KB
YonghuxinxiInfoController.class 12KB
LiuyanbanInfoController.class 12KB
AccountController.class 11KB
AdminInfoController.class 9KB
NxSystemFileController.class 8KB
EchartsController.class 5KB
YonghuxinxiInfoService.class 5KB
XinwentongzhiInfoService.class 5KB
GoumaiInfoService.class 5KB
WupinshenqingInfoService.class 5KB
AdminInfoService.class 5KB
ZaixianjuanzengInfoService.class 5KB
AdminInfo.class 4KB
YimaishangpinInfoService.class 4KB
CommentInfoService.class 4KB
QiuzhuxinxiInfoService.class 4KB
YonghuxinxiInfo.class 4KB
ShangpinleibieInfoService.class 4KB
XitongjianjieInfoService.class 4KB
PinkunshengInfoService.class 4KB
XinwentongzhiInfo.class 4KB
GoumaiInfo.class 4KB
CollectInfoController.class 4KB
LiuyanbanInfoService.class 4KB
CommentInfoController.class 4KB
ZaixianjuanzengInfo.class 4KB
YimaishangpinInfo.class 3KB
RichtextInfoController.class 3KB
CollectInfoService.class 3KB
WupinshenqingInfo.class 3KB
RichtextInfoService.class 3KB
NxSystemFileInfoService.class 3KB
LiuyanbanInfo.class 3KB
CollectInfo.class 3KB
CommentInfo.class 3KB
QiuzhuxinxiInfo.class 3KB
Account.class 3KB
Result.class 2KB
PinkunshengInfo.class 2KB
EchartsData.class 2KB
ResultCode.class 2KB
MyInterceptor.class 2KB
XitongjianjieInfo.class 2KB
ZaixianjuanzengInfoDao.class 2KB
YimaishangpinInfoDao.class 2KB
WupinshenqingInfoDao.class 2KB
GlobalExceptionHandler.class 2KB
QiuzhuxinxiInfoDao.class 2KB
GoumaiInfoDao.class 2KB
ShangpinleibieInfo.class 2KB
XinwentongzhiInfoDao.class 2KB
EchartsData$Data.class 2KB
WebMvcConfig.class 2KB
CommentInfoDao.class 1KB
EchartsData$Series.class 1KB
ShangpinleibieInfoDao.class 1KB
PinkunshengInfoDao.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
共 1146 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
老歪不歪
- 粉丝: 44
- 资源: 4038
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功