赞
踩
基于java的水果网上商城设计与实现
使用旧方法对水果网上商城信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在水果网上商城信息的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。
这次开发的基于java的水果网上商城有管理员和用户,管理员管理后台相关信息,用户浏览器商品并且购买商品。管理员功能有个人中心,用户管理,供应商管理,水果分类管理,水果信息管理,水果进货管理,销售统计管理,订单评价管理,系统管理,订单管理等。用户功能有注册登录,查看水果信息,水果资讯,个人中心,购物车,订单评价,我的订单,我的地址,我的收藏等。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择B/S模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行基于java的水果网上商城程序的开发,在数据库的选择上面,选择功能强大的MySQL数据库进行数据的存放操作。
基于java的水果网上商城被人们投放于现在的生活中进行使用,该款管理类软件就可以让管理人员处理信息的时间介于十几秒之间。在这十几秒内就能完成信息的编辑等操作。有了这样的管理软件,水果网上商城信息的管理就离无纸化办公的目标更贴近了。
Java SSM水果网上商城,后端基于SSM框架进行开发,前端页面效果通过使用Vue进行编码实现,主要将实现用户跟管理员角色,实现了水果信息管理、订单管理等功能。
#loginForm .codes {
display: none;
}
#loginForm .codes input { width: calc(100% - 84px); height: 44px; margin: 0; color: #1e90ff; font-size: 14px; padding: 0 10px; border-radius: 0; border-width: 1px; border-style: solid; border-color: #1e90ff; background-color: #fff; box-shadow: 0 0 6px rgba(30, 144, 255, 0); outline: none; } #loginForm .codes .nums { width: 84px; height: 44px; margin: 0; color: $template2.front.login.code.nums.color; font-size: $template2.front.login.code.nums.fontSize; padding: 0; border-radius: 0; border-width: 1px 1px 1px 0; border-style: solid; border-color: #1e90ff; background-color: #f5f5f5; box-shadow: 0 0 6px rgba(30, 144, 255, 0); outline: none; box-sizing: border-box; } </style>
<div class="msg-warn hide title" v-if="true" :style='{"padding":"0 10px","boxShadow":"0 0 6px rgba(255,0,0,.8)","margin":"10px auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"#f7f7f7","color":"red","isshow":true,"borderRadius":"8px","borderWidth":"0","width":"auto","lineHeight":"32px","fontSize":"12px","borderStyle":"solid"}'>公共场所不建议自动登录,以防账号丢失</div> <div :style='{"padding":"0","boxShadow":"0 0 6px rgba(255,0,0,0)","margin":"0 auto","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"rgba(213, 195, 195, 0.49)","borderRadius":"20px","borderWidth":"0 0 0px 0","width":"80%","borderStyle":"solid","height":"64px"}' class="form-item"> <label v-if="false" :style='{"padding":"0 10px","boxShadow":"0 0 6px rgba(255,0,0,0)","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">账号</label> <input :style='{"padding":"0 10px","boxShadow":"0 0 6px rgba(0,0,0,.5)","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"#fff","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"1px","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="text" name="username" required lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input"> </div> <div :style='{"padding":"0","boxShadow":"0 0 6px rgba(255,0,0,0)","margin":"0 auto","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"rgba(213, 195, 195, 0.49)","borderRadius":"20px","borderWidth":"0 0 0px 0","width":"80%","borderStyle":"solid","height":"64px"}' class="form-item"> <label v-if="false" :style='{"padding":"0 10px","boxShadow":"0 0 6px rgba(255,0,0,0)","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">密码</label> <input :style='{"padding":"0 10px","boxShadow":"0 0 6px rgba(0,0,0,.5)","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"#fff","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"1px","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input"> </div> <div class="form-item codes" :style='{"padding":"0","boxShadow":"0 0 6px rgba(255,0,0,0)","margin":"0 auto","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"rgba(213, 195, 195, 0.49)","borderRadius":"20px","borderWidth":"0 0 0px 0","width":"80%","borderStyle":"solid","height":"64px"}'> <input style="flex: 1;" type="text" id="code" placeholder="请输入验证码"> <div class="nums" id="nums" style="display: flex;justify-content: center;align-items: center;"> </div> </div> <div :style='{"padding":"0","boxShadow":"0 0 6px rgba(255,0,0,0)","margin":"0 auto","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"#fff","borderRadius":"0","borderWidth":"0 0 1px 0","width":"80%","borderStyle":"solid","height":"44px"}' class="form-item l-redio"> <input v-if="item.hasFrontLogin=='是'" v-for="(item,index) in menu" v-bind:key="index" type="radio" name="role" id="role" :value="item.tableName" :title="item.roleName"> </div> <button :style='{"padding":"0 10px","boxShadow":"0 0px 0px rgba(255, 0, 0, 1)","margin":"10px auto","borderColor":"rgba(0, 112, 126, 1)","backgroundColor":"rgba(38, 155, 158, 1)","color":"#fff","borderRadius":"8px","borderWidth":"0","width":"60%","fontSize":"14px","borderStyle":"solid","height":"44px"}' class="layui-btn layui-btn-fluid layui-btn-danger btn-submit" lay-submit lay-filter="login">登录</button> <p :style='{"color":"rgba(255, 0, 0, 1)","textAlign":"left","fontSize":"12px"}' class="txt"><a style="color: inherit;font-size: inherit;" v-if="item.hasFrontRegister=='是'" v-for="(item,index) in menu" v-bind:key="index" :href="'javascript:registerClick(\''+item.tableName+'\')'">注册{{item.roleName.replace('注册','')}}</a></p> </form> </div> <script src="../../layui/layui.js"></script> <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 type="text/javascript"> var vue = new Vue({ el: '#app', data: { menu: menu }, methods: { jump(url) { jump(url) } } }) var codes = [{ num: 1, color: '#000', rotate: '10deg', size: '16px' }, { num: 2, color: '#000', rotate: '10deg', size: '16px' }, { num: 3, color: '#000', rotate: '10deg', size: '16px' }, { num: 4, color: '#000', rotate: '10deg', size: '16px' }] layui.use(['layer', 'element', 'carousel', 'form', 'http', 'jquery'], function() { var layer = layui.layer; var element = layui.element; var carousel = layui.carousel; var form = layui.form; var http = layui.http; var jquery = layui.jquery; function randomString() { var len = 4; var chars = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] var colors = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'] var sizes = ['14', '15', '16', '17', '18'] var output = [] for (var i = 0; i < len; i++) { // 随机验证码 var key = Math.floor(Math.random() * chars.length) codes[i].num = chars[key] // 随机验证码颜色 var code = '#' for (var j = 0; j < 6; j++) { var key = Math.floor(Math.random() * colors.length) code += colors[key] } codes[i].color = code // 随机验证码方向 var rotate = Math.floor(Math.random() * 45) var plus = Math.floor(Math.random() * 2) if (plus == 1) rotate = '-' + rotate codes[i].rotate = 'rotate(' + rotate + 'deg)' // 随机验证码字体大小 var size = Math.floor(Math.random() * sizes.length) codes[i].size = sizes[size] + 'px' } var str = '' for(var i = 0;i<codes.length;i++) { str += '<span style="color:' + codes[i].color + ';transform:' + codes[i].rotate + ';fontSize:' + codes[i].size + ';padding: 0 3px;display:inline-block">'+codes[i].num+'</span>' } jquery('#nums').html('').append(str); } jquery('#nums').click(function(){ randomString(); }) randomString(); // 登录 form.on('submit(login)', function(data) { data = data.field; if (!data.role) { layer.msg('请选择登录用户类型', { time: 2000, icon: 5 }); return false; } if(false) { var arr = [] for(var i = 0;i<codes.length;i++) { arr.push(codes[i].num) } if(arr.join('').toLowerCase() != jquery('#code').val().toLowerCase()) { alert("请输入正确的验证码"); randomString() return false; } } http.request(data.role + '/login', 'get', data, function(res) { layer.msg('登录成功', { time: 2000, icon: 6 }); // 登录凭证 localStorage.setItem('Token', res.token); localStorage.setItem('role', jquery('#role:checked').attr('title')); // 当前登录用户角色 localStorage.setItem('userTable', data.role); localStorage.setItem('sessionTable', data.role); // 用户名称 localStorage.setItem('adminName', data.username); http.request(data.role + '/session', 'get', {}, function(res) { // 用户id localStorage.setItem('userid', res.data.id); // 路径访问设置 window.location.href = '../../index.html'; }) }); return false }); }); /** * 跳转登录 * @param {Object} tablename */ function registerClick(tablename) { window.location.href = '../' + tablename + '/register.html?tablename=' + tablename; } </script>
<div :class="2 == 1 ? 'left' : 2 == 2 ? 'left center' : 'left right'" style="backgroundColor: rgba(255, 255, 255, 0.2)"> <el-form class="login-form" label-position="left" :label-width="2 == 3 ? '56px' : '0px'"> <div class="title-container"><h3 class="title" style="color: rgba(0, 150, 136, 1)">水果网上商城登录</h3></div> <el-form-item :label="2 == 3 ? '用户名' : ''" :class="'style'+2"> <span v-if="2 != 3" class="svg-container" style="color:rgba(0, 150, 136, 1);line-height:44px"><svg-icon icon-class="user" /></span> <el-input placeholder="请输入用户名" name="username" type="text" v-model="rulesForm.username" /> </el-form-item> <el-form-item :label="2 == 3 ? '密码' : ''" :class="'style'+2"> <span v-if="2 != 3" class="svg-container" style="color:rgba(0, 150, 136, 1);line-height:44px"><svg-icon icon-class="password" /></span> <el-input placeholder="请输入密码" name="password" type="password" v-model="rulesForm.password" /> </el-form-item> <el-form-item v-if="0 == '1'" class="code" :label="2 == 3 ? '验证码' : ''" :class="'style'+2"> <span v-if="2 != 3" class="svg-container" style="color:rgba(0, 150, 136, 1);line-height:44px"><svg-icon icon-class="code" /></span> <el-input placeholder="请输入验证码" name="code" type="text" v-model="rulesForm.code" /> <div class="getCodeBt" @click="getRandCode(4)" style="height:44px;line-height:44px"> <span v-for="(item, index) in codes" :key="index" :style="{color:item.color,transform:item.rotate,fontSize:item.size}">{{ item.num }}</span> </div> </el-form-item> <el-form-item label="角色" prop="loginInRole" class="role"> <el-radio v-for="item in menus" v-if="item.hasBackLogin=='是'" v-bind:key="item.roleName" v-model="rulesForm.role" :label="item.roleName" >{{item.roleName}}</el-radio> </el-form-item> <el-button type="primary" @click="login()" class="loginInBt" style="padding:0;font-size:16px;border-radius:4px;height:44px;line-height:44px;width:100%;backgroundColor:rgba(0, 150, 136, 1); borderColor:rgba(0, 150, 136, 1); color:rgba(255, 255, 255, 1)">{{'1' == '1' ? '登录' : 'login'}}</el-button> <el-form-item class="setting"> <!-- <div style="color:rgba(0, 150, 136, 1)" class="reset">修改密码</div> --> </el-form-item> </el-form> </div> </div>
}
};
log4j.rootLogger=INFO,CONSOLE,A
log4j.addivity.org.apache=false
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} -%-4r [%t] %-5p %x - %m%n
log4j.appender.CONSOLE.Target=System.out
#log4j.appender.CONSOLE.charset=utf-8
log4j.appender.CONSOLE.encoding=utf-8
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.A=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A.File=${catalina.home}/logs/yo_log/PurePro_
log4j.appender.A.DatePattern=yyyy-MM-dd’.log’
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=[FH_sys] %d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L : %m%n
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.org.apache=INFO
log4j.logger.java.sql.Connection=INFO
log4j.logger.java.sql.Statement=INFO
log4j.logger.java.sql.PreparedStatement=INFO
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 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.ChatEntity;
import com.entity.view.ChatView;
import com.service.ChatService;
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
@date 2021-04-27 10:58:18
*/
@RestController
@RequestMapping(“/chat”)
public class ChatController {
@Autowired
private ChatService chatService;
/**
后端列表
*/
@RequestMapping(“/page”)
public R page(@RequestParam Map<String, Object> params,ChatEntity chat,
HttpServletRequest request){
if(!request.getSession().getAttribute(“role”).toString().equals(“管理员”)) {
chat.setUserid((Long)request.getSession().getAttribute(“userId”));
}
EntityWrapper ew = new EntityWrapper();
PageUtils page = chatService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, chat), params), params));
return R.ok().put(“data”, page);
}
/**
前端列表
*/
@RequestMapping(“/list”)
public R list(@RequestParam Map<String, Object> params,ChatEntity chat,
HttpServletRequest request){
if(!request.getSession().getAttribute(“role”).toString().equals(“管理员”)) {
chat.setUserid((Long)request.getSession().getAttribute(“userId”));
}
EntityWrapper ew = new EntityWrapper();
PageUtils page = chatService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, chat), params), params));
return R.ok().put(“data”, page);
}
/**
/**
/**
/**
/**
后端保存
*/
@RequestMapping(“/save”)
public R save(@RequestBody ChatEntity chat, HttpServletRequest request){
chat.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(chat);
if(StringUtils.isNotBlank(chat.getAsk())) {
chatService.updateForSet(“isreply=0”, new EntityWrapper().eq(“userid”, request.getSession().getAttribute(“userId”)));
chat.setUserid((Long)request.getSession().getAttribute(“userId”));
chat.setIsreply(1);
}
if(StringUtils.isNotBlank(chat.getReply())) {
chatService.updateForSet(“isreply=0”, new EntityWrapper().eq(“userid”, chat.getUserid()));
chat.setAdminid((Long)request.getSession().getAttribute(“userId”));
}
chatService.insert(chat);
return R.ok();
}
/**
前端保存
*/
@RequestMapping(“/add”)
public R add(@RequestBody ChatEntity chat, HttpServletRequest request){
chat.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(chat);
chat.setUserid((Long)request.getSession().getAttribute(“userId”));
if(StringUtils.isNotBlank(chat.getAsk())) {
chatService.updateForSet(“isreply=0”, new EntityWrapper().eq(“userid”, request.getSession().getAttribute(“userId”)));
chat.setUserid((Long)request.getSession().getAttribute(“userId”));
chat.setIsreply(1);
}
if(StringUtils.isNotBlank(chat.getReply())) {
chatService.updateForSet(“isreply=0”, new EntityWrapper().eq(“userid”, chat.getUserid()));
chat.setAdminid((Long)request.getSession().getAttribute(“userId”));
}
chatService.insert(chat);
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 wrapper = new EntityWrapper();
if(map.get(“remindstart”)!=null) {
wrapper.ge(columnName, map.get(“remindstart”));
}
if(map.get(“remindend”)!=null) {
wrapper.le(columnName, map.get(“remindend”));
}
int count = chatService.selectCount(wrapper);
return R.ok().put(“count”, count);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。