包含源程序,数据库脚本。代码和数据库脚本都有详细注释。课题设计仅供参考学习使用,可以在此基础上进行扩展完善
代码已经上传github,下载地址 https://github.com/21503882/auction
开发环境:
Eclipse ,MYSQL,JDK1.8,Tomcat 7
涉及技术点:
MVC模式、SpringMvc、Mybatis、Spring、bootstrap、HTML、JavaScript、CSS、JQUERY、log4j、Ajax、maven等
系统采用Mybatis框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.8. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离
主要功能:
卖家中心
package com.beifeng.common;
/**
* 定义日志收集客户端收集得到的用户数据参数的name名称
* 以及event_logs这张hbase表的结构信息
* 用户数据参数的name名称就是event_logs的列名
*
* @author gerry
*
*/
public class EventLogConstants {
/**
* 事件枚举类。指定事件的名称
*
* @author gerry
*
*/
public static enum EventEnum {
LAUNCH(1, "launch event", "e_l"), // launch事件,表示第一次访问
PAGEVIEW(2, "page view event", "e_pv"), // 页面浏览事件
CHARGEREQUEST(3, "charge request event", "e_crt"), // 订单生产事件
CHARGESUCCESS(4, "charge success event", "e_cs"), // 订单成功支付事件
CHARGEREFUND(5, "charge refund event", "e_cr"), // 订单退款事件
EVENT(6, "event duration event", "e_e") // 事件
;
public final int id; // id 唯一标识
public final String name; // 名称
public final String alias; // 别名,用于数据收集的简写
private EventEnum(int id, String name, String alias) {
this.id = id;
this.name = name;
this.alias = alias;
}
/**
* 获取匹配别名的event枚举对象,如果最终还是没有匹配的值,那么直接返回null。
*
* @param alias
* @return
*/
public static EventEnum valueOfAlias(String alias) {
for (EventEnum event : values()) {
if (event.alias.equals(alias)) {
return event;
}
}
return null;
}
}
/**
* 表名称
*/
public static final String HBASE_NAME_EVENT_LOGS = "event_logs";
/**
* event_logs表的列簇名称
*/
public static final String EVENT_LOGS_FAMILY_NAME = "info";
/**
* 日志分隔符
*/
public static final String LOG_SEPARTIOR = "\\^A";
/**
* 用户ip地址
*/
public static final String LOG_COLUMN_NAME_IP = "ip";
/**
* 服务器时间
*/
public static final String LOG_COLUMN_NAME_SERVER_TIME = "s_time";
/**
* 事件名称
*/
public static final String LOG_COLUMN_NAME_EVENT_NAME = "en";
/**
* 数据收集端的版本信息
*/
public static final String LOG_COLUMN_NAME_VERSION = "ver";
/**
* 用户唯一标识符
*/
public static final String LOG_COLUMN_NAME_UUID = "u_ud";
/**
* 会员唯一标识符
*/
public static final String LOG_COLUMN_NAME_MEMBER_ID = "u_mid";
/**
* 会话id
*/
public static final String LOG_COLUMN_NAME_SESSION_ID = "u_sd";
/**
* 客户端时间
*/
public static final String LOG_COLUMN_NAME_CLIENT_TIME = "c_time";
/**
* 语言
*/
public static final String LOG_COLUMN_NAME_LANGUAGE = "l";
/**
* 浏览器user agent参数
*/
public static final String LOG_COLUMN_NAME_USER_AGENT = "b_iev";
/**
* 浏览器分辨率大小
*/
public static final String LOG_COLUMN_NAME_RESOLUTION = "b_rst";
/**
* 定义platform
*/
public static final String LOG_COLUMN_NAME_PLATFORM = "pl";
/**
* 当前url
*/
public static final String LOG_COLUMN_NAME_CURRENT_URL = "p_url";
/**
* 前一个页面的url
*/
public static final String LOG_COLUMN_NAME_REFERRER_URL = "p_ref";
/**
* 当前页面的title
*/
public static final String LOG_COLUMN_NAME_TITLE = "tt";
/**
* 订单id
*/
public static final String LOG_COLUMN_NAME_ORDER_ID = "oid";
/**
* 订单名称
*/
public static final String LOG_COLUMN_NAME_ORDER_NAME = "on";
/**
* 订单金额
*/
public static final String LOG_COLUMN_NAME_ORDER_CURRENCY_AMOUNT = "cua";
/**
* 订单货币类型
*/
public static final String LOG_COLUMN_NAME_ORDER_CURRENCY_TYPE = "cut";
/**
* 订单支付金额
*/
public static final String LOG_COLUMN_NAME_ORDER_PAYMENT_TYPE = "pt";
/**
* category名称
*/
public static final String LOG_COLUMN_NAME_EVENT_CATEGORY = "ca";
/**
* action名称
*/
public static final String LOG_COLUMN_NAME_EVENT_ACTION = "ac";
/**
* kv前缀
*/
public static final String LOG_COLUMN_NAME_EVENT_KV_START = "kv_";
/**
* duration持续时间
*/
public static final String LOG_COLUMN_NAME_EVENT_DURATION = "du";
/**
* 操作系统名称
*/
public static final String LOG_COLUMN_NAME_OS_NAME = "os";
/**
* 操作系统版本
*/
public static final String LOG_COLUMN_NAME_OS_VERSION = "os_v";
/**
* 浏览器名称
*/
public static final String LOG_COLUMN_NAME_BROWSER_NAME = "browser";
/**
* 浏览器版本
*/
public static final String LOG_COLUMN_NAME_BROWSER_VERSION = "browser_v";
/**
* ip地址解析的所属国家
*/
public static final String LOG_COLUMN_NAME_COUNTRY = "country";
/**
* ip地址解析的所属省份
*/
public static final String LOG_COLUMN_NAME_PROVINCE = "province";
/**
* ip地址解析的所属城市
*/
public static final String LOG_COLUMN_NAME_CITY = "city";
}
package com.controller;
import com.alibaba.fastjson.JSON;
import com.model.*;
import com.service.*;
import com.system.utils.MD5Util;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.SessionStatus;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping({"/user", "/site"})
@SessionAttributes(names = {"user"})
public class UserController extends BaseController{
@Resource(name = "userService")
private UserService userService;
@Resource(name = "hotelOrderService")
private HotelOrderService hotelOrderService;
@Resource(name = "scenicOrderService")
private ScenicOrderService scenicOrderService;
@Resource(name = "userMsgService")
private UserMsgService userMsgService;
@GetMapping("/index.action")
public String index(){
return "/site_index";
}
@GetMapping("/register.action")
public String register() {
return "/user_register";
}
@PostMapping(value = "/doRegister.action", produces = "text/json;charset=UTF-8")
@ResponseBody
public String doRegister(User user, ModelMap modelMap) {
User dbUser = userService.getUserByName(user);
if (dbUser != null) {
response.setType("error");
response.setMessage("用户名已经被占用");
return JSON.toJSONString(response);
}
user.setPassword(MD5Util.generateMD5(user.getPassword()));
user.setCreateTime(new Timestamp(System.currentTimeMillis()));
user.setBalance(0);
userService.save(user);
response.setType("success");
response.setMessage("注册成功");
modelMap.addAttribute("user", user);
return JSON.toJSONString(response);
}
@PostMapping(value = "/doLogin.action", produces = "text/json;charset=UTF-8")
@ResponseBody
public String doLogin(User user, ModelMap modelMap) {
User dbUser = userService.getUserByName(user);
if (dbUser == null) {
response.setType("error");
response.setMessage("用户不存在");
return JSON.toJSONString(response);
}
if (!dbUser.getPassword().equals(MD5Util.generateMD5(user.getPassword()))) {
response.setType("error");
response.setMessage("密码不正确");
return JSON.toJSONString(response);
}
modelMap.addAttribute("user", dbUser);
response.setType("success");
return JSON.toJSONString(response);
}
@GetMapping(value = "/doLogout.action")
public String doLogout(SessionStatus sessionStatus, HttpSession httpSession) {
sessionStatus.setComplete();
httpSession.invalidate();
return "redirect:/user/index.action";
}
@PostMapping(value = "/cashShoppingCart.action", produces = "text/json;charset=UTF-8")
@ResponseBody
public String cashShoppingCart(Integer totalPrice, ModelMap modelMap) {
User user = (User) modelMap.get("user");
try {
List