源码获取:博客首页 "资源" 里下载!
本系统功能包括: 前台展示+后台管理,包括最基本的用户登录注册,下单, 购物车,购买,结算,订单查询,收货地址,后台商品管 理,订单管理,用户管理等等功能,小伙伴一起来看看 吧。
环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。
项目技术: Springboot + Maven + Mybatis + Vue + Redis + HTML 等 等组成,B/S模式+ Maven管理等等。
package com.qiu.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qiu.entity.Logistics;
import com.qiu.entity.Order;
import com.qiu.entity.Product;
import com.qiu.service.LogisticsService;
import com.qiu.service.OrderService;
import com.qiu.service.ProductService;
import com.qiu.util.general.CommonResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @description 订单相关业务
*/
@RestController
@CrossOrigin
public class OrderController {
final OrderService orderService;
final ProductService productService;
final LogisticsService logisticsService;
final RedisTemplate redisTemplate;
public OrderController(RedisTemplate redisTemplate,OrderService orderService,LogisticsService logisticsService,ProductService productService) {
this.orderService = orderService;
this.productService = productService;
this.logisticsService = logisticsService;
this.redisTemplate = redisTemplate;
}
@RequestMapping(value = "/order/findById")
private CommonResult findOrderById(Integer orderId) {
Order order= orderService.selectById(orderId);
if(orderId!=null){
return CommonResult.success("订单信息查询成功",order);
}else{
return CommonResult.error("订单信息查询失败");
}
}
@RequestMapping(value = "/order/findOrderInfo")
private CommonResult findOrderInfo(String userAccount) {
List
package com.qiu.controller;
import com.qiu.entity.Role;
import com.qiu.service.RoleService;
//import com.qiu.util.general.CommonResult;
import com.qiu.util.general.CommonResult;
//import com.power.common.model.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description 用户授权等相关业务
*/
@RestController
@CrossOrigin
public class RoleController {
final RoleService roleService;
public RoleController(RoleService roleService) {
this.roleService = roleService;
}
/*根据id查询用户*/
@RequestMapping(value = "/role/findById")
private CommonResult findById(Integer roleId) {
Role role = roleService.selectById(roleId);
if(role!=null){
return CommonResult.success("查询成功",role);
}else{
return CommonResult.error("查询失败");
}
}
/*根据角色名称查询角色*/
@RequestMapping(value = "/role/findByKey")
private CommonResult findByKey(String roleName) {
Role role = roleService.selectByKey(roleName);
if(role!=null){
return CommonResult.success("查询成功",role);
}else{
return CommonResult.error("查询失败");
}
}
/*根据key查询用户*/
@RequestMapping(value = "/role/existRoleName")
private CommonResult existRoleName(Integer roleId,String roleName) {
Boolean isExist = roleService.existsRoleName(roleId,roleName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有角色信息*/
@RequestMapping(value = "/role/findAll")
private CommonResult findAll() {
List roles = roleService.selectAll();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有用户*/
@RequestMapping(value = "/role/findAllUsable")
private CommonResult findAllUsable() {
List roles = roleService.selectAllUsable();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/count")
private CommonResult findCount() {
Integer count = roleService.selectCount();
if(count!=null){
return CommonResult.success("查询成功",count);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/findIdByKey")
private CommonResult findIdByKey(String key) {
Integer id = roleService.selectIdByKey(key);
if(id!=null){
return CommonResult.success("查询成功","id: "+id);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/add")
private CommonResult add(Role role) {
if(role!=null){
if(roleService.insertData(role)){
return CommonResult.success("添加成功",role);
}else{
return CommonResult.error("添加失败");
}
}
return CommonResult.error("用户数据不存在");
}
@RequestMapping(value = "/role/update")
private CommonResult update(Role role) {
System.out.println(role);
if(roleService.updateById(role)){
return CommonResult.success("更新成功",role);
}else{
return CommonResult.error("更新失败");
}
}
@RequestMapping(value = "/role/delete")
private CommonResult delete(Integer roleId) {
if(roleService.deleteById(roleId)){
return CommonResult.success("删除成功",roleId);
}else{
return CommonResult.error("删除失败");
}
}
}
package com.qiu.controller;
import com.qiu.entity.User;
import com.qiu.entity.UserRole;
import com.qiu.entity.Vip;
import com.qiu.service.RoleService;
import com.qiu.service.UserRoleService;
import com.qiu.service.UserService;
import com.qiu.service.VipService;
import com.qiu.util.general.CommonResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
* @description 用户相关业务
*/
@RestController
@CrossOrigin
public class UserController {
final RoleService roleService;
final UserService userService;
final UserRoleService userRoleService;
final VipService vipService;
public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
this.userService = userService;
this.roleService = roleService;
this.userRoleService = userRoleService;
this.vipService = vipService;
}
/*根据id查询用户*/
@RequestMapping(value = "/user/findById")
private CommonResult findById(Integer id) {
User user = userService.selectById(id);
if(user!=null){
return CommonResult.success("查询成功",user);
}else{
return CommonResult.error("查询失败");
}
}
/*根据帐号查询用户*/
@RequestMapping(value = "/user/findByKey")
private CommonResult findByKey(String key) {
User user = userService.selectByKey(key);
if(user!=null){
return CommonResult.success("查询成功",user);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有用户*/
@RequestMapping(value = "/user/findAll")
private CommonResult findAll() {
List users = userService.selectAll();
if(users!=null){
return CommonResult.success("查询成功",users);
}else{
return CommonResult.error("查询失败");
}
}
/*判断某个用户是否还存在*/
@RequestMapping(value = "/user/existKey")
private CommonResult existKey(String key) {
Boolean isExist = userService.existsWithPrimaryKey(key);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
/*查询用户状态*/
@RequestMapping(value = "/user/userState")
private CommonResult userState(String accountNumber) {
Boolean state = userService.selectUserState(accountNumber);
if(state!=null){
return CommonResult.success("查询成功",state);
}else{
return CommonResult.error("查询失败");
}
}
/*查询用户记录的总条数*/
@RequestMapping(value = "/user/count")
private CommonResult findCount() {
Integer count = userService.selectCount();
if(count!=null){
if(count!=0){
return CommonResult.success("查询成功",count);
}else{
return CommonResult.error("查询失败");
}
}else{
return CommonResult.error("查询失败");
}
}
//通过用户帐号去查询用户的id
@RequestMapping(value = "/user/findIdByKey")
private CommonResult findIdByKey(String key) {
Integer id = userService.selectIdByKey(key);
if(id!=null){
if(id!=0){
return CommonResult.success("查询成功","id: "+id);
}else{
return CommonResult.error("未查询到");
}
}else{
return CommonResult.error("查询失败");
}
}
//删除用户
@RequestMapping(value = "/user/delete")
private CommonResult delete(Integer userId) {
if(userService.deleteById(userId)){
return CommonResult.success("删除成功",userId);
}else{
return CommonResult.error("删除失败");
}
}
@RequestMapping(value = "/user/author")
private CommonResult author(Integer userId,@RequestParam List roleId) {
System.out.println(userId);
System.out.println(roleId);
if(userId!=null && roleId!=null && roleId.size()!=0){
if(userRoleService.deleteById(userId)){
UserRole userRole = new UserRole();
userRole.setUserId(userId);
for (Integer id : roleId) {
userRole.setRoleId(id);
userRoleService.insertData(userRole);
}
}
return CommonResult.success("授权成功");
}else{
return CommonResult.error("角色授权数据不完整!");
}
}
/*查询所有VIP用户*/
@RequestMapping(value = "/vip/findAllVip")
private CommonResult findAllVip() {
List vips = vipService.selectAll();
if(vips!=null){
return CommonResult.success("查询成功",vips);
}else{
return CommonResult.error("查询失败");
}
}
/*查询VIP用户信息根据id*/
@RequestMapping(value = "/vip/findVipById")
private CommonResult findVipById(Integer vipId) {
Vip vip = vipService.selectById(vipId);
if(vip!=null){
return CommonResult.success("查询成功",vip);
}else{
return CommonResult.error("查询失败");
}
}
/*查询VIP用户信息根据id*/
@RequestMapping(value = "/vip/findVipByKey")
private CommonResult findVipByKey(String accountNumber) {
Vip vip = vipService.selectByKey(accountNumber);
if(vip!=null){
return CommonResult.success("查询成功",vip);
}else{
return CommonResult.error("查询失败");
}
}
/*判断用户信息是否存在*/
@RequestMapping(value = "/vip/existsVip")
private CommonResult existsVip(String accountNumber) {
Boolean isExist = vipService.existsVip(accountNumber);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
//创建vip信息
@RequestMapping(value = "/vip/addVip")
private CommonResult addVip(Vip vip) {
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);//设置起时间
cal.add(Calendar.YEAR, 1);//增加一年
vip.setOverdueTime(cal.getTime());
if(vipService.insertData(vip)){
return CommonResult.success("vip信息插入成功",vip);
}else{
return CommonResult.error("vip信息插入失败");
}
}
//更新vip信息
@RequestMapping(value = "/vip/updateVip")
private CommonResult updateVip(Vip vip) {
if(vipService.updateById(vip)){
return CommonResult.success("vip信息更新成功",vip);
}else{
return CommonResult.error("vip信息更新失败");
}
}
//删除vip信息
@RequestMapping(value = "/vip/deleteVip")
private CommonResult deleteVip(Integer vipId) {
if(vipService.deleteById(vipId)){
return CommonResult.success("删除成功",vipId);
}else{
return CommonResult.error("删除失败");
}
}
}
源码获取:博客首页 "资源" 里下载!