基于javaweb的在线服装销售商城系统(java+springboot+vue+mysql)
基于javaweb的在线服装销售商城系统(java+springboot+vue+mysql)
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明





基于javaweb+mysql的在线服装销售商城系统(java+SpringBoot+Maven+Vue+mysql)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
后台管理-用户页:
/**
- 后台管理-用户页
*/
@Controller
public class UserController extends BaseController{
@Resource(name=“userService”)
private UserService userService;
@Resource(name=“addressService”)
private AddressService addressService;
@Resource(name =“reviewService”)
private ReviewService reviewService;
@Resource(name = “productOrderItemService”)
private ProductOrderItemService productOrderItemService;
@Resource(name = “productService”)
private ProductService productService;
@Resource(name = “productImageService”)
private ProductImageService productImageService;
//转到后台管理-用户页-ajax
@RequestMapping(value = “admin/user”, method = RequestMethod.GET)
public String goUserManagePage(HttpSession session, Map
logger.info(“获取前十条用户信息”);
PageUtil pageUtil = new PageUtil(0, 10);
List userList = userService.getList(null, null, pageUtil);
map.put(“userList”, userList);
logger.info(“获取用户总数量”);
Integer userCount = userService.getTotal(null);
map.put(“userCount”, userCount);
logger.info(“获取分页信息”);
pageUtil.setTotal(userCount);
map.put(“pageUtil”, pageUtil);
logger.info(“转到后台管理-用户页-ajax方式”);
return “admin/userManagePage”;
//转到后台管理-用户详情页-ajax
@RequestMapping(value = “admin/user/{uid}”, method = RequestMethod.GET)
public String getUserById(HttpSession session, Map
logger.info(“获取user_id为{}的用户信息”,uid);
User user = userService.get(uid);
logger.info(“获取用户详情-所在地地址信息”);
Address address = addressService.get(user.getUser_address().getAddress_areaId());
Stack addressStack = new Stack<>();
//最后一级地址
addressStack.push(address.getAddress_name() + " ");
//如果不是第一级地址
while (!address.getAddress_areaId().equals(address.getAddress_regionId().getAddress_areaId())) {
address = addressService.get(address.getAddress_regionId().getAddress_areaId());
addressStack.push(address.getAddress_name() + " ");
StringBuilder builder = new StringBuilder();
while (!addressStack.empty()) {
builder.append(addressStack.pop());
logger.info(“所在地地址字符串:{}”, builder);
user.setUser_address(new Address().setAddress_name(builder.toString()));
logger.info(“获取用户详情-家乡地址信息”);
address = addressService.get(user.getUser_homeplace().getAddress_areaId());
//最后一级地址
addressStack.push(address.getAddress_name() + " ");
//如果不是第一级地址
while (!address.getAddress_areaId().equals(address.getAddress_regionId().getAddress_areaId())) {
address = addressService.get(address.getAddress_regionId().getAddress_areaId());
addressStack.push(address.getAddress_name() + " ");
builder = new StringBuilder();
while (!addressStack.empty()) {
builder.append(addressStack.pop());
logger.info(“家乡地址字符串:{}”, builder);
user.setUser_homeplace(new Address().setAddress_name(builder.toString()));
logger.info(“获取用户详情-购物车订单项信息”);
List productOrderItemList = productOrderItemService.getListByUserId(
user.getUser_id(), null
);
if (productOrderItemList != null) {
logger.info(“获取用户详情-购物车订单项对应的产品信息”);
for (ProductOrderItem productOrderItem : productOrderItemList) {
Integer productId = productOrderItem.getProductOrderItem_product().getProduct_id();
logger.warn(“获取产品ID为{}的产品信息”, productId);
Product product = productService.get(productId);
if (product != null) {
logger.warn(“获取产品ID为{}的第一张预览图片信息”, productId);
product.setSingleProductImageList(productImageService.getList(
productId, (byte) 0, new PageUtil(0, 1))
);
productOrderItem.setProductOrderItem_product(product);
user.setProductOrderItemList(productOrderItemList);
if (user.getUser_realname() != null) {
logger.info(“用户隐私加密”);
user.setUser_realname(user.getUser_realname().substring(0, 1) + “*”);
} else {
user.setUser_realname(“未命名”);
map.put(“user”,user);
logger.info(“转到后台管理-用户详情页-ajax方式”);
return “admin/include/userDetails”;
//按条件查询用户-ajax
@ResponseBody
@RequestMapping(value = “admin/user/{index}/{count}”, method = RequestMethod.GET, produces = “application/json;charset=UTF-8”)
public String getUserBySearch(@RequestParam(required = false) String user_name/* 用户名称 */,
@RequestParam(required = false) Byte[] user_gender_array/* 用户性别数组 */,
@RequestParam(required = false) String orderBy/* 排序字段 */,
@RequestParam(required = false,defaultValue = “true”) Boolean isDesc/* 是否倒序 */,
@PathVariable Integer index/* 页数 */,
@PathVariable Integer count/* 行数 */) throws UnsupportedEncodingException {
//移除不必要条件
Byte gender = null;
if (user_gender_array != null && user_gender_array.length == 1) {
gender = user_gender_array[0];
if (user_name != null) {
//如果为非空字符串则解决中文乱码:URLDecoder.decode(String,“UTF-8”);
user_name = “”.equals(user_name) ? null : URLDecoder.decode(user_name, “UTF-8”);
if (orderBy != null && “”.equals(orderBy)) {
orderBy = null;
//封装查询条件
User user = new User()
.setUser_name(user_name)
.setUser_gender(gender);
OrderUtil orderUtil = null;
if (orderBy != null) {
logger.info(“根据{}排序,是否倒序:{}”,orderBy,isDesc);
orderUtil = new OrderUtil(orderBy, isDesc);
JSONObject object = new JSONObject();
logger.info(“按条件获取第{}页的{}条用户”, index + 1, count);
PageUtil pageUtil = new PageUtil(index, count);
List userList = userService.getList(user, orderUtil, pageUtil);
object.put(“userList”, JSONArray.parseArray(JSON.toJSONString(userList)));
logger.info(“按条件获取用户总数量”);
Integer userCount = userService.getTotal(user);
object.put(“userCount”, userCount);
logger.info(“获取分页信息”);
pageUtil.setTotal(userCount);
object.put(“totalPage”, pageUtil.getTotalPage());
object.put(“pageUtil”, pageUtil);
return object.toJSONString();
后台管理-产品类型页:
/**
- 后台管理-产品类型页
*/
@Controller
public class CategoryController extends BaseController {
@Resource(name = “categoryService”)
private CategoryService categoryService;
@Resource(name = “lastIDService”)
private LastIDService lastIDService;
@Resource(name = “propertyService”)
private PropertyService propertyService;
//转到后台管理-产品类型页-ajax
@RequestMapping(value = “admin/category”, method = RequestMethod.GET)
public String goToPage(HttpSession session, Map
logger.info(“获取前10条产品类型列表”);
PageUtil pageUtil = new PageUtil(0, 10);
List categoryList = categoryService.getList(null, pageUtil);
map.put(“categoryList”, categoryList);
logger.info(“获取产品类型总数量”);
Integer categoryCount = categoryService.getTotal(null);
map.put(“categoryCount”, categoryCount);
logger.info(“获取分页信息”);
pageUtil.setTotal(categoryCount);
map.put(“pageUtil”, pageUtil);
logger.info(“转到后台管理-分类页-ajax方式”);
return “admin/categoryManagePage”;
//转到后台管理-产品类型详情页-ajax
@RequestMapping(value = “admin/category/{cid}”, method = RequestMethod.GET)
public String goToDetailsPage(HttpSession session, Map
logger.info(“获取category_id为{}的分类信息”, cid);
Category category = categoryService.get(cid);
logger.info(“获取分类子信息-属性列表”);
category.setPropertyList(propertyService.getList(new Property().setProperty_category(category), null));
map.put(“category”, category);
logger.info(“转到后台管理-分类详情页-ajax方式”);
return “admin/include/categoryDetails”;
//转到后台管理-产品类型添加页-ajax
@RequestMapping(value = “admin/category/new”, method = RequestMethod.GET)
public String goToAddPage(HttpSession session, Map
logger.info(“转到后台管理-分类添加页-ajax方式”);
return “admin/include/categoryDetails”;
//添加产品类型信息-ajax
@ResponseBody
@RequestMapping(value = “admin/category”, method = RequestMethod.POST, produces = “application/json;charset=utf-8”)
public String addCategory(@RequestParam String category_name/* 分类名称 */,
@RequestParam String category_image_src/* 分类图片路径 */) {
JSONObject jsonObject = new JSONObject();
logger.info(“整合分类信息”);
Category category = new Category()
.setCategory_name(category_name)
.setCategory_image_src(category_image_src.substring(category_image_src.lastIndexOf(“/”) + 1));
logger.info(“添加分类信息”);
boolean yn = categoryService.add(category);
if (yn) {
int category_id = lastIDService.selectLastID();
logger.info(“添加成功!,新增分类的ID值为:{}”, category_id);
jsonObject.put(“success”, true);
jsonObject.put(“category_id”, category_id);
} else {
jsonObject.put(“success”, false);
logger.warn(“添加失败!事务回滚”);
throw new RuntimeException();
return jsonObject.toJSONString();
//更新产品类型信息-ajax
@ResponseBody
@RequestMapping(value = “admin/category/{category_id}”, method = RequestMethod.PUT, produces = “application/json;charset=utf-8”)
public String updateCategory(@RequestParam String category_name/* 分类名称 */,
@RequestParam String category_image_src/* 分类图片路径 */,
@PathVariable(“category_id”) Integer category_id/* 分类ID */) {
JSONObject jsonObject = new JSONObject();
logger.info(“整合分类信息”);
Category category = new Category()
.setCategory_id(category_id)
.setCategory_name(category_name)
.setCategory_image_src(category_image_src.substring(category_image_src.lastIndexOf(“/”) + 1));
logger.info(“更新分类信息,分类ID值为:{}”, category_id);
boolean yn = categoryService.update(category);
if (yn) {
logger.info(“更新成功!”);
jsonObject.put(“success”, true);
jsonObject.put(“category_id”, category_id);
} else {
jsonObject.put(“success”, false);
logger.info(“更新失败!事务回滚”);
throw new RuntimeException();
return jsonObject.toJSONString();
//按条件查询产品类型-ajax
@ResponseBody
@RequestMapping(value = “admin/category/{index}/{count}”, method = RequestMethod.GET, produces = “application/json;charset=utf-8”)
public String getCategoryBySearch(@RequestParam(required = false) String category_name/* 分类名称 */,
@PathVariable Integer index/* 页数 */,
@PathVariable Integer count/* 行数 */) throws UnsupportedEncodingException {
//移除不必要条件
if (category_name != null) {
//如果为非空字符串则解决中文乱码:URLDecoder.decode(String,“UTF-8”);
category_name = “”.equals(category_name) ? null : URLDecoder.decode(category_name, “UTF-8”);
JSONObject object = new JSONObject();
logger.info(“按条件获取第{}页的{}条分类”, index + 1, count);
PageUtil pageUtil = new PageUtil(index, count);
List categoryList = categoryService.getList(category_name, pageUtil);
object.put(“categoryList”, JSONArray.parseArray(JSON.toJSONString(categoryList)));
logger.info(“按条件获取分类总数量”);
Integer categoryCount = categorySer
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
