基于javaweb+SSM甜品冰淇淋奶茶店网上订餐系统(前台、后台)
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
*/
public long getTotal() {
return adminDao.getTotal();
}
/**
* 通过id查询
* @param id
* @return
*/
public Admins get(int id) {
return adminDao.selectById(id);
}
/**
* 添加
* @param admin
*/
public Integer add(Admins admin) {
admin.setPassword(SafeUtil.encode(admin.getPassword()));
return adminDao.insert(admin);
}
/**
* 更新
* @param user
*/
this.paytype = paytype;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public String getAddress() {
return address;
}
public String topay(int orderid, ServletRequest request, Model model) {
model.addAttribute("typeList", typeService.getList());
request.setAttribute("order", orderService.get(orderid));
return "/index/pay.jsp";
}
/**
* 支付(模拟)
* @return
*/
@RequestMapping("/pay")
public String pay(Orders order, Model model) {
model.addAttribute("typeList", typeService.getList());
orderService.pay(order);
return "redirect:payok?orderid="+order.getId();
}
/**
* 支付成功
* @return
u.setPhone(user.getPhone());
u.setAddress(user.getAddress());
userService.update(u); // 更新数据库
session.setAttribute("user", u); // 更新session
model.addAttribute("msg", "信息修改成功!");
// 修改密码
if(user.getPasswordNew()!=null && !user.getPasswordNew().trim().isEmpty()) {
if (user.getPassword()!=null && !user.getPassword().trim().isEmpty()
&& SafeUtil.encode(user.getPassword()).equals(u.getPassword())) {
if (user.getPasswordNew()!=null && !user.getPasswordNew().trim().isEmpty()) {
u.setPassword(SafeUtil.encode(user.getPasswordNew()));
}
userService.update(u); // 更新数据库
session.setAttribute("user", u); // 更新session
model.addAttribute("msg", "密码修改成功!");
}else {
model.addAttribute("msg", "原密码错误!");
}
}
return "/index/my.jsp";
}
}
public void setCover(String cover) {
this.cover = cover == null ? null : cover.trim();
}
public String getImage1() {
return image1;
}
public void setImage1(String image1) {
this.image1 = image1 == null ? null : image1.trim();
}
public String getImage2() {
return image2;
}
<if test="goodId != null" >
good_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="price != null" >
#{price,jdbcType=INTEGER},
</if>
<if test="amount != null" >
#{amount,jdbcType=INTEGER},
</if>
<if test="orderId != null" >
#{orderId,jdbcType=INTEGER},
</if>
<if test="goodId != null" >
#{goodId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByIdSelective" parameterType="com.entity.Items" >
update items
<set >
<if test="price != null" >
price = #{price,jdbcType=INTEGER},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=INTEGER},
this.typeId = typeId;
}
}
package com.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.entity.Goods;
public interface GoodsDao {
int deleteById(Integer id);
int insert(Goods record);
int insertSelective(Goods record);
Goods selectById(Integer id);
int updateByIdSelective(Goods record);
int updateById(Goods record);
// 以上为mybatis generator自动生成接口, 具体实现在mapper.xml中
</li>
<li data-thumb="../${good.image1}">
<div class="thumb-image"> <img src="../${good.image1}" data-imagezoom="true" class="img-responsive"> </div>
</li>
<li data-thumb="../${good.image2}">
<div class="thumb-image"> <img src="../${good.image2}" data-imagezoom="true" class="img-responsive"> </div>
</li>
</ul>
</div>
</div>
<div class="col-md-4 single-grid simpleCart_shelfItem">
<h3>${good.name}</h3>
<div class="tag">
<p>分类 : <a href="goods?typeid=${good.type.id}">${good.type.name}</a></p>
</div>
* @return
*/
public static String getPageTool(HttpServletRequest request, long total, int page, int size){
long pages = total % size ==0 ? total/size : total /size + 1;
pages = pages==0 ? 1 : pages;
String url = request.getRequestURL().toString();
StringBuilder queryString = new StringBuilder();
Enumeration<String> enumeration = request.getParameterNames();
try { // 拼装请求参数
while (enumeration.hasMoreElements()) {
String element = (String) enumeration.nextElement();
if(!element.contains("page")) { // 跳过page参数
queryString.append("&").append(element).append("=").append(java.net.URLEncoder.encode(request.getParameter(element),"UTF-8"));
}
* 产品更新
*
* @return
* @throws Exception
*/
@RequestMapping("/goodUpdate")
public String goodUpdate(int id, String name, int price, String intro, int stock, int typeId,
MultipartFile cover, MultipartFile image1, MultipartFile image2,
@RequestParam(required=false, defaultValue="1") int page) throws Exception {
Goods good = goodService.get(id);
good.setName(name);
good.setPrice(price);
good.setIntro(intro);
good.setStock(stock);
good.setTypeId(typeId);
运行环境
Java≥8、Tomcat≥7.0、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL jQuery Bootstrap JavaScript CSS
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
分为前台和后台管理
前台用户可以注册、登录、查看商品列表与商品详情、加入购物车、下单购买等
后台管理员可以管理用户、商品、分类、订单等
前台
后台