项目描述:
当今社会的生活水平的提高,现在生活水平技术的日益增长,科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。越来越多的企业也必然要借助先进的信息技术来展示自己公司的信息,产品的介绍,并借助计算机技术来提高管理效率,因此网站建设所体现的重要性越来越突出。一个企业门户网站建设、运行的好坏,直接关系到一个企业的形象,也影响着其管理、服务的质量和水平。对企业门户网站的测评能直接对其建设、运行状况做出科学的评价,并据此对其未来的发展做出科学的规划。通过对企业门户网站的不断完善来推动企业内部管理体制的改革和业务流程的再造,并从根本上在企业的各个部门贯彻服务的理念。
运行环境:
jdk8+tomcat8+mysql5.7+IntelliJ IDEA 2020+maven3.X
项目技术(必填):
spring+spring mvc+mybatis+shrio+jquery+html+bootstrap
研发背景
当今时代信息技术飞速发展,人们已经处于数字化的生存空间之中。Internet构造了无限的信息资源,让我们感受到了科技带来的快感,它的普遍使用已经从根本上改变了人们的生活方式和工作方式。
网络技术的迅猛发展使得基于Web的各类信息系统成为目前信息系统中最为流行的展现形式之一。基于Web的信息系统具有如下一些特点:
(1)有利于信息的及时更新和发布;
(2)便于操作和管理;
(3)拥有良好的用户界面;
(4)灵活性和可扩展性;
(5)系统功能的通用性;
数据库设计
DROP TABLE IF EXISTS `t_auth_user`;
CREATE TABLE `t_auth_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`realname` varchar(50) NOT NULL DEFAULT '' COMMENT '登录用户名',
`username` varchar(50) NOT NULL DEFAULT '' COMMENT '真实姓名',
`password` varchar(32) NOT NULL DEFAULT '' COMMENT '密码',
`gender` tinyint(1) NOT NULL DEFAULT '1' COMMENT '性别',
`header` varchar(128) NOT NULL DEFAULT '' COMMENT '头像',
`mobile` varchar(15) NOT NULL DEFAULT '' COMMENT '手机号码',
`status` tinyint(1) NOT NULL DEFAULT '2' COMMENT '状态:待审核(0),有效(1),无效(3)',
`birthday` date NOT NULL DEFAULT '1900-01-01',
`education` varchar(20) NOT NULL DEFAULT '' COMMENT '学历:大专、本科、硕士、博士、博士后',
`college_code` varchar(50) NOT NULL DEFAULT '' COMMENT '大学编码',
`college_name` varchar(100) NOT NULL DEFAULT '' COMMENT '大学名称',
`cert_no` varchar(50) NOT NULL DEFAULT '' COMMENT '资格证书编号',
`title` varchar(100) NOT NULL DEFAULT '' COMMENT '头衔',
`sign` varchar(500) NOT NULL DEFAULT '' COMMENT '签名',
`open_id` varchar(128) NOT NULL DEFAULT '' COMMENT '微信公众号openid',
`wechat_id` varchar(100) NOT NULL DEFAULT '' COMMENT '微信号',
`qq` varchar(20) NOT NULL DEFAULT '' COMMENT 'qq号',
`login_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '最后一次登录时间',
`ip` varchar(15) NOT NULL DEFAULT '' COMMENT '最后一次登录IP',
`province` varchar(16) NOT NULL DEFAULT '' COMMENT '所在省份',
`city` varchar(16) NOT NULL DEFAULT '' COMMENT '所在城市',
`district` varchar(16) NOT NULL DEFAULT '' COMMENT '所在地区',
`weight` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`create_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`create_user` varchar(32) NOT NULL DEFAULT 'system',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`update_user` varchar(32) NOT NULL DEFAULT 'system',
`del` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `T_AUTH_USER_USERNAME_UNIQUE` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COMMENT='用户表';
DROP TABLE IF EXISTS `t_consts_classify`;
CREATE TABLE `t_consts_classify` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
`code` varchar(50) NOT NULL DEFAULT '',
`parent_code` varchar(50) NOT NULL DEFAULT '0' COMMENT '父级别code',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
`create_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`create_user` varchar(32) NOT NULL DEFAULT 'system',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`update_user` varchar(32) NOT NULL DEFAULT 'system',
`del` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COMMENT='课程类别表';
DROP TABLE IF EXISTS `t_consts_college`;
CREATE TABLE `t_consts_college` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
`code` varchar(50) NOT NULL DEFAULT '' COMMENT '编码',
`picture` varchar(100) NOT NULL DEFAULT '' COMMENT '图片',
`create_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`create_user` varchar(32) NOT NULL DEFAULT 'system',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`update_user` varchar(32) NOT NULL DEFAULT 'system',
`del` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8 COMMENT='高校表结构';
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) DEFAULT NULL COMMENT '用户id',
`username` varchar(50) DEFAULT NULL COMMENT '用户名',
`operation` varchar(50) DEFAULT NULL COMMENT '用户操作',
`time` int(11) DEFAULT NULL COMMENT '响应时间',
`method` varchar(200) DEFAULT NULL COMMENT '请求方法',
`params` varchar(5000) DEFAULT NULL COMMENT '请求参数',
`ip` varchar(64) DEFAULT NULL COMMENT 'IP地址',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=694 DEFAULT CHARSET=utf8 COMMENT='系统日志';
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
`menu_id` bigint(20) NOT NULL AUTO_INCREMENT,
`parent_id` bigint(20) DEFAULT NULL COMMENT '父菜单ID,一级菜单为0',
`name` varchar(50) DEFAULT NULL COMMENT '菜单名称',
`url` varchar(200) DEFAULT NULL COMMENT '菜单URL',
`perms` varchar(500) DEFAULT NULL COMMENT '授权(多个用逗号分隔,如:user:list,user:create)',
`type` int(11) DEFAULT NULL COMMENT '类型 0:目录 1:菜单 2:按钮',
`icon` varchar(50) DEFAULT NULL COMMENT '菜单图标',
`order_num` int(11) DEFAULT NULL COMMENT '排序',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`menu_id`)
) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8 COMMENT='菜单管理';
系统技术架构
主要技术:
SpringBoot、SpringMVC、Mybatis
thymeleaf、jQuery、HTML、CSS、JS
Mysql
bootstrap
开发工具和环境:
Eclipse
Maven
Tomcat 8.5
JDK 1.8
Mysql 5.6+
Win10 操作系统
核心代码实现
package cn.edu.tyut.common.exception;
import cn.edu.tyut.common.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* controller处理器
* @author xyp
* @date 2019-4-20
*/
@RestController
public class MainsiteErrorController implements ErrorController {
private Logger logger = LoggerFactory.getLogger(getClass());
private static final String ERROR_PATH = "/error";
@Autowired
ErrorAttributes errorAttributes;
@RequestMapping(
value = {ERROR_PATH},
produces = {"text/html"}
)
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
int code = response.getStatus();
if (404 == code) {
return new ModelAndView("error/404");
} else if (403 == code) {
return new ModelAndView("error/403");
} else if (401 == code) {
return new ModelAndView("login");
} else {
return new ModelAndView("error/500");
}
}
@RequestMapping(value = ERROR_PATH)
public R handleError(HttpServletRequest request, HttpServletResponse response) {
response.setStatus(200);
int code = response.getStatus();
if (404 == code) {
return R.error(404, "未找到资源");
} else if (403 == code) {
return R.error(403, "没有访问权限");
} else if (401 == code) {
return R.error(403, "登录过期");
} else {
return R.error(500, "服务器错误");
}
}
@Override
public String getErrorPath() {
// TODO Auto-generated method stub
return ERROR_PATH;
}
}
rediscache实现
package cn.edu.tyut.common.redis.shiro;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.util.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author xyp
* @date 2019-4-20
*/
public class RedisCache<K, V> implements Cache<K, V> {
private Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* The wrapped Jedis instance.
*/
private RedisManager cache;
/**
* The Redis key prefix for the sessions
*/
private String keyPrefix = "shiro_redis_session:";
/**
* Returns the Redis session keys
* prefix.
* @return The prefix
*/
public String getKeyPrefix() {
return keyPrefix;
}
/**
* Sets the Redis sessions key
* prefix.
* @param keyPrefix The prefix
*/
public void setKeyPrefix(String keyPrefix) {
this.keyPrefix = keyPrefix;
}
/**
* 通过一个JedisManager实例构造RedisCache
*/
public RedisCache(RedisManager cache){
if (cache == null) {
throw new IllegalArgumentException("Cache argument cannot be null.");
}
this.cache = cache;
}
/**
* Constructs a cache instance with the specified
* Redis manager and using a custom key prefix.
* @param cache The cache manager instance
* @param prefix The Redis key prefix
*/
public RedisCache(RedisManager cache,
String prefix){
this( cache );
// set the prefix
this.keyPrefix = prefix;
}
/**
* 获得byte[]型的key
* @param key
* @return
*/
private byte[] getByteKey(K key){
if(key instanceof String){
String preKey = this.keyPrefix + key;
return preKey.getBytes();
}else{
return SerializeUtils.serialize(key);
}
}
@Override
public V get(K key) throws CacheException {
logger.debug("根据key从Redis中获取对象 key [" + key + "]");
try {
if (key == null) {
return null;
}else{
byte[] rawValue = cache.get(getByteKey(key));
@SuppressWarnings("unchecked")
V value = (V)SerializeUtils.deserialize(rawValue);
return value;
}
} catch (Throwable t) {
throw new CacheException(t);
}
}
@Override
public V put(K key, V value) throws CacheException {
logger.debug("根据key从存储 key [" + key + "]");
try {
cache.set(getByteKey(key), SerializeUtils.serialize(value));
return value;
} catch (Throwable t) {
throw new CacheException(t);
}
}
@Override
public V remove(K key) throws CacheException {
logger.debug("从redis中删除 key [" + key + "]");
try {
V previous = get(key);
cache.del(getByteKey(key));
return previous;
} catch (Throwable t) {
throw new CacheException(t);
}
}
@Override
public void clear() throws CacheException {
logger.debug("从redis中删除所有元素");
try {
cache.flushDB();
} catch (Throwable t) {
throw new CacheException(t);
}
}
@Override
public int size() {
try {
Long longSize = new Long(cache.dbSize());
return longSize.intValue();
} catch (Throwable t) {
throw new CacheException(t);
}
}
@SuppressWarnings("unchecked")
@Override
public Set<K> keys() {
try {
Set<byte[]> keys = cache.keys(this.keyPrefix + "*");
if (CollectionUtils.isEmpty(keys)) {
return Collections.emptySet();
}else{
Set<K> newKeys = new HashSet<K>();
for(byte[] key:keys){
newKeys.add((K)key);
}
return newKeys;
}
} catch (Throwable t) {
throw new CacheException(t);
}
}
@Override
public Collection<V> values() {
try {
Set<byte[]> keys = cache.keys(this.keyPrefix + "*");
if (!CollectionUtils.isEmpty(keys)) {
List<V> values = new ArrayList<V>(keys.size());
for (byte[] key : keys) {
@SuppressWarnings("unchecked")
V value = get((K)key);
if (value != null) {
values.add(value);
}
}
return Collections.unmodifiableList(values);
} else {
return Collections.emptyList();
}
} catch (Throwable t) {
throw new CacheException(t);
}
}
}
```java
package cn.edu.tyut.common.redis.shiro;
import java.util.Set;
import org.springframework.beans.factory.annotation.Value;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* @author xyp
* @date 2019-4-20
*/
public class RedisManager {
@Value("${spring.redis.host}")
private String host = "127.0.0.1";
@Value("${spring.redis.port}")
private int port = 6379;
// 0 - never expire
private int expire = 0;
//timeout for jedis try to connect to redis server, not expire time! In milliseconds
@Value("${spring.redis.timeout}")
private int timeout = 0;
@Value("${spring.redis.password}")
private String password = "";
private static JedisPool jedisPool = null;
public RedisManager() {
}
/**
* 初始化方法
*/
public void init() {
if (jedisPool == null) {
if (password != null && !"".equals(password)) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout, password);
} else if (timeout != 0) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout);
} else {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port);
}
}
}
/**
* get value from redis
*
* @param key
* @return
*/
public byte[] get(byte[] key) {
byte[] value = null;
Jedis jedis = jedisPool.getResource();
try {
value = jedis.get(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @return
*/
public byte[] set(byte[] key, byte[] value) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (this.expire != 0) {
jedis.expire(key, this.expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @param expire
* @return
*/
public byte[] set(byte[] key, byte[] value, int expire) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (expire != 0) {
jedis.expire(key, expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* del
*
* @param key
*/
public void del(byte[] key) {
Jedis jedis = jedisPool.getResource();
try {
jedis.del(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* flush
*/
public void flushDB() {
Jedis jedis = jedisPool.getResource();
try {
jedis.flushDB();
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* size
*/
public Long dbSize() {
Long dbSize = 0L;
Jedis jedis = jedisPool.getResource();
try {
dbSize = jedis.dbSize();
} finally {
if (jedis != null) {
jedis.close();
}
}
return dbSize;
}
/**
* keys
*
* @param regex
* @return
*/
public Set<byte[]> keys(String pattern) {
Set<byte[]> keys = null;
Jedis jedis = jedisPool.getResource();
try {
keys = jedis.keys(pattern.getBytes());
} finally {
if (jedis != null) {
jedis.close();
}
}
return keys;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public int getExpire() {
return expire;
}
public void setExpire(int expire) {
this.expire = expire;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
```java
package cn.edu.tyut.common.service.impl;
import cn.edu.tyut.common.domain.DictDO;
import cn.edu.tyut.common.utils.StringUtils;
import cn.edu.tyut.common.utils.StringUtils;
import cn.edu.tyut.system.domain.UserDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import cn.edu.tyut.common.dao.DictDao;
import cn.edu.tyut.common.domain.DictDO;
import cn.edu.tyut.common.service.DictService;
@Service
public class DictServiceImpl implements DictService {
@Autowired
private DictDao dictDao;
@Override
public DictDO get(Long id) {
return dictDao.get(id);
}
@Override
public List<DictDO> list(Map<String, Object> map) {
return dictDao.list(map);
}
@Override
public int count(Map<String, Object> map) {
return dictDao.count(map);
}
@Override
public int save(DictDO dict) {
return dictDao.save(dict);
}
@Override
public int update(DictDO dict) {
return dictDao.update(dict);
}
@Override
public int remove(Long id) {
return dictDao.remove(id);
}
@Override
public int batchRemove(Long[] ids) {
return dictDao.batchRemove(ids);
}
@Override
public List<DictDO> listType() {
return dictDao.listType();
}
@Override
public String getName(String type, String value) {
Map<String, Object> param = new HashMap<String, Object>(16);
param.put("type", type);
param.put("value", value);
String rString = dictDao.list(param).get(0).getName();
return rString;
}
@Override
public List<DictDO> getHobbyList(UserDO userDO) {
Map<String, Object> param = new HashMap<>(16);
param.put("type", "hobby");
List<DictDO> hobbyList = dictDao.list(param);
if (StringUtils.isNotEmpty(userDO.getHobby())) {
String userHobbys[] = userDO.getHobby().split(";");
for (String userHobby : userHobbys) {
for (DictDO hobby : hobbyList) {
if (!Objects.equals(userHobby, hobby.getId().toString())) {
continue;
}
hobby.setRemarks("true");
break;
}
}
}
return hobbyList;
}
@Override
public List<DictDO> getSexList() {
Map<String, Object> param = new HashMap<>(16);
param.put("type", "sex");
return dictDao.list(param);
}
@Override
public List<DictDO> listByType(String type) {
Map<String, Object> param = new HashMap<>(16);
param.put("type", type);
return dictDao.list(param);
}
}
日志的实现
package cn.edu.tyut.common.service.impl;
import java.util.List;
import cn.edu.tyut.common.domain.LogDO;
import cn.edu.tyut.common.domain.PageDO;
import cn.edu.tyut.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import cn.edu.tyut.common.dao.LogDao;
import cn.edu.tyut.common.domain.LogDO;
import cn.edu.tyut.common.domain.PageDO;
import cn.edu.tyut.common.service.LogService;
import cn.edu.tyut.common.utils.Query;
@Service
public class LogServiceImpl implements LogService {
@Autowired
LogDao logMapper;
@Async
@Override
public void save(LogDO logDO) {
logMapper.save(logDO);
}
@Override
public PageDO<LogDO> queryList(Query query) {
int total = logMapper.count(query);
List<LogDO> logs = logMapper.list(query);
PageDO<LogDO> page = new PageDO<>();
page.setTotal(total);
page.setRows(logs);
return page;
}
@Override
public int remove(Long id) {
int count = logMapper.remove(id);
return count;
}
@Override
public int batchRemove(Long[] ids){
return logMapper.batchRemove(ids);
}
}










