Compare commits

..

No commits in common. 'smq' and 'main' have entirely different histories.
smq ... main

@ -1,59 +0,0 @@
# 项目信息配置
project:
name: dyspringboot
version: 1.0.0
env: development
# WEB服务器配置
server:
#端口
port: 8080
servlet:
#上下文路径
context-path: /springbootzongse
spring:
# 数据源配置
datasource:
# 数据库
url: jdbc:mysql://localhost:3306/gouwulingshispr97023?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
# 数据库用户名,需要改成你自己的
username: root
# 数据库密码,需要改成你自己的
password: 123456
# 数据库驱动按实际选择默认是mysql8 com.mysql.cj.jdbc.Driver(mysql8) 、 com.mysql.jdbc.Driver(mysql8)
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
# JSON返回配置
jackson:
# 默认时区
time-zone: GMT+8
# 默认日期格式化
date-format: yyyy-MM-dd HH:mm:ss
# 静态资源配置
resources:
static-locations: classpath:/static/
# Thymeleaf配置
thymeleaf:
cache: false
servlet:
multipart:
#上传文件时单个文件大小配置
max-file-size: 50MB
#总上传文件大小配置
max-request-size: 50MB
# MyBatis配置
mybatis:
mapper-locations: classpath:/mappers/*.xml
configuration:
map-underscore-to-camel-case: true
# 日志配置
logback:
level: INFO
appender: ${project.env}
# dao层的日志设置为debug方便查看sql
logging:
level:
com.dao: debug

@ -1,80 +0,0 @@
package com.controller;
import com.annotation.IgnoreAuth;
import com.util.ApiResponse;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Date;
/**
* @ClassName CommonController
* @Description
*/
@RestController
@RequestMapping("/common")
public class CommonController {
/**
*
*/
@IgnoreAuth
@RequestMapping("/uploadfile")
public ApiResponse<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
if (file.isEmpty()) {
return ApiResponse.failed(400, "文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
File path = new File(ResourceUtils.getURL("classpath:static").getPath());
if (!path.exists()) {
path = new File("");
}
File upload = new File(path.getAbsolutePath(), "/upload/");
if (!upload.exists()) {
upload.mkdirs();
}
String fileName = new Date().getTime() + "." + fileExt;
File dest = new File(upload.getAbsolutePath() + "/" + fileName);
file.transferTo(dest);
return ApiResponse.success(fileName);
}
/**
*
*
* @throws IOException
*/
@IgnoreAuth
@RequestMapping(value = "/download", method = RequestMethod.GET)
public void download(@RequestParam(value = "filename") String filename,
HttpServletRequest request,
HttpServletResponse response) throws IOException {
//需要下载的文件
String path = ResourceUtils.getURL("classpath:static").getPath() + "/" + filename;
//获取输入流
InputStream bis = new BufferedInputStream(new FileInputStream(new File(path)));
//转码,免得文件名中文乱码
filename = URLEncoder.encode(filename, "UTF-8");
//设置文件下载头
response.addHeader("Content-Disposition", "attachment;filename=" + filename);
//1.设置文件ContentType类型这样设置会自动判断下载文件类型
response.setContentType("multipart/form-data");
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
int len = 0;
while ((len = bis.read()) != -1) {
out.write(len);
out.flush();
}
out.close();
}
}

@ -1,335 +0,0 @@
package com.controller;
import com.annotation.IgnoreAuth;
import com.entity.*;
import com.service.DingdanService;
import com.service.DingdanxiangService;
import com.service.GouwucheService;
import com.service.ShangpinService;
import com.util.ApiResponse;
import com.util.PageData;
import com.util.PageWrap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName DingdanController
* @Description
*/
@RequestMapping("dingdan")
@RestController
public class DingdanController {
@Autowired
private DingdanService dingdanService;
@Autowired
private GouwucheService gouwucheService;
@Autowired
private ShangpinService shangpinService;
@Autowired
private DingdanxiangService dingdanxiangService;
//前台-根据条件获取订单列表分页数据接口
@RequestMapping("/manaqian")
public ApiResponse<Dingdan> manaQian(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//前台-根据条件获取我的订单列表分页数据接口
@RequestMapping("/manamyqian")
public ApiResponse<Dingdan> manaMyQian(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//前台-根据条件获取订单图片列表分页数据接口
@RequestMapping("/manaqiantp")
public ApiResponse<Dingdan> manaQianTp(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//前台-订单详情
@RequestMapping("/detail/{id}")
public ApiResponse<Dingdan> detail(@PathVariable("id") Integer id) {
Dingdan info = dingdanService.findById(id);
return ApiResponse.success(info);
}
//前台-订单添加接口
@PostMapping("/add")
public ApiResponse<Integer> add(@RequestBody Dingdan req, HttpSession session, String shangPinId) {
Users users = (Users) session.getAttribute("users");
List<Gouwuche> gouwucheList = new ArrayList<>();
if (null != users && null != users.getId()) {
if (null == shangPinId || shangPinId.equals("0")) {
//从购物车里提交订单下单
Gouwuche gouwuche = new Gouwuche();
gouwuche.setUsersid(users.getId());
gouwucheList = gouwucheService.find(gouwuche);
}else {
//商品详情页里直接购买下单
Integer shangpinid = cn.hutool.core.convert.Convert.toInt(shangPinId);
Gouwuche gouwuche = new Gouwuche();
gouwuche.setShangpinid(shangpinid);
gouwuche.setId(0);
//直接购买时购买数量为1
gouwuche.setGoumaishuliang(1);
gouwucheList.add(gouwuche);
}
if (gouwucheList.size() == 0) {
return ApiResponse.failed("请先将商品添加到购物车再提交订单!");
} else {
for (Gouwuche info : gouwucheList) {
Integer shangpinid = info.getShangpinid();
if (null == shangpinid || shangpinid == 0) {
return ApiResponse.failed("购物车里的商品数据异常!");
}
Integer goumaishuliang = info.getGoumaishuliang();
//库存判断
Shangpin shangpin = shangpinService.findById(shangpinid);
if (null != shangpin) {
Integer kucunshuliang = shangpin.getKucunshuliang();
//判断库存是否大于或等于订单数量
if (kucunshuliang < goumaishuliang) {
return ApiResponse.failed("购物车里的商品库存不足,请修正后再提交!");
}
} else {
return ApiResponse.failed("购物车里的商品不存在!");
}
}
}
} else {
return ApiResponse.failed("请登陆后再操作!");
}
int result = dingdanService.saveOrUpdate(req);
//保存订单项数据、更新商品表数据以及删除购物车数据
for (Gouwuche info : gouwucheList) {
Integer shangpinid = info.getShangpinid();
Integer goumaishuliang = info.getGoumaishuliang();
//保存订单项数据
Dingdanxiang dingdanxiang = new Dingdanxiang();
dingdanxiang.setShangpinid(shangpinid);
dingdanxiang.setGoumaishuliang(goumaishuliang);
dingdanxiang.setUsersid(users.getId());
dingdanxiang.setDingdanid(result);
dingdanxiangService.saveOrUpdate(dingdanxiang);
//更新商品表数据
Shangpin shangpin = shangpinService.findById(shangpinid);
Integer kucunshuliang = shangpin.getKucunshuliang();
Integer xiaoshoushuliang = shangpin.getXiaoshoushuliang();
//商品库存数量减去购买数量
shangpin.setKucunshuliang(kucunshuliang - goumaishuliang);
//商品销售数量加上购买数量
shangpin.setXiaoshoushuliang(xiaoshoushuliang + goumaishuliang);
shangpinService.saveOrUpdate(shangpin);
//删除购物车数据
gouwucheService.deleteById(info.getId());
}
return ApiResponse.success(result);
}
//后台-根据条件获取订单管理列表分页数据接口
@RequestMapping("/mana")
public ApiResponse<Dingdan> mana(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//后台-根据条件获取订单管理我的列表分页数据接口
@RequestMapping("/manamy")
public ApiResponse<Dingdan> manaMy(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//后台-根据条件获取订单查看列表分页数据接口
@RequestMapping("/chakan")
public ApiResponse<Dingdan> chakan(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//后台-根据条件获取订单查看我的列表分页数据接口
@RequestMapping("/chakanmy")
public ApiResponse<Dingdan> chakanMy(Dingdan req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdan> dingdanList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanList);
}
//后台-订单详情
@RequestMapping("/info/{id}")
public ApiResponse<Dingdan> info(@PathVariable("id") Integer id) {
Dingdan info = dingdanService.findById(id);
return ApiResponse.success(info);
}
//后台-订单添加接口
@PostMapping("/save")
public ApiResponse<Integer> save(@RequestBody Dingdan req, HttpSession session, String shangPinId) {
Users users = (Users) session.getAttribute("users");
List<Gouwuche> gouwucheList = new ArrayList<>();
if (null != users && null != users.getId()) {
if (null == shangPinId || shangPinId.equals("0")) {
//从购物车里提交订单下单
Gouwuche gouwuche = new Gouwuche();
gouwuche.setUsersid(users.getId());
gouwucheList = gouwucheService.find(gouwuche);
}else {
//商品详情页里直接购买下单
Integer shangpinid = cn.hutool.core.convert.Convert.toInt(shangPinId);
Gouwuche gouwuche = new Gouwuche();
gouwuche.setShangpinid(shangpinid);
gouwuche.setId(0);
//直接购买时购买数量为1
gouwuche.setGoumaishuliang(1);
gouwucheList.add(gouwuche);
}
if (gouwucheList.size() == 0) {
return ApiResponse.failed("请先将商品添加到购物车再提交订单!");
} else {
for (Gouwuche info : gouwucheList) {
Integer shangpinid = info.getShangpinid();
if (null == shangpinid || shangpinid == 0) {
return ApiResponse.failed("购物车里的商品数据异常!");
}
Integer goumaishuliang = info.getGoumaishuliang();
//库存判断
Shangpin shangpin = shangpinService.findById(shangpinid);
if (null != shangpin) {
Integer kucunshuliang = shangpin.getKucunshuliang();
//判断库存是否大于或等于订单数量
if (kucunshuliang < goumaishuliang) {
return ApiResponse.failed("购物车里的商品库存不足,请修正后再提交!");
}
} else {
return ApiResponse.failed("购物车里的商品不存在!");
}
}
}
} else {
return ApiResponse.failed("请登陆后再操作!");
}
int result = dingdanService.saveOrUpdate(req);
//保存订单项数据、更新商品表数据以及删除购物车数据
for (Gouwuche info : gouwucheList) {
Integer shangpinid = info.getShangpinid();
Integer goumaishuliang = info.getGoumaishuliang();
//保存订单项数据
Dingdanxiang dingdanxiang = new Dingdanxiang();
dingdanxiang.setShangpinid(shangpinid);
dingdanxiang.setGoumaishuliang(goumaishuliang);
dingdanxiang.setUsersid(users.getId());
dingdanxiang.setDingdanid(result);
dingdanxiangService.saveOrUpdate(dingdanxiang);
//更新商品表数据
Shangpin shangpin = shangpinService.findById(shangpinid);
Integer kucunshuliang = shangpin.getKucunshuliang();
Integer xiaoshoushuliang = shangpin.getXiaoshoushuliang();
//商品库存数量减去购买数量
shangpin.setKucunshuliang(kucunshuliang - goumaishuliang);
//商品销售数量加上购买数量
shangpin.setXiaoshoushuliang(xiaoshoushuliang + goumaishuliang);
shangpinService.saveOrUpdate(shangpin);
//删除购物车数据
gouwucheService.deleteById(info.getId());
}
return ApiResponse.success(result);
}
//订单删除(含批量删除)接口
@RequestMapping("/delete")
public ApiResponse<Integer> delete(@RequestBody Integer[] ids) {
int result = 0;
for (Integer id : ids) {
result = dingdanService.deleteById(id);
}
return ApiResponse.success(result);
}
//订单修改接口
@PostMapping("/set")
public ApiResponse<Integer> set(@RequestBody Dingdan req) {
int result = dingdanService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//根据条件获取订单总金额接口
@RequestMapping("/totalamount")
public ApiResponse<Integer> getTotalamount(Dingdan req) {
//计算订单总金额
Integer totalAmount = 0;
List<Dingdan> dingdanList = dingdanService.find(req);
for (Dingdan dingdan : dingdanList) {
totalAmount += dingdan.getJine();
}
return ApiResponse.success(totalAmount);
}
//获取所有订单数据接口
@RequestMapping("/all")
public ApiResponse<Dingdan> dingdanAll() {
List<Dingdan> dingdanList = dingdanService.findAll();
return ApiResponse.success(dingdanList);
}
//根据条件(字符类型模糊匹配查询)获取订单数据接口
@IgnoreAuth
@RequestMapping("/search")
public ApiResponse<Dingdan> dingdanSearch(Dingdan req) {
List<Dingdan> dingdanList = dingdanService.find(req);
return ApiResponse.success(dingdanList);
}
//根据条件(字符类型完全匹配查询)获取订单数据接口
@IgnoreAuth
@RequestMapping("/searchByEqualTo")
public ApiResponse<Dingdan> dingdanSearchByEqualTo(Dingdan req) {
List<Dingdan> dingdanList = dingdanService.findByEqualTo(req);
return ApiResponse.success(dingdanList);
}
//按条件查询订单分页数据方法(模糊匹配查询)
private PageData<Dingdan> getPageList(Dingdan req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdan> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dingdan> dingdanList = dingdanService.findPage(pageWrap);
return dingdanList;
}
//按条件查询订单分页数据方法(完全匹配查询)
private PageData<Dingdan> getPageListByEqualTo(Dingdan req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdan> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dingdan> dingdanList = dingdanService.findPageByEqualTo(pageWrap);
return dingdanList;
}
//获取订单查询用户数据搜索条件
private PageWrap<Dingdan> getPageWrap(Dingdan req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdan> pageWrap = new PageWrap<>();
pageWrap.setModel(req);
pageWrap.setPageNum(pageNo);
pageWrap.setPageSize(pageSize);
PageWrap.SortData sortData = new PageWrap.SortData();
sortData.setDirection("DESC");
sortData.setProperty(sortProperty);
List<PageWrap.SortData> sorts = new ArrayList<>();
sorts.add(sortData);
pageWrap.setSorts(sorts);
return pageWrap;
}
}

@ -1,179 +0,0 @@
package com.controller;
import com.annotation.IgnoreAuth;
import com.entity.Dingdanxiang;
import com.service.DingdanxiangService;
import com.util.ApiResponse;
import com.util.PageData;
import com.util.PageWrap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName DingdanxiangController
* @Description
*/
@RequestMapping("dingdanxiang")
@RestController
public class DingdanxiangController {
@Autowired
private DingdanxiangService dingdanxiangService;
//前台-根据条件获取订单项列表分页数据接口
@IgnoreAuth
@RequestMapping("/manaqian")
public ApiResponse<Dingdanxiang> manaQian(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//前台-根据条件获取我的订单项列表分页数据接口
@RequestMapping("/manamyqian")
public ApiResponse<Dingdanxiang> manaMyQian(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//前台-根据条件获取订单项图片列表分页数据接口
@IgnoreAuth
@RequestMapping("/manaqiantp")
public ApiResponse<Dingdanxiang> manaQianTp(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//前台-订单项详情
@IgnoreAuth
@RequestMapping("/detail/{id}")
public ApiResponse<Dingdanxiang> detail(@PathVariable("id") Integer id) {
Dingdanxiang info = dingdanxiangService.findById(id);
return ApiResponse.success(info);
}
//前台-订单项添加接口
@PostMapping("/add")
public ApiResponse<Integer> add(@RequestBody Dingdanxiang req) {
int result = dingdanxiangService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//后台-根据条件获取订单项管理列表分页数据接口
@RequestMapping("/mana")
public ApiResponse<Dingdanxiang> mana(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//后台-根据条件获取订单项管理我的列表分页数据接口
@RequestMapping("/manamy")
public ApiResponse<Dingdanxiang> manaMy(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//后台-根据条件获取订单项查看列表分页数据接口
@RequestMapping("/chakan")
public ApiResponse<Dingdanxiang> chakan(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//后台-根据条件获取订单项查看我的列表分页数据接口
@RequestMapping("/chakanmy")
public ApiResponse<Dingdanxiang> chakanMy(Dingdanxiang req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dingdanxiang> dingdanxiangList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dingdanxiangList);
}
//后台-订单项详情
@RequestMapping("/info/{id}")
public ApiResponse<Dingdanxiang> info(@PathVariable("id") Integer id) {
Dingdanxiang info = dingdanxiangService.findById(id);
return ApiResponse.success(info);
}
//后台-订单项添加接口
@PostMapping("/save")
public ApiResponse<Integer> save(@RequestBody Dingdanxiang req) {
int result = dingdanxiangService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//订单项删除(含批量删除)接口
@RequestMapping("/delete")
public ApiResponse<Integer> delete(@RequestBody Integer[] ids) {
int result = 0;
for (Integer id : ids) {
result = dingdanxiangService.deleteById(id);
}
return ApiResponse.success(result);
}
//订单项修改接口
@PostMapping("/set")
public ApiResponse<Integer> set(@RequestBody Dingdanxiang req) {
int result = dingdanxiangService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//获取所有订单项数据接口
@IgnoreAuth
@RequestMapping("/all")
public ApiResponse<Dingdanxiang> dingdanxiangAll() {
List<Dingdanxiang> dingdanxiangList = dingdanxiangService.findAll();
return ApiResponse.success(dingdanxiangList);
}
//根据条件(字符类型模糊匹配查询)获取订单项数据接口
@IgnoreAuth
@RequestMapping("/search")
public ApiResponse<Dingdanxiang> dingdanxiangSearch(Dingdanxiang req) {
List<Dingdanxiang> dingdanxiangList = dingdanxiangService.find(req);
return ApiResponse.success(dingdanxiangList);
}
//根据条件(字符类型完全匹配查询)获取订单项数据接口
@IgnoreAuth
@RequestMapping("/searchByEqualTo")
public ApiResponse<Dingdanxiang> dingdanxiangSearchByEqualTo(Dingdanxiang req) {
List<Dingdanxiang> dingdanxiangList = dingdanxiangService.findByEqualTo(req);
return ApiResponse.success(dingdanxiangList);
}
//按条件查询订单项分页数据方法(模糊匹配查询)
private PageData<Dingdanxiang> getPageList(Dingdanxiang req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdanxiang> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dingdanxiang> dingdanxiangList = dingdanxiangService.findPage(pageWrap);
return dingdanxiangList;
}
//按条件查询订单项分页数据方法(完全匹配查询)
private PageData<Dingdanxiang> getPageListByEqualTo(Dingdanxiang req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdanxiang> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dingdanxiang> dingdanxiangList = dingdanxiangService.findPageByEqualTo(pageWrap);
return dingdanxiangList;
}
//获取订单项查询数据搜索条件
private PageWrap<Dingdanxiang> getPageWrap(Dingdanxiang req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dingdanxiang> pageWrap = new PageWrap<>();
pageWrap.setModel(req);
pageWrap.setPageNum(pageNo);
pageWrap.setPageSize(pageSize);
PageWrap.SortData sortData = new PageWrap.SortData();
sortData.setDirection("DESC");
sortData.setProperty(sortProperty);
List<PageWrap.SortData> sorts = new ArrayList<>();
sorts.add(sortData);
pageWrap.setSorts(sorts);
return pageWrap;
}
}

@ -1,179 +0,0 @@
package com.controller;
import com.annotation.IgnoreAuth;
import com.entity.Dx;
import com.service.DxService;
import com.util.ApiResponse;
import com.util.PageData;
import com.util.PageWrap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName DxController
* @Description
*/
@RequestMapping("dx")
@RestController
public class DxController {
@Autowired
private DxService dxService;
//前台-根据条件获取信息介绍列表分页数据接口
@IgnoreAuth
@RequestMapping("/manaqian")
public ApiResponse<Dx> manaQian(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//前台-根据条件获取我的信息介绍列表分页数据接口
@RequestMapping("/manamyqian")
public ApiResponse<Dx> manaMyQian(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//前台-根据条件获取信息介绍图片列表分页数据接口
@IgnoreAuth
@RequestMapping("/manaqiantp")
public ApiResponse<Dx> manaQianTp(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//前台-信息介绍详情
@IgnoreAuth
@RequestMapping("/detail/{id}")
public ApiResponse<Dx> detail(@PathVariable("id") Integer id) {
Dx info = dxService.findById(id);
return ApiResponse.success(info);
}
//前台-信息介绍添加接口
@PostMapping("/add")
public ApiResponse<Integer> add(@RequestBody Dx req) {
int result = dxService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//后台-根据条件获取信息介绍管理列表分页数据接口
@RequestMapping("/mana")
public ApiResponse<Dx> mana(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//后台-根据条件获取信息介绍管理我的列表分页数据接口
@RequestMapping("/manamy")
public ApiResponse<Dx> manaMy(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//后台-根据条件获取信息介绍查看列表分页数据接口
@RequestMapping("/chakan")
public ApiResponse<Dx> chakan(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//后台-根据条件获取信息介绍查看我的列表分页数据接口
@RequestMapping("/chakanmy")
public ApiResponse<Dx> chakanMy(Dx req, @RequestParam(defaultValue = "1", value = "pageNo") int pageNo, @RequestParam(defaultValue = "10", value = "pageSize") int pageSize, @RequestParam(defaultValue = "id", value = "sortProperty") String sortProperty) {
PageData<Dx> dxList = getPageList(req, pageNo, pageSize, sortProperty);
return ApiResponse.success(dxList);
}
//后台-信息介绍详情
@RequestMapping("/info/{id}")
public ApiResponse<Dx> info(@PathVariable("id") Integer id) {
Dx info = dxService.findById(id);
return ApiResponse.success(info);
}
//后台-信息介绍添加接口
@PostMapping("/save")
public ApiResponse<Integer> save(@RequestBody Dx req) {
int result = dxService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//信息介绍删除(含批量删除)接口
@RequestMapping("/delete")
public ApiResponse<Integer> delete(@RequestBody Integer[] ids) {
int result = 0;
for (Integer id : ids) {
result = dxService.deleteById(id);
}
return ApiResponse.success(result);
}
//信息介绍修改接口
@PostMapping("/set")
public ApiResponse<Integer> set(@RequestBody Dx req) {
int result = dxService.saveOrUpdate(req);
return ApiResponse.success(result);
}
//获取所有信息介绍数据接口
@IgnoreAuth
@RequestMapping("/all")
public ApiResponse<Dx> dxAll() {
List<Dx> dxList = dxService.findAll();
return ApiResponse.success(dxList);
}
//根据条件(字符类型模糊匹配查询)获取信息介绍数据接口
@IgnoreAuth
@RequestMapping("/search")
public ApiResponse<Dx> dxSearch(Dx req) {
List<Dx> dxList = dxService.find(req);
return ApiResponse.success(dxList);
}
//根据条件(字符类型完全匹配查询)获取信息介绍数据接口
@IgnoreAuth
@RequestMapping("/searchByEqualTo")
public ApiResponse<Dx> dxSearchByEqualTo(Dx req) {
List<Dx> dxList = dxService.findByEqualTo(req);
return ApiResponse.success(dxList);
}
//按条件查询信息介绍分页数据方法(模糊匹配查询)
private PageData<Dx> getPageList(Dx req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dx> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dx> dxList = dxService.findPage(pageWrap);
return dxList;
}
//按条件查询信息介绍分页数据方法(完全匹配查询)
private PageData<Dx> getPageListByEqualTo(Dx req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dx> pageWrap = getPageWrap(req, pageNo, pageSize, sortProperty);
PageData<Dx> dxList = dxService.findPageByEqualTo(pageWrap);
return dxList;
}
//获取信息介绍查询数据搜索条件
private PageWrap<Dx> getPageWrap(Dx req, int pageNo, int pageSize, String sortProperty) {
PageWrap<Dx> pageWrap = new PageWrap<>();
pageWrap.setModel(req);
pageWrap.setPageNum(pageNo);
pageWrap.setPageSize(pageSize);
PageWrap.SortData sortData = new PageWrap.SortData();
sortData.setDirection("DESC");
sortData.setProperty(sortProperty);
List<PageWrap.SortData> sorts = new ArrayList<>();
sorts.add(sortData);
pageWrap.setSorts(sorts);
return pageWrap;
}
}

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="logbackLevel" source="logback.level"/>
<springProperty scope="context" name="logbackAppender" source="logback.appender"/>
<!-- 开发环境(输出到控制台) -->
<appender name="development" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- 设置日志输出格式 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!-- 输出编码 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 测试/线上环境(通过日期分割日志文件) -->
<appender name="production"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/dyspringboot.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件名配置 -->
<fileNamePattern>log/dyspringboot-%d.%i.log</fileNamePattern>
<!-- 日志文件保存期限(单位天) -->
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- 设置日志文件大小默认值是10MB-->
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<!-- 设置日志输出格式 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!-- 输出编码 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 设置日志级别和输出模式 -->
<root level="${logbackLevel}">
<appender-ref ref="${logbackAppender}" />
</root>
</configuration>
Loading…
Cancel
Save