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.HuiyuanxinxiInfo;
import com.example.dao.HuiyuanxinxiInfoDao;
import com.example.service.HuiyuanxinxiInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.HuiyuanxinxiInfoVo;
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 = "/huiyuanxinxiInfo")
public class HuiyuanxinxiInfoController {
@Resource
private HuiyuanxinxiInfoService huiyuanxinxiInfoService;
@Resource
private HuiyuanxinxiInfoDao huiyuanxinxiInfoDao;
@PostMapping
public Result<HuiyuanxinxiInfo> add(@RequestBody HuiyuanxinxiInfoVo huiyuanxinxiInfo) {
huiyuanxinxiInfo.setMima(SecureUtil.md5(huiyuanxinxiInfo.getMima()));
huiyuanxinxiInfoService.add(huiyuanxinxiInfo);
return Result.success(huiyuanxinxiInfo);
}
//youtixing1
//youtixing2
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
huiyuanxinxiInfoService.delete(id);
return Result.success();
}
@PutMapping
public Result update(@RequestBody HuiyuanxinxiInfoVo huiyuanxinxiInfo) {
huiyuanxinxiInfoService.update(huiyuanxinxiInfo);
return Result.success();
}
//@PutMapping("/update2")
// public Result update2(@RequestBody HuiyuanxinxiInfoVo huiyuanxinxiInfo) {
// huiyuanxinxiInfoService.update2(huiyuanxinxiInfo);
// return Result.success();
// }
@GetMapping("/{id}")
public Result<HuiyuanxinxiInfo> detail(@PathVariable Long id) {
HuiyuanxinxiInfo huiyuanxinxiInfo = huiyuanxinxiInfoService.findById(id);
return Result.success(huiyuanxinxiInfo);
}
@GetMapping("/changeStatus/{id}")
public Result<HuiyuanxinxiInfo> changeStatus(@PathVariable Long id) {
huiyuanxinxiInfoService.changeStatus(id);
return Result.success();
}
@GetMapping
public Result<List<HuiyuanxinxiInfoVo>> all() {
return Result.success(huiyuanxinxiInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<HuiyuanxinxiInfoVo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(huiyuanxinxiInfoService.findPage(name, pageNum, pageSize, request));
}
@GetMapping("/pageqt/{name}")
public Result<PageInfo<HuiyuanxinxiInfoVo>> pageqt(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize,
HttpServletRequest request) {
return Result.success(huiyuanxinxiInfoService.findPageqt(name, pageNum, pageSize, request));
}
// @PostMapping("/register")
// public Result<HuiyuanxinxiInfo> register(@RequestBody HuiyuanxinxiInfo huiyuanxinxiInfo) {
// if (StrUtil.isBlank(huiyuanxinxiInfo.getName()) || StrUtil.isBlank(huiyuanxinxiInfo.getPassword())) {
// throw new CustomException(ResultCode.PARAM_ERROR);
// }
// return Result.success(huiyuanxinxiInfoService.add(huiyuanxinxiInfo));
// }
/**
* 批量通过excel添加信息
* @param file excel文件
* @throws IOException
*/
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
List<HuiyuanxinxiInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(HuiyuanxinxiInfo.class);
if (!CollectionUtil.isEmpty(infoList)) {
// 处理一下空数据
List<HuiyuanxinxiInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getXingming())).collect(Collectors.toList());
for (HuiyuanxinxiInfo info : resultList) {
huiyuanxinxiInfoService.add(info);
}
}
return Result.success();
}
@GetMapping("/get/huiyuanxinxi_tj_xingbie")
Result<List<EchartsData>> huiyuanxinxi_tj_xingbie() {
List<EchartsData> list = new ArrayList<>();
List<Map<String, Object>> huiyuanxinxi_tj_xingbieList = huiyuanxinxiInfoDao.huiyuanxinxi_tj_xingbie();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : huiyuanxinxi_tj_xingbieList) {
typeMap.put((String)map.get("aa"), (Double.valueOf((String)map.get("bb").toString())));
}
getPieData("会员信息按性别统计", list, typeMap);
getBarData("会员信息按性别统计", list, typeMap);
return Result.success(list);
}
@GetMapping("/get/huiyuanxinxi_tj_leixing")
Result<List<EchartsData>> huiyuanxinxi_tj_leixing() {
List<EchartsData> list = new ArrayList<>();
List<Map<String, Object>> huiyuanxinxi_tj_leixingList = huiyuanxinxiInfoDao.huiyuanxinxi_tj_leixing();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : huiyuanxinxi_tj_leixingList) {
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("yonghuming", "A用户名");
row.put("mima", "A密码");
row.put("xingming", "A姓名");
row.put("xingbie", "A性别");
row.put("dianhua", "A电话");
row.put("shenfenzheng", "A身份证");
row.put("zhaopian", "A照片");
row.put("leixing", "A类型");
row.put("zhekou", "A折扣");
row.put("beizhu", "A备注");
row.put("status", "是");
row.put("level", "huiyuanxinxi");
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=huiyuanxinxiInfoModel.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> ro
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
小程序毕业设计,小程序课程设计,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 1. 技术组成 前端: 小程序 后台框架:SSM/SpringBoot(如果有的话) 开发环境:idea,微信开发者工具 数据库:MySql(建议用 5.7 版本,8.0 有时候会有坑) 数据库可视化工具:使用 Navicat 部署环境:Tomcat(建议用 7.x 或者 8.x 版本),maven
资源推荐
资源详情
资源评论



























收起资源包目录





































































































共 828 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论


gdutxiaoxu
- 粉丝: 1435
- 资源: 2611
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
