在线宠物商城设计与实现
信息数据从传统到当代,是一直在变革当中,突如其来的互联网让传统的信息管理看到了革命性的曙光,因为传统信息管理从时效性,还是安全性,还是可操作性等各个方面来讲,遇到了互联网时代才发现能补上自古以来的短板,有效的提升管理的效率和业务水平。传统的管理模式,时间越久管理的内容越多,也需要更多的人来对数据进行整理,并且数据的汇总查询方面效率也是极其的低下,并且数据安全方面永远不会保证安全性能。结合数据内容管理的种种缺点,在互联网时代都可以得到有效的补充。结合先进的互联网技术,开发符合需求的软件,让数据内容管理不管是从录入的及时性,查看的及时性还是汇总分析的及时性,都能让正确率达到最高,管理更加的科学和便捷。本次开发的在线宠物商城实现了收货地址管理、购物车管理、宠物管理、宠物收藏管理、宠物留言管理、宠物预定订单管理、字典管理、论坛管理、商品管理、商品收藏管理、商品评价管理、商品订单管理、用户管理、管理员管理等功能。系统用到了关系型数据库中王者MySql作为系统的数据库,有效的对数据进行安全的存储,有效的备份,对数据可靠性方面得到了保证。并且程序也具备程序需求的所有功能,使得操作性还是安全性都大大提高,让在线宠物商城更能从理念走到现实,确确实实的让人们提升信息处理效率。
Java SSM在线宠物商城,基于SSM框架进行开发,前端效果通过使用Vue框架进行编码实现,实现用户跟管理员这两类用户角色,主要实现了宠物管理、论坛管理等功能。
validationQuery=SELECT 1
jdbc_url=jdbc:mysql://127.0.0.1:3306/zaixianchongwushangcheng?useUnicode=true&characterEncoding=UTF-8&tinyInt1isBit=false
jdbc_username=root
jdbc_password=123456
#
#jdbc_url=jdbc:sqlserver://localhost:1433;DatabaseName=zaixianchongwushangcheng
#jdbc_username=sa
#jdbc_password=123456
package com.thread;
/**
* 线程执行方法(做一些项目启动后 一直要执行的操作,比如根据时间自动更改订单状态,比如订单签收30天自动收货功能,比如根据时间来更改状态)
*/
public class MyThreadMethod extends Thread {
public void run() {
while (!this.isInterrupted()) {// 线程未中断执行循环
try {
Thread.sleep(5000); //每隔2000ms执行一次
} catch (InterruptedException e) {
e.printStackTrace();
}
// ------------------ 开始执行 ---------------------------
// System.out.println("线程执行中:" + System.currentTimeMillis());
}
}
}
package com.ServletContextListener;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.DictionaryEntity;
import com.service.DictionaryService;
import com.thread.MyThreadMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 字典初始化监视器 用的是服务器监听,每次项目启动,都会调用这个类
*/
public class DictionaryServletContextListener implements ServletContextListener {
private static final Logger logger = LoggerFactory.getLogger(DictionaryServletContextListener.class);
private MyThreadMethod myThreadMethod;
@Override
public void contextDestroyed(ServletContextEvent sce) {
logger.info("----------服务器停止----------");
}
@Override
public void contextInitialized(ServletContextEvent sce) {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
logger.info("----------字典表初始化开始----------");
DictionaryService dictionaryService = (DictionaryService)appContext.getBean("dictionaryService");
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
sce.getServletContext().setAttribute("dictionaryMap", map);
logger.info("----------字典表初始化完成----------");
logger.info("----------线程执行开始----------");
if (myThreadMethod == null) {
myThreadMethod = new MyThreadMethod();
myThreadMethod.start(); // servlet 上下文初始化时启动线程myThreadMethod
}
logger.info("----------线程执行结束----------");
}
}
package com.model.enums;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IEnum;
/**
* 必须现在 IEnum 配置 该包扫描自动注入,查看文件 spring-mybatis.xml 参数 typeEnumsPackage
*/
public enum TypeEnum implements IEnum {
DISABLED(0, "禁用"),
NORMAL(1, "正常");
private final int value;
private final String desc;
TypeEnum(final int value, final String desc) {
this.value = value;
this.desc = desc;
}
@Override
public Serializable getValue() {
return this.value;
}
// Jackson 注解为 JsonValue 返回中文 json 描述
public String getDesc() {
return this.desc;
}
}