系统实现预览
这章节主要是对系统总体设计,数据库设计等几个方面进行了详细的论述。
面向品牌会员的在线商城小程序主要有管理员和用户两个模块。详细规划如图4-1所示。
图4-1 系统规划图
其中各子模块的主要功能如下:
1、系统登录:用户进入网页先输入用户名与密码,选择权限登录,验证码与密码是否正确。如果验证成功,要记录登录的用户名和登录类型。
2、新用户注册:新用户填写用户注册信息完成注册。
3、查看面向品牌会员的在线商城信息:用户登录成功后,能够按分类或者查找品牌会员的在线商城信息进行管理。
4、主页内容管理:管理员登录以后,可以对首页,个人中心,用户管理,商品分类管理,热卖商品管理,系统管理,订单管理进行详细操作。
数据库是一个软件项目的根基,它决定了整个项目代码的走势,同时也决定了整个项目在后期的维护以及升级的难易程度。
根据面向品牌会员的在线商城小程序的功能需求,对数据库进行分析,得到相应的数据,设计用户需要的各种实体,以及相互之间的关联,为逻辑结构设计铺好路。根据所实体内的各种具体信息得于实现。
1.用户管理实体
用户管理实体包括索引,用户账号,用户姓名,头像,性别,联系方式,是否会员等属性。用户管理实体图如图4-2所示:
图4-2用户管理实体图
2.热卖商品管理实体
热卖商品管理实体包括索引,商品编号,商品名称,封面,商品分类,规格,价格,会员价,单限,库存等属性;热卖商品管理实体图如图4-3所示:
图4-3热卖商品管理实体图
数据库概念结构设计完成后,就可以将数据库概念转为数据库支持的数据模型。一个符合规范的数据库设计不仅可以在设计的时候让程序设计员逻辑更为清晰,更能让分析程序的人容易理清数据间的关系。本面向品牌会员的在线商城小程序的主要数据库,根据上述的实体对象以及功能分析可得出需要设计的表,表的逻辑结构如下:
表4-1:在线客服
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
userid | bigint | 用户id | |||
adminid | bigint | 管理员id | |||
ask | longtext | 4294967295 | 提问 | ||
reply | longtext | 4294967295 | 回复 | ||
isreply | int | 是否回复 |
表4-2:购物车表
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
tablename | varchar | 200 | 商品表名 | remaishangpin | |
userid | bigint | 用户id | |||
goodid | bigint | 商品id | |||
goodname | varchar | 200 | 商品名称 | ||
picture | varchar | 200 | 图片 | ||
buynumber | int | 购买数量 | |||
price | float | 单价 | |||
discountprice | float | 会员价 | |||
goodtype | varchar | 200 | 商品类型 |
表4-3:用户表
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
username | varchar | 100 | 用户名 | ||
password | varchar | 100 | 密码 | ||
role | varchar | 100 | 角色 | 管理员 | |
addtime | timestamp | 新增时间 | CURRENT_TIMESTAMP |
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
userid | bigint | 用户id | |||
address | varchar | 200 | |||
name | varchar | 200 | 收货人 | ||
phone | varchar | 200 | 电话 | ||
isdefault | varchar | 200 |
表4-5:token表
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
userid | bigint | 用户id | |||
username | varchar | 100 | 用户名 | ||
tablename | varchar | 100 | 表名 | ||
role | varchar | 100 | 角色 | ||
token | varchar | 200 | 密码 | ||
addtime | timestamp | 新增时间 | CURRENT_TIMESTAMP | ||
expiratedtime | timestamp | 过期时间 | CURRENT_TIMESTAMP |
表4-6:收藏表
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
userid | bigint | 用户id | |||
refid | bigint | 收藏id | |||
tablename | varchar | 200 | 表名 | ||
name | varchar | 200 | 收藏名称 | ||
picture | varchar | 200 | 收藏图片 | ||
type | varchar | 200 | 类型(1:收藏,21:赞,22:踩) | 1 | |
inteltype | varchar | 200 | 推荐类型 |
表4-7:热卖商品
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
shangpinbianhao | varchar | 200 | 商品编号 | ||
shangpinmingcheng | varchar | 200 | 商品名称 | ||
fengmian | varchar | 200 | 封面 | ||
shangpinfenlei | varchar | 200 | 商品分类 | ||
guige | varchar | 200 | 规格 | ||
shangpinxiangqing | longtext | 4294967295 | 商品详情 | ||
thumbsupnum | int | 赞 | 0 | ||
crazilynum | int | 踩 | 0 | ||
clicktime | datetime | 最近点击时间 | |||
clicknum | int | 点击次数 | 0 | ||
price | float | 价格 | |||
vipprice | float | 会员价 | -1 | ||
onelimittimes | int | 单限 | -1 | ||
alllimittimes | int | 库存 | -1 |
表4-8:订单
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
orderid | varchar | 200 | 订单编号 | ||
tablename | varchar | 200 | 商品表名 | remaishangpin | |
userid | bigint | 用户id | |||
goodid | bigint | 商品id | |||
goodname | varchar | 200 | 商品名称 | ||
picture | varchar | 200 | 商品图片 | ||
buynumber | int | 购买数量 | |||
price | float | 价格/积分 | 0 | ||
discountprice | float | 折扣价格 | 0 | ||
total | float | 总价格/总积分 | 0 | ||
discounttotal | float | 折扣总价格 | 0 | ||
type | int | 支付类型 | 1 | ||
status | varchar | 200 | 状态 | ||
address | varchar | 200 | |||
tel | varchar | 200 | 电话 | ||
consignee | varchar | 200 | 收货人 | ||
logistics | longtext | 4294967295 | 物流 | ||
goodtype | varchar | 200 | 商品类型 |
表4-9:优惠资讯
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
title | varchar | 200 | 标题 | ||
introduction | longtext | 4294967295 | 简介 | ||
picture | varchar | 200 | 图片 | ||
content | longtext | 4294967295 | 内容 |
表4-10:热卖商品评论表
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
refid | bigint | 关联表id | |||
userid | bigint | 用户id | |||
nickname | varchar | 200 | 用户名 | ||
content | longtext | 4294967295 | 评论内容 | ||
reply | longtext | 4294967295 | 回复内容 |
表4-11:配置文件
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
name | varchar | 100 | 配置参数名称 | ||
value | varchar | 100 | 配置参数值 |
表4-12:用户
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
yonghuzhanghao | varchar | 200 | 用户账号 | ||
mima | varchar | 200 | 密码 | ||
yonghuxingming | varchar | 200 | 用户姓名 | ||
touxiang | varchar | 200 | 头像 | ||
xingbie | varchar | 200 | 性别 | ||
lianxifangshi | varchar | 200 | 联系方式 | ||
money | float | 余额 | 0 | ||
vip | varchar | 200 | 是否会员 | 否 |
表4-13:商品分类
字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
id | bigint | 主键 | 主键 | ||
addtime | timestamp | 创建时间 | CURRENT_TIMESTAMP | ||
shangpinfenlei | varchar | 200 | 商品分类 |
系统实现是新系统开发工作的最后一个阶段。它是将结构化系统设计的成果变成可实际运行的系统的过程。这一部分主要对系统的主要功能模块的实现细节进行了详细的阐述。
登录,用户通过输入用户名和密码,点击登录进行系统登录操作,如图5-1所示。
图5-1用户登录界面图
系统登陆后,可以对首页,热卖商品,优惠资讯,购物车,我的等功能进行详细操作,如图5-2所示。
图5-2系统首页界面图
用户注册,用户可以通过填写用户账号,密码,确认密码,用户姓名,性别,联系方式等信息进行注册操作;如图5-3所示。
图5-3用户注册界面图
热卖商品,在热卖商品页面可以查看商品名称,商品编号,商品分类,规格,点击次数,会员价,库存等信息进行立即订购和加入购物车等操作;如图5-4所示。
图5-4热卖商品界面图
代码
<!-- 论坛中心 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>论坛中心</title>
<link rel="stylesheet" href="../../layui/css/layui.css">
<!-- 样式 -->
<link rel="stylesheet" href="../../css/style.css" />
<!-- 主题(主要颜色设置) -->
<link rel="stylesheet" href="../../css/theme.css" />
<!-- 通用的css -->
<link rel="stylesheet" href="../../css/common.css" />
</head>
<style>
#swiper {
overflow: hidden;
}
#swiper .layui-carousel-ind li {
width: 16px;
height: 10px;
border-width: 0;
border-style: solid;
border-color: rgba(0,0,0,.3);
border-radius: 3px;
background-color: #f7f7f7;
box-shadow: 0 0 6px rgba(255,0,0,.8);
}
#swiper .layui-carousel-ind li.layui-this {
width: 24px;
height: 10px;
border-width: 0;
border-style: solid;
border-color: rgba(0,0,0,.3);
border-radius: 0;
background-color: red;
box-shadow: 0 0 6px rgba(255,0,0,.8);
}
.index-title {
text-align: center;
box-sizing: border-box;
width: 980px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.paper-container thead tr {
background-color: rgba(130, 198, 243, 1);
color: #000;
}
</style>
<body>
<div id="app">
<!-- 轮播图 -->
<div class="layui-carousel" id="swiper" :style='{"boxShadow":"0 0 0px rgba(255,0,0,.8)","margin":"0 auto","borderColor":"rgba(0,0,0,.3)","borderRadius":"0","borderWidth":"0","width":"100%","borderStyle":"solid"}'>
<div carousel-item id="swiper-item">
<div v-for="(item,index) in swiperList" :key="index">
<img style="width: 100%;height: 100%;object-fit:cover;" :src="item.img" />
</div>
</div>
</div>
<!-- 轮播图 -->
<!-- 标题 -->
<div class="index-title" :style='{"padding":"10px","boxShadow":"0 0 0px rgba(255,0,0,.8)","margin":"10px auto","borderColor":"rgba(21, 71, 106, 1)","backgroundColor":"rgba(130, 198, 243, 1)","color":"rgba(0, 0, 0, 1)","borderRadius":"4px","borderWidth":"0 0 10px","fontSize":"20px","borderStyle":"solid","height":"auto"}'>
<span>SHOP / CART</span><span>购物车</span>
</div>
<!-- 标题 -->
<div class="paper-container">
<table class="layui-table" lay-skin="nob">
<thead>
<tr>
<th>
<input checked type="checkbox" id="checkAll" @click="selectAll()">
</th>
<th>购买商品</th>
<th>价格</th>
<th>数量</th>
<th>总价</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="(item,index) in dataList" v-bind:key="index">
<td>
<label>
<input checked type="checkbox" name="good" value="index" @click="selectOne()">
</label>
</td>
<td style="display: flex;text-align: left;height: 100px">
<img :src="baseurl+item.picture" style="width: 100px;height: 100px;object-fit: cover;">
<div style="margin-left: 10px;margin-top: 10px;">
{{item.goodname}}
</div>
</td>
<td style="width: 100px;"><span :style='{"fontSize":"12px"}'>¥</span>{{Number(item.price).toFixed(2)}}</td>
<td style="width: 140px;">
<div class="num-picker">
<button type="button" @click="reduceCartNum(index)" class="layui-btn layui-btn-primary">-</button>
<input style="height: 38px;" type="number" :value="item.buynumber" id="buynumber" name="buynumber" class="layui-input"
disabled="disabled"></input>
<button type="button" @click="addCartNum(index)" class="layui-btn layui-btn-primary">+</button>
</div>
</td>
<td style="width: 100px;"><span :style='{"fontSize":"12px"}'>¥</span>{{Number((item.price*item.buynumber)).toFixed(2)}}</td>
<td style="width: 100px;">
<button @click="deleteCart(index)" type="button" class="layui-btn layui-btn-radius btn-theme">
<i class="layui-icon"></i> 删除
</button>
</td>
</tr>
</tbody>
</table>
<div class="btn-container">
<span style="font-size: 18px;font-weight: bold;color: rgba(209, 10, 10, 1);margin-right: 20px;">
总价:<span :style='{"fontSize":"12px"}'>¥</span>{{totalPrice}}
</span>
<button :style='{"padding":"0 20px","boxShadow":"0 0 0px rgba(255,0,0,.3)","margin":"0 5px","borderColor":"rgba(0,0,0,.3)","backgroundColor":"rgba(29, 93, 135, 1)","color":"rgba(255, 255, 255, 1)","borderRadius":"34px","borderWidth":"0","width":"auto","lineHeight":"34px","fontSize":"14px","borderStyle":"solid"}' @click="buyClick" type="button" class="layui-btn layui-btn-lg btn-theme">
<i class="layui-icon"></i> 点击购买
</button>
</div>
</div>
</div>
<!-- layui -->
<script src="../../layui/layui.js"></script>
<!-- vue -->
<script src="../../js/vue.js"></script>
<!-- 组件配置信息 -->
<script src="../../js/config.js"></script>
<!-- 扩展插件配置信息 -->
<script src="../../modules/config.js"></script>
<!-- 工具方法 -->
<script src="../../js/utils.js"></script>
<script>
var vue = new Vue({
el: '#app',
data: {
// 轮播图
swiperList: [{
img: '../../img/banner.jpg'
}],
dataList: [],
selectDataList: [],
baseurl:''
},
computed: {
totalPrice: function() {
var total = 0;
for (var item of this.selectDataList) {
total += item.price * item.buynumber
}
return total.toFixed(2);
}
},
methods: {
jump(url) {
jump(url)
},
selectAll() {
var objs = document.getElementsByName('good');
var i;
if(document.getElementById("checkAll").checked) {
for(i = 0; i < objs.length; i++) {
if(objs[i].type == "checkbox") {
objs[i].checked = true;
}
}
this.selectDataList = this.dataList;
} else {
for(i = 0; i < objs.length; i++) {
if(objs[i].type == "checkbox") {
objs[i].checked = false;
}
}
this.selectDataList = [];
}
},
selectOne() {
var objs = document.getElementsByName('good');
var nDataList = []
var i;
for(i = 0; i < objs.length; i++) {
if(objs[i].type == "checkbox") {
if(objs[i].checked) {
nDataList.push(this.dataList[i])
}
}
}
this.selectDataList = nDataList;
if(this.selectDataList.length!=this.dataList.length) {
document.getElementById("checkAll").checked = false;
} else {
document.getElementById("checkAll").checked = true;
}
},
// 添加数量
addCartNum(index) {
// 查询对应的商品的详情信息,判断是否有商品限次,库存的判断
var item = this.dataList[index];
layui.http.request(`${item.tablename}/info/${item.goodid}`, 'get', {}, function(res) {
// 单次购买限制
if (res.data.onelimittimes && res.data.onelimittimes > 0 && res.data.onelimittimes <= item.buynumber) {
layui.layer.msg(`每人单次只能购买${res.data.onelimittimes}件`, {
time: 2000,
icon: 5
});
return
}
// 库存限制
if (res.data.alllimittimes && res.data.alllimittimes > 0 && res.data.alllimittimes <= item.buynumber) {
layui.layer.msg(`库存不足`, {
time: 2000,
icon: 5
});
return
}
item.buynumber = parseInt(item.buynumber) + 1;
layui.http.requestJson(`cart/update`, 'post', item, function(res) {});
});
},
// 减少数量
reduceCartNum(index) {
var item = this.dataList[index];
if (item.buynumber > 1) {
item.buynumber = item.buynumber - 1;
layui.http.requestJson(`cart/update`, 'post', item, function(res) {});
}
},
// 删除
deleteCart(index) {
var item = this.dataList[index];
layui.http.requestJson(`cart/delete`, 'post', [item.id], function(res) {
window.location.reload();
});
},
// 购买商品
buyClick() {
if(this.selectDataList.length==0) {
layui.layer.msg(`请选择商品`, {
time: 2000,
icon: 5
});
return
}
localStorage.setItem('orderGoods', JSON.stringify(this.selectDataList));
window.location.href = '../shop-order/confirm.html'
}
}
})
layui.use(['layer', 'element', 'carousel', 'laypage', 'http', 'jquery'], function() {
var layer = layui.layer;
var element = layui.element;
var carousel = layui.carousel;
var laypage = layui.laypage;
var http = layui.http;
var jquery = layui.jquery;
var limit = 10;
vue.baseurl = http.baseurl;
// 获取轮播图 数据
http.request('config/list', 'get', {
page: 1,
limit: 5
}, function(res) {
if (res.data.list.length > 0) {
var swiperItemHtml = '';
for (let item of res.data.list) {
if (item.name.indexOf('picture') >= 0 && item.value && item.value != "" && item.value != null) {
swiperItemHtml +=
'<div>' +
'<img class="swiper-item" style="width: 100%;height: 100%;object-fit:cover;" src="' + http.baseurl+item.value + '">' +
'</div>';
}
}
jquery('#swiper-item').html(swiperItemHtml);
// 轮播图
vue.$nextTick(() => {
carousel.render({
elem: '#swiper',
width: '100%',
height: '300px',
arrow: 'hover',
anim: 'default',
autoplay: 'true',
interval: '3000',
indicator: 'none'
});
})
}
});
// 获取列表数据
http.request('cart/list', 'get', {
page: 1,
limit: 1000,
userid: localStorage.getItem('userid')
}, function(res) {
vue.dataList = res.data.list
vue.selectDataList = res.data.list
// 分页
laypage.render({
elem: 'pager',
count: res.data.total,
limit: limit,
jump: function(obj, first) {
//首次不执行
if (!first) {
http.request('news/list', 'get', {
page: obj.curr,
limit: obj.limit,
userid: localStorage.getItem('userid')
}, function(res) {
vue.dataList = res.data.list
})
}
}
});
})
});
</script>
</body>
</html>
我的,在我的页面可以对我的收藏管理,用户充值,用户购买,在线客服,购物车,我的订单等详细信息进行操作,如图5-5所示。
图5-5我的界面图
管理员登录,管理员通过输入账号、密码,选择角色并点击登录进行系统登录操作,如图5-6所示。
图5-6管理员登录界图面
管理员登陆系统后,可以对首页,个人中心,用户管理,商品分类管理,热卖商品管理,系统管理,订单管理等功能进行相应操作,如图5-7所示。
图5-7管理员功能界面图
用户管理,在用户管理页面可以对索引,用户账号,用户姓名,头像,性别,联系方式,是否会员等内容进行详情、修改或删除等操作,如图5-8所示。
图5-8用户管理界面图
部分代码
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.YonghuEntity;
import com.entity.view.YonghuView;
import com.service.YonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 用户
* 后端接口
* @author
* @email
* @date 2022-03-26 18:05:32
*/
@RestController
@RequestMapping("/yonghu")
public class YonghuController {
@Autowired
private YonghuService yonghuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody YonghuEntity yonghu){
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
yonghu.setId(uId);
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
YonghuEntity user = yonghuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
yonghuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
HttpServletRequest request){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( YonghuEntity yonghu){
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
return R.ok().put("data", yonghuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(YonghuEntity yonghu){
EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
YonghuView yonghuView = yonghuService.selectView(ew);
return R.ok("查询用户成功").put("data", yonghuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
yonghu.setId(new Date().getTime());
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(yonghu);
YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
yonghu.setId(new Date().getTime());
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
//ValidatorUtils.validateEntity(yonghu);
yonghuService.updateById(yonghu);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
yonghuService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<YonghuEntity> wrapper = new EntityWrapper<YonghuEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = yonghuService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
商品分类管理,在商品分类管理页面可以对索引,商品分类等内容进行详情,修改或删除等操作,如图5-9所示。
图5-9商品分类管理界面图
大家点赞、收藏、关注、评论啦 其他的定制服务 下方联系卡片↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 或者私信作者