package com.daowen.controller;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.daowen.entity.Lanmu;
import com.daowen.service.*;
import com.daowen.util.JsonResult;
import com.daowen.vo.LanmuVo;
import com.daowen.vo.ShangpinVo;
import com.daowen.vo.SpcommentVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.daowen.entity.Shangpin;
import com.daowen.ssm.simplecrud.SimpleController;
import com.daowen.util.SequenceUtil;
import com.daowen.webcontrol.PagerMetal;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class ShangpinController extends SimpleController {
@Override
@RequestMapping("/admin/shangpinmanager.do")
public void mapping(HttpServletRequest request, HttpServletResponse response) {
mappingMethod(request, response);
}
@ResponseBody
@PostMapping("/admin/shangpin/mylanmu")
public JsonResult list(){
List<LanmuVo> listLanmu=shangpinSrv.getMyLanmus();
return JsonResult.success(1,"获取栏目",listLanmu);
}
@ResponseBody
@PostMapping("/admin/shangpin/count")
public JsonResult counttongji(){
String sql=" select lm.name ,count(*) as value from shangpin sp,lanmu lm where lm.id=sp.typeid ";
String pubren=request.getParameter("pubren");
if(pubren!=null)
sql+=" and sp.pubren="+pubren;
sql+=" group by sp.typeid,lm.name ";
List<HashMap<String,Object>> listTongji=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"",listTongji);
}
@ResponseBody
@PostMapping("/admin/shangpin/saledstat")
public JsonResult saleStat(){
String sql=" select sp.name as name,sum(count) as value from shangpin sp,orderitem oi where sp.id=oi.spid ";
String pubren=request.getParameter("pubren");
if(pubren!=null)
sql+=" and sp.pubren="+pubren;
sql+=" group by sp.id,sp.name ";
List<HashMap<String,Object>> listTongji=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"",listTongji);
}
/**
* 浏览排行榜
* @return
*/
@ResponseBody
@PostMapping("/admin/shangpin/hotclick")
public JsonResult hotclick(){
HashMap map=new HashMap();
map.put("order","order by clickcount desc");
map.put("topcount",5);
List<ShangpinVo> listShangpin=shangpinSrv.find(map);
return JsonResult.success(1,"热销产品",listShangpin);
}
@ResponseBody
@PostMapping("/admin/shangpin/hotsales")
public JsonResult hotSales(){
String sql=" select sp.*,t.saledcount from shangpin sp inner join (select oi.spid,sum(oi.count) as saledcount from shorder o ,orderitem oi where o.id=oi.orderid and o.state!=1 group by oi.spid) t on t.spid=sp.id order by saledcount desc limit 10 ";
List<HashMap<String,Object>> listMap=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"热销产品",listMap);
}
@ResponseBody
@GetMapping("/admin/shangpin/type")
public JsonResult getTypes(){
List<Lanmu> listLanmu=lanmuSrv.getEntity("where type=2");
return JsonResult.success(1,"获取 商品类别",listLanmu);
}
@RequestMapping("/admin/shangpin/info")
@ResponseBody
public JsonResult info() {
String id = request.getParameter("id");
String hyid=request.getParameter("hyid");
ShangpinVo shangpin = null;
if (id == null) {
return JsonResult.error(-1, "参数异常");
}
shangpin = shangpinSrv.loadPlus(Integer.parseInt(id));
if(hyid!=null){
shangpinSrv.executeUpdate("update shangpin set clickcount=clickcount+1 where id="+id);
}
return JsonResult.success(1, "获取 商品信息", shangpin);
}
public void shenpi() {
String id = request.getParameter("id");
String forwardurl = request.getParameter("forwardurl");
String spstate = request.getParameter("spstate");
String reply = request.getParameter("reply");
String shenpiren = request.getParameter("shenpiren");
int statuscode = 3;
// 验证错误url
String errorurl = request.getParameter("errorurl");
if (id == null)
return;
Shangpin shangpin = shangpinSrv.load(" where id=" + id);
if (shangpin == null)
return;
if (spstate != null)
statuscode = Integer.parseInt(spstate);
shangpin.setSpstate(statuscode);
shangpinSrv.update(shangpin);
if (forwardurl == null) {
forwardurl = "/admin/shangpinmanager.do?actiontype=get";
}
redirect(forwardurl);
}
@ResponseBody
@PostMapping("/admin/shangpin/shangjia")
public JsonResult shangjia() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " update shangpin set state=1 where id in("
+ join(spliter, ids) + ")";
int count=shangpinSrv.executeUpdate(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"上架成功",jsonObject);
}
@ResponseBody
@PostMapping("/admin/shangpin/xiajia")
public JsonResult xiajia() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " update shangpin set state=2 where id in("
+ join(spliter, ids) + ")";
int count=shangpinSrv.executeUpdate(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"下架成功",jsonObject);
}
public void kucunadd() {
String forwardurl = request.getParameter("forwardurl");
String id = request.getParameter("id");
String supplor = request.getParameter("supplor");
String cgdate = request.getParameter("cgdate");
String cgren = request.getParameter("cgren");
if (id == null)
return;
Shangpin shangpin = shangpinSrv.load(new Integer(id));
if (shangpin == null)
return;
String shuliang = request.getParameter("shuliang");
String danwei = request.getParameter("danwei");
if (shuliang != null) {
shangpin.setKucun(shangpin.getKucun() + Integer.parseInt(shuliang));
shangpin.setDanwei(danwei);
shangpinSrv.update(shangpin);
}
if (forwardurl == null) {
forwardurl = "/admin/shangpinmanager.do?actiontype=get";
}
redirect(forwardurl);
}
@ResponseBody
@PostMapping("/admin/shangpin/comment/list")
public JsonResult spcomment(){
String id=request.getParameter("id");
String hyid=request.getParameter("hyid");
HashMap map=new HashMap();
if(id==null)
map.put("id",id);
if(hyid!=null)
map.put("hyid",hyid);
List<SpcommentVo> listMap=shangpinSrv.getComment(map);
return JsonResult.success(1,"获取评论信息",listMap);
}
@ResponseBody
@PostMapping("/admin/shangpin/delete")
public JsonResult delete() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " where id in(" + join(spliter, ids)+ ")";
int count=shangpinSrv.delete(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"删除成功",jsonObject);
}
public void save() {
String forwardurl = request.getParameter("forwardurl");
String name = request.getParameter("name");
String jiage = request.getParameter("jiage");
String tuijian = request.getParameter("tuijian");
St
code.song
- 粉丝: 1075
- 资源: 1214
最新资源
- 西电微机原理实验四:微机原理实验中8255可编程并行接口的应用实践
- 西电微机原理课程实验指南-理论与实践相结合提升技术素养
- 基于go+gin+vue+element admin 后台管理系统,支持用户管理,认证,内容管理等详细文档+优秀项目+全部资料.zip
- 基于go-kratos +Ant Design Pro的前后端分离微服务管理系统后端模块详细文档+优秀项目+全部资料.zip
- 基于Golang 的后台管理系统(基础版)详细文档+优秀项目+全部资料.zip
- CR750CR751 控制器操作说明书(故障排除).pdf
- 基于goframe搭建的电商前后台API系统详细文档+优秀项目+全部资料.zip
- linux常用命令大全.txt
- 基于golang的分布式即时通讯系统详细文档+优秀项目+全部资料.zip
- linux常用命令大全.txt
- 基于Golang的个人简易博客系统详细文档+优秀项目+全部资料.zip
- 基于Golang实现的单点登录系统(go-sso),实现手机号注册、手机号+验证码登录、手机号+密码登录、账号登出等功能,用户认证采用cookie和jwt两种方式详细文档+优秀项目+全部资料.zip
- 基于Golang+Markdown的博客系统详细文档+优秀项目+全部资料.zip
- 基于golang实现的分布式聊天系统,支持i一对一聊天,聊天室等详细文档+优秀项目+全部资料.zip
- 基于Golang的开源社区系统。简洁对话,高效互动,详细文档+优秀项目+全部资料.zip
- 基于Golang重构考试系统详细文档+优秀项目+全部资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈