package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 餐品订单
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/caipinOrder")
public class CaipinOrderController {
private static final Logger logger = LoggerFactory.getLogger(CaipinOrderController.class);
@Autowired
private CaipinOrderService caipinOrderService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private AddressService addressService;
@Autowired
private CaipinService caipinService;
@Autowired
private YonghuService yonghuService;
@Autowired
private CaipinCommentbackService caipinCommentbackService;
@Autowired
private CartService cartService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = caipinOrderService.queryPage(params);
//字典表数据转换
List<CaipinOrderView> list =(List<CaipinOrderView>)page.getList();
for(CaipinOrderView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
CaipinOrderEntity caipinOrder = caipinOrderService.selectById(id);
if(caipinOrder !=null){
//entity转view
CaipinOrderView view = new CaipinOrderView();
BeanUtils.copyProperties( caipinOrder , view );//把实体数据重构到view中
//级联表
AddressEntity address = addressService.selectById(caipinOrder.getAddressId());
if(address != null){
BeanUtils.copyProperties( address , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setAddressId(address.getId());
view.setAddressYonghuId(address.getYonghuId());
}
//级联表
CaipinEntity caipin = caipinService.selectById(caipinOrder.getCaipinId());
if(caipin != null){
BeanUtils.copyProperties( caipin , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setCaipinId(caipin.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(caipinOrder.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody CaipinOrderEntity caipinOrder, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,caipinOrder:{}",this.getClass().getName(),caipinOrder.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
caipinOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
caipinOrder.setInsertTime(new Date());
caipinOrder.setCreateTime(new Date());
caipinOrderService.insert(caipinOrder);
return R.ok();
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody CaipinOrderEntity caipinOrder, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,caipinOrder:{}",this.getClass().getName(),caipinOrder.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// caipinOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<CaipinOrderEntity> queryWrapper = new EntityWrapper<CaipinOrderEntity>()
.eq("id",0)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
CaipinOrderEntity caipinOrderEntity = caipinOrderService.selectOne(queryWrapper);
if(caipinOrderEntity==null){
caipinOrderService.updateById(caipinOrder);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
caipinOrderService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<CaipinOrderEntity> caipinOrderList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String s
没有合适的资源?快使用搜索试试~ 我知道了~
weixin202便捷饭店点餐小程序的设计与实现ssm.zip
共433个文件
svg:162个
java:106个
vue:56个
需积分: 0 1 下载量 111 浏览量
2023-12-21
14:41:42
上传
评论 2
收藏 20.4MB ZIP 举报
温馨提示
weixin202便捷饭店点餐小程序的设计与实现ssm.zip
资源推荐
资源详情
资源评论
收起资源包目录
weixin202便捷饭店点餐小程序的设计与实现ssm.zip (433个子文件)
3-build.bat 16B
2-run.bat 14B
1-install.bat 12B
app.ef5fb5bc.css 259KB
bootstrap.css 149KB
bootstrap.min.css 118KB
chunk-vendors.a72b0961.css 37KB
style.css 2KB
glyphicons-halflings-regular.eot 20KB
index.html 933B
index.html 585B
favicon.ico 4KB
favicon.ico 4KB
CaipinOrderController.java 27KB
CommonController.java 23KB
YonghuController.java 19KB
AddressController.java 16KB
CaipinController.java 13KB
CartController.java 13KB
CaipinCommentbackController.java 13KB
DictionaryController.java 11KB
CaipinOrderView.java 11KB
NewsController.java 10KB
CaipinCommentbackView.java 8KB
CartView.java 8KB
CaipinEntity.java 7KB
CaipinOrderEntity.java 6KB
YonghuEntity.java 6KB
CaipinVO.java 6KB
AddressEntity.java 5KB
MPUtil.java 5KB
CaipinModel.java 5KB
DictionaryServiceImpl.java 5KB
CaipinOrderVO.java 5KB
CaipinCommentbackEntity.java 5KB
CommonServiceImpl.java 5KB
UsersController.java 5KB
YonghuVO.java 5KB
CaipinOrderModel.java 5KB
DictionaryEntity.java 4KB
CartEntity.java 4KB
YonghuModel.java 4KB
AddressVO.java 4KB
NewsEntity.java 4KB
AddressModel.java 4KB
CaipinCommentbackVO.java 4KB
CommonDao.java 4KB
BaiduUtil.java 4KB
CommonService.java 4KB
PoiUtil.java 4KB
CaipinCommentbackModel.java 3KB
AddressView.java 3KB
DictionaryVO.java 3KB
AuthorizationInterceptor.java 3KB
CartVO.java 3KB
DictionaryModel.java 3KB
CartModel.java 3KB
ConfigController.java 3KB
NewsVO.java 3KB
FileController.java 3KB
NewsModel.java 3KB
Query.java 3KB
TokenServiceImpl.java 2KB
DictionaryServletContextListener.java 2KB
TokenEntity.java 2KB
PageUtils.java 2KB
CaipinView.java 2KB
CaipinCommentbackServiceImpl.java 1KB
UsersServiceImpl.java 1KB
CaipinOrderServiceImpl.java 1KB
AddressServiceImpl.java 1KB
NewsView.java 1KB
YonghuServiceImpl.java 1KB
CaipinServiceImpl.java 1KB
YonghuView.java 1KB
NewsServiceImpl.java 1KB
CartServiceImpl.java 1KB
UsersEntity.java 1KB
SpringContextUtils.java 1KB
ValidatorUtils.java 1KB
SQLFilter.java 1KB
DictionaryView.java 1KB
HttpClientUtils.java 1013B
ConfigEntity.java 930B
ConfigServiceImpl.java 929B
R.java 884B
EIException.java 845B
JQPageInfo.java 790B
FileUtil.java 759B
TokenService.java 752B
MyThreadMethod.java 737B
TypeEnum.java 728B
UsersService.java 622B
MyMetaObjectHandler.java 620B
DictionaryService.java 611B
CaipinCommentbackDao.java 577B
CommonUtil.java 568B
UsersDao.java 562B
TokenDao.java 560B
CaipinOrderDao.java 547B
共 433 条
- 1
- 2
- 3
- 4
- 5
资源评论
写JAVA代码的人
- 粉丝: 3185
- 资源: 100
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功