基于javaweb+mysql的ssh微信小程序商城+后台管理系统(java+ssh+jsp+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSH微信小程序商城+后台管理系统(java+ssh+jsp+jquery+mysql)
项目介绍
本项目为小程序商城系统前后台,前台为普通会员用户登录,后台为管理员登录;
程序功能: 1.小程序前台:用户注册登录、首页、轮播图、新品推荐、分类、购物车、我的订单。 2.网站后台:管理员登录、用户管理、商品类别管理、商品管理、订单管理、公告管理;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目: 否;
技术栈
- 后端:spring+struts+hibernate 2. 前端:JSP+css+javascript+jquery
使用说明
后台运行: 1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中config/jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/shop 管理员:admin/111111
前台小程序运行: 1.使用微信开发者工具导入项目; 2.导入成功后编译运行; 3.运行成功后登录账号; 普通用户:ceshi/111111
public String userpp(){
HttpServletRequest request = getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
List<Pp> listByAlias = ppService.listByAlias("from Pp where 1=1 and lb.id="+lbId, null);
if(!isEmpty(listByAlias)){
for(Pp p : listByAlias){
String string = basePath+p.getCpUrl();
String replaceAll;
try {
replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
p.setCpUrl(replaceAll);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
jsonMap.put("pps", listByAlias);
return "json";
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
lb.setIsDelete(0);
lbService.save(lb);
ActionContext.getContext().put("url", "/lb_lb.do");
return "redirect";
}
/**
* 查看详情页面
* @return
*/
ActionContext.getContext().put("Obj", pp);
getActionContext().put("lbId", lbId);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
getActionContext().put("lbId", lbId);
return SUCCESS;
}
/**
* 执行添加
* @return
* @throws IOException
*/
public String exAdd() throws IOException{
if(fileFileName != null){
String root = "D:/my/upload";
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create()+fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
System.out.println("fileFileName: " + fileFileName);
System.out.println("file: " + file.getName());
System.out.println("file: " + file.getPath());
byte[] buffer = new byte[500];
int length = 0;
while(-1 != (length = is.read(buffer, 0, buffer.length)))
{
os.write(buffer);
}
os.close();
is.close();
pp.setCpUrl("\\upload\\"+fileFileName);
}
Lb lb = new Lb();
lb.setId(lbId);
pp.setLb(lb);
* @return
*/
public String exUpdate(){
Car n = carService.getById(car.getId());
carService.update(n);
ActionContext.getContext().put("url", "/car_car.do");
return "redirect";
}
/**
* 删除
* @return
*/
public String delete(){
carService.delete2(car.getId());
return "json";
}
//=============公=======共=======方=======法==========区=========end============//
//-------------------------华丽分割线---------------------------------------------//
//=============自=======定=======义=========方=======法==========区=========start============//
//=============自=======定=======义=========方=======法==========区=========end============//
}
package com.my.pro.action;
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
}
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String goods(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Goods where 1=1 and isDelete= 0");
sb = sb.append("order by id desc");
Pager<Goods> pagers = goodsService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", goods);
return SUCCESS;
}
public String userSrarch() throws UnsupportedEncodingException{
StringBuffer sb = new StringBuffer();
Map<String,Object> alias = new HashMap<String,Object>();
sb = sb.append("from Goods where 1=1 and isDelete= 0");
if(goods!=null && goods.getTitle() !=null && !"".equals(goods.getTitle())){
String str = URLDecoder.decode((new String(goods.getTitle().getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
sb.append(" and title like :realName ");
alias.put("realName", "%" +str+ "%" );
}
sb = sb.append("order by id desc");
List<Goods> list = goodsService.listByAlias(sb.toString(),alias);
HttpServletRequest request = getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
if(!isEmpty(list)){
for(Goods g : list){
String string = basePath+g.getUrl1();
String replaceAll;
@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends BaseAction implements ModelDriven<Manage>{
private Manage manage;
@Autowired
private UserService userService;
@Autowired
private ManageService manageService;
private int userId;
private String userName;
private int sayId;
private String new1;
public String getNew1() {
return new1;
}
public void setNew1(String new1) {
this.new1 = new1;
}
/**
* 登陆以后进入首页
* @return
*/
public String index(){
Manage ma = manageService.login(manage);
if(ma == null){
return "login";
}
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("userName", ma.getName());
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private DdService ddService;
private String ids;
private Integer userId;
//依赖注入 end dao/service/===
@Autowired
private CarService carService;
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
d.setPhone(dd.getPhone());
d.setAddress(address);
d.setUser(user);
//购物车阐述
List<Car> listByAlias = carService.listByAlias("from Car where goods.id="+Integer.parseInt(split[i]),null );
if(!isEmpty(listByAlias)){
carService.delete(listByAlias.get(0).getId());
}
ddService.save( d);
}
}
}
return "json";
}
public String userList(){
HttpServletRequest request = getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
List<DdDto> dds = new ArrayList<DdDto>();
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Dd where 1=1 and user.id= "+userId);
if(dd!=null && dd.getCode() !=null && !"".equals(dd.getCode())){
sb.append(" and code like :realName ");
alias.put("realName", "%" +dd.getCode()+ "%" );
}
sb = sb.append("order by id desc");
List<Dd> pagers = ddService.listByAlias(sb.toString(),alias);
if(!isEmpty(pagers)){
for(Dd d :pagers){
DdDto do2 = new DdDto();
String string = basePath+d.getGoods().getUrl1();
String replaceAll;
try {
replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
do2.setPpUrl(replaceAll);
do2.setCode(d.getCode());
do2.setDdId(d.getId());
do2.setPrice(String.valueOf(d.getGoods().getPrice()));
*/
public String view(){
Goods n = goodsService.getById(goods.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
getActionContext().put("pps", ppService.listByAlias("from Pp ", null));
Goods n = goodsService.getById(goods.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 执行修改
* @return
* @throws IOException
*/
public String exUpdate() throws IOException{
Goods n = goodsService.getById(goods.getId());
if (file != null) {
for (int i = 0; i < file.size(); i++) {
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
String root = "D:/my/upload";
InputStream is = new FileInputStream(file.get(i));
String f = fileFileName.get(i);
f = UUIDUtils.create() + i + fileFileName.get(i);
OutputStream os = new FileOutputStream(new File(root, f));
byte[] buffer = new byte[500];
int length = 0;
while (-1 != (length = is.read(buffer, 0, buffer.length))) {
os.write(buffer);
}
os.close();
is.close();
if (i == 0){
n.setUrl1("\\upload\\" + f);
}
if (i == 1){
n.setUrl2("\\upload\\" + f);
}
if (i == 2){
n.setUrl3("\\upload\\" + f);
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
public String jsonAction() {
// dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
}
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String lb(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Lb where 1=1 and isDelete = 0");
sb = sb.append("order by id desc");
Pager<Lb> pagers = lbService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", lb);
return SUCCESS;
}
/**
* 微信查询品牌集合
* @return
*/
public String userLb(){
HttpServletRequest request = getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
public String welcome(){
return SUCCESS;
}
}
package com.my.pro.action;
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
public String jsonAction() {
// dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
//chain
public static final String CHAIN = "chain";
public Map<String, Object> jsonMap = new HashMap<String, Object>();
//===================================================================
public Map<String, Object> getJsonMap() {
return jsonMap;
}
public void setJsonMap(Map<String, Object> jsonMap) {
this.jsonMap = jsonMap;
}
//===================================================================
/**
* 獲取request
* @return
*/
public HttpServletRequest getRequest() {
return ServletActionContext.getRequest();
}
/**
* 获取response
* @return
*/
public HttpServletResponse getResponse() {
return ServletActionContext.getResponse();
}
public HttpSession getSession() {
return getRequest().getSession();
}
public ServletContext getServletContext() {
return ServletActionContext.getServletContext();
}
/**
* 存值
* @return
*/
public ActionContext getActionContext(){
return ActionContext.getContext();
out = resp.getWriter();
out.write(js.toString());
}
public void editmanage2() throws IOException{
HttpServletResponse resp = ServletActionContext.getResponse();
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = null;
//Manage ma = manageService.getById(manage.getId());
/*ma.setPassWord(manage.getPassWord());
ma.setRealName(manage.getRealName());
ma.setName(manage.getName());
ma.setId(manage.getId());*/
manageService.updateInfo(manage);
out = resp.getWriter();
out.write(JSONArray.fromObject(1).toString());
}
public String delManage(){
manageService.deleteInfo(manage.getId());
ActionContext.getContext().put("url", "/manage_manage.do");
return "redirect";
}
//=============================================================================================================
sb.append(" and code like :realName ");
alias.put("realName", "%" +dd.getCode()+ "%" );
}
sb = sb.append("order by id desc");
Pager<Dd> pagers = ddService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", dd);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
* @throws UnsupportedEncodingException
*/
public String exAdd() throws UnsupportedEncodingException{
HttpServletRequest request = getRequest();
User user = userService.getById(userId);
String name = null;
String address = null;
// if(!isEmpty(dd.getName())){
// name = URLDecoder.decode((new String(dd.getName().getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
// }
// if(!isEmpty(dd.getAddress())){
// address = URLDecoder.decode((new String(dd.getAddress().getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
// }
if(!isEmpty(ids)){
String[] split = ids.split(",");
if(!isEmpty(split)){
for (int i = 0; i < split.length; i++) {
Goods byId = goodsService.getById(Integer.parseInt(split[i]));
Dd d = new Dd();
d.setAddress(dd.getAddress());
d.setCode(getOrderNo());
d.setCreateTime(new Date());
d.setGoods(byId);
d.setName(dd.getName());
sb = sb.append("from Dd where 1=1 ");
if(dd!=null && dd.getCode() !=null && !"".equals(dd.getCode())){
sb.append(" and code like :realName ");
alias.put("realName", "%" +dd.getCode()+ "%" );
}
sb = sb.append("order by id desc");
Pager<Dd> pagers = ddService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", dd);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
* @throws UnsupportedEncodingException
*/
public String exAdd() throws UnsupportedEncodingException{
HttpServletRequest request = getRequest();
User user = userService.getById(userId);
String name = null;
String address = null;
// if(!isEmpty(dd.getName())){
// name = URLDecoder.decode((new String(dd.getName().getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
// }
// if(!isEmpty(dd.getAddress())){
// address = URLDecoder.decode((new String(dd.getAddress().getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
// }
if(!isEmpty(ids)){
String[] split = ids.split(",");
if(!isEmpty(split)){
for (int i = 0; i < split.length; i++) {
Goods byId = goodsService.getById(Integer.parseInt(split[i]));
Dd d = new Dd();
d.setAddress(dd.getAddress());
d.setCode(getOrderNo());
d.setCreateTime(new Date());
d.setGoods(byId);
d.setName(dd.getName());
d.setPhone(dd.getPhone());
}
public void setPass(String pass) {
this.pass = pass;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
private String name;
private String pass;
private String phone;
private String userName;//用户名
private String passWord;//密码
private String realName;
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
/**
* 图片上传
* @return
* @throws Exception
*/
/*public String fileUpload() throws Exception{
HttpSession session = ServletActionContext.getRequest().getSession();
if(session.getAttribute("userId") != null){
int userId = Integer.parseInt( session.getAttribute("userId").toString());
String root = ServletActionContext.getServletContext().getRealPath("/")+"upload";
//String root = ServletActionContext.getServletContext().getRealPath("upload");
//String root = ServletActionContext.getRequest().getContextPath()+"/"+"upload";
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create()+fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
System.out.println("fileFileName: " + fileFileName);
System.out.println("file: " + file.getName());
System.out.println("file: " + file.getPath());
byte[] buffer = new byte[500];
int length = 0;
while(-1 != (length = is.read(buffer, 0, buffer.length)))
{
os.write(buffer);
}
os.close();
is.close();
//接下来存到说说表中
SayMood sayMood = new SayMood();
sayMood.setContent("\\upload\\"+fileFileName);
sayMood.setCreateTime(new Date());
sayMood.setDzs(0);
sayMood.setIsDelete(2);
sayMood.setType(2);
User u = userService.getUser(userId);
sayMood.setSayUser(u);
sayMoodService.save(sayMood);
*//**
* 积分规则还没有做。上传图片需要加积分
*//*
*/
/*public String userPhotos(){
Pager<SayMood> pagers = sayMoodService.findAllphotosById(userId);
ActionContext.getContext().put("pagers", pagers);
return SUCCESS;
}
*/
/**
* 删除照片
* @return
*/
/*public String delsay(){
sayMoodService.del(sayId);
ActionContext.getContext().put("url", "/manage_userPhotos.do");
return "redirect";
}*/
//删除用户
public String delUse(){
userService.delUse(userId);
ActionContext.getContext().put("url", "/manage_userList.do");
return "redirect";
}
/**
* 图片上传
* @return
* @throws Exception
*/
/*public String fileUpload() throws Exception{
HttpSession session = ServletActionContext.getRequest().getSession();
if(session.getAttribute("userId") != null){
int userId = Integer.parseInt( session.getAttribute("userId").toString());
String root = ServletActionContext.getServletContext().getRealPath("/")+"upload";
//String root = ServletActionContext.getServletContext().getRealPath("upload");
//String root = ServletActionContext.getRequest().getContextPath()+"/"+"upload";
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create()+fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
System.out.println("fileFileName: " + fileFileName);
System.out.println("file: " + file.getName());
System.out.println("file: " + file.getPath());
byte[] buffer = new byte[500];
int length = 0;
newsService.del(news);
ActionContext.getContext().put("url", "/news_newsnew.do?");
return "redirect";
}
//文件上传
//上传的文件对象
private File uploadFile;
//文件名称
private String uploadFileFileName;
//文件类型
private String uploadFileContentType;
public File getUploadFile() {
return uploadFile;
}
public void setUploadFile(File uploadFile) {
this.uploadFile = uploadFile;
}
public String getUploadFileFileName() {
return uploadFileFileName;
}
public void setUploadFileFileName(String uploadFileFileName) {
this.uploadFileFileName = uploadFileFileName;
}
public String getUploadFileContentType() {
return uploadFileContentType;
}
public void setUploadFileContentType(String uploadFileContentType) {
this.uploadFileContentType = uploadFileContentType;
}
public String fileUpload() throws Exception{
News news2 = new News();
news2.setTitle(news.getTitle());
news2.setIntroduction(news.getIntroduction());
news2.setContent(news.getContent());
news2.setCreateTime(new Date());
newsService.addInfo(news2);
ActionContext.getContext().put("url", "/news_newsnew.do");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
String time = format.format(c.getTime());
System.out.println(time);
return time;
}
public void reportSay() throws IOException{/*
HttpServletResponse resp = ServletActionContext.getResponse();
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = null;
//首先查询本月和上个月用户总人数
List<SayMood> users = sayMoodService.findSYusay();
List<SayMood> users2 = sayMoodService.findBYsay();
List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("NAME", getsy());
if(users != null && users.size()>0){
map1.put("TOTAL", users.size());
}else{
map1.put("TOTAL", 0);
}
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("NAME", getBy());
if(users2 != null && users2.size()>0){
map2.put("TOTAL", users2.size());
}else{
map2.put("TOTAL", 0);
}
list.add(map1);
list.add(map2);
//创建Option
GsonOption option = new GsonOption();
option.title("发表图片数").tooltip(Trigger.axis).legend("数量(人)");
//横轴为值轴
option.xAxis(new ValueAxis().boundaryGap(0d, 0.01));
//创建类目轴
CategoryAxis category = new CategoryAxis();
//柱状数据
Bar bar = new Bar("月份");
//饼图数据
Pie pie = new Pie("月份");
//循环数据
for (Map<String, Object> objectMap : list) {
//设置类目
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
os.write(buffer);
}
os.close();
is.close();
pp.setCpUrl("\\upload\\"+fileFileName);
}
Lb lb = new Lb();
lb.setId(lbId);
pp.setLb(lb);
ppService.save(pp);
ActionContext.getContext().put("url", "/pp_pp.do?lbId="+lbId);
return "redirect";
}
/**
* 微信查询品牌集合
* @return
*/
public String userPp(){
return "json";
}
/**
* 查看详情页面
* @return
*/
public String view(){
Pp n = ppService.getById(pp.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
getActionContext().put("lbId", lbId);
Pp n = ppService.getById(pp.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
}
}
goods.setIsDelete(0);
goodsService.save(goods);
ActionContext.getContext().put("url", "/goods_goods.do");
return "redirect";
}
/**
* 查看详情页面
* @return
*/
public String view(){
Goods n = goodsService.getById(goods.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
getActionContext().put("pps", ppService.listByAlias("from Pp ", null));
Goods n = goodsService.getById(goods.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 执行修改
* @return
* @throws IOException
*/
public String exUpdate() throws IOException{
Goods n = goodsService.getById(goods.getId());
if (file != null) {
for (int i = 0; i < file.size(); i++) {
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
String root = "D:/my/upload";
InputStream is = new FileInputStream(file.get(i));
String f = fileFileName.get(i);
f = UUIDUtils.create() + i + fileFileName.get(i);
OutputStream os = new FileOutputStream(new File(root, f));
byte[] buffer = new byte[500];
}
public String newList(){
Pager<News> pagers = newsService.list(titles);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("titles", titles);
return SUCCESS;
}
public String add(){
News newN = newsService.getById(1);
getActionContext().put("dddd", newN);
return SUCCESS;
}
public String updatenew(){
News newN = newsService.getById(1);
newN.setContent(news.getContent());
newN.setTitle(news.getTitle());
newsService.update(newN);
ActionContext.getContext().put("url", "/news_add.do");
return "redirect";
}
public String exAdd(){
newsService.add(news);
ActionContext.getContext().put("url", "/news_newList.do");
return "redirect";
}
public String del(){
News newN = newsService.load(news);
newsService.del(news);
ActionContext.getContext().put("url", "/news_newsnew.do?");
return "redirect";
}
//文件上传
//上传的文件对象
private File uploadFile;
//文件名称
private String uploadFileFileName;
//文件类型
private String uploadFileContentType;
public File getUploadFile() {
}
}
HttpServletRequest request = getRequest();
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
if(!isEmpty(gg)){
for(CarGoods g2 : gg){
String string = basePath+g2.getGoods().getUrl1();
String replaceAll = null;
try {
replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
g2.getGoods().setUrl1(replaceAll);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
jsonMap.put("listgoods",gg);
return "json";
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
List<Goods> listByAlias = goodsService.listByAlias("from Car where user.id="+userId+"and goods.id="+goodsId, null);
if(isEmpty(listByAlias)){
User user = new User();
user.setId(userId);
Goods byId = goodsService.getById(goodsId);
car.setGoods(byId);
car.setUser(user);
carService.save(car);
}
jsonMap.put("result", 1);
return "json";
}
public String exAdd() throws IOException{
if(fileFileName != null){
String root = "D:/my/upload";
InputStream is = new FileInputStream(file);
fileFileName = UUIDUtils.create()+fileFileName;
OutputStream os = new FileOutputStream(new File(root, fileFileName));
System.out.println("fileFileName: " + fileFileName);
System.out.println("file: " + file.getName());
System.out.println("file: " + file.getPath());
byte[] buffer = new byte[500];
int length = 0;
while(-1 != (length = is.read(buffer, 0, buffer.length)))
{
os.write(buffer);
}
os.close();
is.close();
pp.setCpUrl("\\upload\\"+fileFileName);
}
Lb lb = new Lb();
lb.setId(lbId);
pp.setLb(lb);
ppService.save(pp);
ActionContext.getContext().put("url", "/pp_pp.do?lbId="+lbId);
return "redirect";
}
/**
* 微信查询品牌集合
* @return
*/
public String userPp(){
return "json";
}
/**
* 查看详情页面
* @return
*/
public String view(){
Pp n = ppService.getById(pp.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends BaseAction implements ModelDriven<Manage>{
private Manage manage;
@Autowired
private UserService userService;
@Autowired
private ManageService manageService;
private int userId;