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.ShangpinxinxiInfo;
import com.example.dao.ShangpinxinxiInfoDao;
import com.example.service.ShangpinxinxiInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.ShangpinxinxiInfoVo;
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 = "/shangpinxinxiInfo")
public class ShangpinxinxiInfoController {
@Resource
private ShangpinxinxiInfoService shangpinxinxiInfoService;
@Resource
private ShangpinxinxiInfoDao shangpinxinxiInfoDao;
@PostMapping
public Result<ShangpinxinxiInfo> add(@RequestBody ShangpinxinxiInfoVo shangpinxinxiInfo) {
//mixmajixami
shangpinxinxiInfoService.add(shangpinxinxiInfo);
return Result.success(shangpinxinxiInfo);
}
@GetMapping("/tixing")
public Result<Integer> tixing() { Integer count = shangpinxinxiInfoService.tixing(); return Result.success(count); }
// @GetMapping("/getByDiqu")
// public Result<List<Map<String,String>>> qidu() {
// return Result.success(shangpinxinxiInfoService.findByDiqu());
// }
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
shangpinxinxiInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody ShangpinxinxiInfoVo shangpinxinxiInfo) {
shangpinxinxiInfoService.update(shangpinxinxiInfo);
return Result.success();
}
//@PutMapping("/update2")
// public Result update2(@RequestBody ShangpinxinxiInfoVo shangpinxinxiInfo) {
// shangpinxinxiInfoService.update2(shangpinxinxiInfo);
// return Result.success();
// }
@GetMapping("/{id}")
public Result<ShangpinxinxiInfo> detail(@PathVariable Long id) {
ShangpinxinxiInfo shangpinxinxiInfo = shangpinxinxiInfoService.findById(id);
return Result.success(shangpinxinxiInfo);
}
@GetMapping("/changeStatus/{id}")
public Result<ShangpinxinxiInfo> changeStatus(@PathVariable Long id) {
shangpinxinxiInfoService.changeStatus(id);
return Result.success();
}
@GetMapping
public Result<List<ShangpinxinxiInfoVo>> all() {
return Result.success(shangpinxinxiInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<ShangpinxinxiInfoVo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(shangpinxinxiInfoService.findPage(name, pageNum, pageSize, request));
}
@GetMapping("/pageqt/{name}")
public Result<PageInfo<ShangpinxinxiInfoVo>> pageqt(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize,
HttpServletRequest request) {
return Result.success(shangpinxinxiInfoService.findPageqt(name, pageNum, pageSize, request));
}
@GetMapping("/findByType/{type}")
public Result<List<ShangpinxinxiInfoVo>> findByType(@PathVariable String type) {
return Result.success(shangpinxinxiInfoService.findByType(type));
}
// @PostMapping("/register")
// public Result<ShangpinxinxiInfo> register(@RequestBody ShangpinxinxiInfo shangpinxinxiInfo) {
// if (StrUtil.isBlank(shangpinxinxiInfo.getName()) || StrUtil.isBlank(shangpinxinxiInfo.getPassword())) {
// throw new CustomException(ResultCode.PARAM_ERROR);
// }
// return Result.success(shangpinxinxiInfoService.add(shangpinxinxiInfo));
// }
/**
* 批量通过excel添加信息
* @param file excel文件
* @throws IOException
*/
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
List<ShangpinxinxiInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(ShangpinxinxiInfo.class);
if (!CollectionUtil.isEmpty(infoList)) {
// 处理一下空数据
List<ShangpinxinxiInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getShangpinbianhao())).collect(Collectors.toList());
for (ShangpinxinxiInfo info : resultList) {
shangpinxinxiInfoService.add(info);
}
}
return Result.success();
}
@GetMapping("/get/shangpinxinxi_tj_shangpinleibie")
Result<List<EchartsData>> shangpinxinxi_tj_shangpinleibie() {
List<EchartsData> list = new ArrayList<>();
List<Map<String, Object>> shangpinxinxi_tj_shangpinleibieList = shangpinxinxiInfoDao.shangpinxinxi_tj_shangpinleibie();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : shangpinxinxi_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("xiaoliang", "A销量");
row.put("tupian", "A图片");
row.put("beizhu", "A备注");
row.put("status", "是");
row.put("level", "shangpinxinxi");
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=shangpinxinxiInfoModel.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商品类�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【微信小程序项目实例】惠农小店系统设计与开发(源码+说明+数据库+演示视频).zip 【项目技术】 微信小程序开发工具+mysql+java+b/s 【实现功能】 小程序的主要功能有系统首页、商品、购物车、我的。后台的主要功能包括系统用户管理、农产品新闻管理、会员等级管理、注册用户管理、农产品类别管理和商品管理和购买管理。
资源推荐
资源详情
资源评论
收起资源包目录
【微信小程序项目实例】惠农小店系统设计与开发(源码+说明+数据库+演示视频).zip (777个子文件)
02add20b581be471b8d17f887b8e8337070546 194B
034ccce28a21cdd1d8500e03a3a19950a24840 135B
06718f8e6a9de9438b6501aff2f83152c53f25 2KB
06bfdeb5ad13a02a29eb9b8b8b57e1d69cedf5 124B
07d6d5f654346606542e80ea09e9983f07705c 85B
0841a689acfc75f16b91e8e49d4daa3cb01df9 831B
0887a714f0134b8dc77a89f648ad7af5219624 2KB
0c0812bb527be6b50c8a043d1e291ddd0d0b0f 135B
0f96ef21c70252c670fbb021f9ddf4e17d7e2a 2KB
132b89c93c82fb7d83523022c3d606b0cdce55 78B
136700c3f750c5b13756b0dc040c0f73168f9c 1KB
17db6db9c5f9d9ffa753ba24dbae05c63a71c6 643B
1988e9f039d279a680e8b915fe5e1d56dd385c 7KB
1a4f51d6e7d104f36ebd32906ca09c7f7ef82a 8KB
1bddcf8c0d37b912fba31db4b7261959e166b2 4KB
1d566316c654a00f15a8fa8605adcc0887ca78 134B
1d5abdfb44d57b8c2e9f70fe5e82ddc71b6040 242B
27b9ee1bdfda2aff5098f63ce7668e0bfc2d51 395B
302da08c7b072cd19358dbb503c18d08fb2143 168B
333cd8c19ff05f2b316c1e8c7d067593702854 5KB
3475a344ade362d397c92f42bafce7f4357dbd 145B
35af0699ccec004cbe685ef938cd2d63ea7037 43B
36c5aae34facbdeb0bd8ee16feba3cdacc8a2e 670B
370e54f9f9ccbc0483f91ed17cd4d0ca7d1a70 361B
395ba95c5c84d41771f4cb2b9df6cc965ee60f 1KB
39747192cd7402c2784c27bb13b8d4e6021d7a 6KB
3b32372fa0114d56ecc4e9f1d0ea4ac1ce4f5e 3KB
42709e1cd615263236d0ee23117795e95a586e 82B
47196fb87ade0fd21217c28577b489ed536b34 2KB
499d747924a8c5aa0ad42ca020ab1dcba50613 417B
50f112453e93931726340632087f9f173cfec4 965B
538c295a79e1ccc89a476f6432a0f8bbef04f9 1KB
559ee67ff7916e39e897c0ec7e140669be3ff1 676B
59f2720d04769b18523ecfd19ab1ade5ccbb9d 998B
5bf3a9933976efe33f1364f35ea29bfc1e9b26 135B
62a356e02e047d41dc875951245df07784d393 85B
6355f833fa1631a2aff819ff01633262da105e 309B
640e0dc44a0e9b160f85b9124714ea071ae7b6 39B
66f3d96d389c73495bbc9cc29d885fc5686bbf 7KB
67afb3a76618078d09086794e323dfe3a29c67 464B
69302c397adc425d760404292f4e9f519553a3 547B
6adec7200d72d6e908125b68cd1c67870bb0f8 85B
6ae0a20376ab441fbb25ed51daef83edb01fa9 135B
7021ccbae905b1e6d5242870e02123f6802b0d 85B
70aad1425a244da356e277ad9bc0607ab5f1dd 3KB
70ab1985689e06f05f658e06e2c39d05753296 407B
71f0df9ae63c39b48b150016cf5a922d540a85 673B
720f7a8e2ffa773538b1ed03222a3b7b20308f 4KB
752381bbf3cf1e8fe80266ebdf35f072df4e98 419B
763277e84151db2255d4000b7dbb91ada84a2b 1KB
767e3032a1cf829c00c7e147d494447d90652e 90B
784a5ce22115b67892b535f3c60fe024cf0e74 2KB
7aa4936e5edd996855413f9ca3fd9edcef7603 794B
7e73b461960e9b46ab3930aa4ed7ea0b252f3e 316B
7f19b5f9c2c88d7c8d0c2f5dd31a9699997f1a 388B
8114571df8026ac96009c567edbe5fef81ed09 52B
858121553fb20a1275407abcd7ee57c634fb3f 135B
87a25525aa06dba166ccdba796671feaae184b 1KB
87db04fd8716eb3a4b88f97041126b9da7bde9 761B
894d1a278e3ed8c42e639570a0ceb1ac36326c 135B
89a34ee050b5e68e6ae70f41cbfd776421f541 84B
8b9b1520e9a72765a0721ad12c58acb627039f 928B
8bb93e7ebffecf9b3a7fe1582c2d54be32f75e 345B
8e4079810a018090ba597cc7a7afd41ea79bfb 2KB
8f6d71951e182e79255a2b94cb4ea4aa840da5 134B
8fb1d865a89e6d04e3a0c387535ad4d6aa34c0 1KB
92d638e2a2710cc72eac649710cbf560127d22 1KB
968af357ba7583984746b29aa400ff1bcb224c 245B
96f859f54e491950d60868ef72455f47fac058 464B
97c9bf6abab5bfb1d540e49408165e52cdeff3 151B
9960aa4c4d20d830655c87be19faa59a01682c 134B
9c108783e453961d68b9f44a7dd505927a380f 1KB
9cee8e7b376a4b493efd229ef5246561865764 135B
9d7c0880fe6a8db908fe6e365c370df7aaccb6 135B
9da67f1cdf39347ffd1ad0cb4012580cf34415 832B
9df324b450d0cb30d6cd6ee76845ba67ab748e 72B
a262d800b44df5ce408b97627d6711a064c07c 982B
a4ad3f5871c4b3815694f776d304ae29851227 48B
a7e960684704ca3d756a2719cd0e554aa5396c 850B
a803e63eeee1a27918f6c36ca41c80ea7933c8 85B
aba0b2d291bbf2ad9178ed9a8c621ca523b888 134B
ac38830e1d734727cdf659c6d6005674f8167e 805B
af40cadf2e21c8e03aa284fb4af3e7eeacc82b 788B
b9149ea2f49f24e39fd6a3e78241969a6b48a4 408B
b9902204bec6686f1c9b066ef459979346c4c4 2KB
bef88f62c0e917ecb8d4dda3e422983063e6bf 466B
bfff5b56c4101296ce2867851ade06ca86af48 226B
c0b5583ff1d87aefdd9035cf351b888ad41503 2KB
c47546807d4b6d68d54c46bb334ed13a21c4cb 136B
c4afc6d123f8ca861ce4ad3200fcc47c34e075 375B
ca58b388c66119887731fcab9dd57f1e2c6836 12KB
cfa20722ff7572d4c4a3023b776559ed9be1f2 1006B
GoumaiInfoController.class 14KB
ShangpinxinxiInfoController.class 14KB
ZhuceyonghuInfoController.class 13KB
XinwentongzhiInfoController.class 13KB
NongchanpinleibieInfoController.class 12KB
HuiyuandengjiInfoController.class 12KB
LiuyanbanInfoController.class 12KB
AccountController.class 11KB
共 777 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
职场程序猿
- 粉丝: 5898
- 资源: 3706
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功