From 53e38ec5b1c19742f1a440e25c96130847dd6bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=9D=B0?= Date: Sun, 30 Sep 2018 10:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E7=BB=86?= =?UTF-8?q?=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 +- .../app/rest/system/SysLogController.java | 12 +- .../app/rest/web/WeatherController.java | 2 +- .../java/me/aurora/service/EmailService.java | 2 + .../aurora/service/impl/EmailServiceImpl.java | 11 +- .../aurora/service/impl/MenuServiceImpl.java | 4 + .../service/impl/PermissionServiceImpl.java | 4 + .../service/impl/PictureServiceImpl.java | 2 + .../aurora/service/impl/RoleServiceImpl.java | 5 + .../service/impl/SysLogServiceImpl.java | 2 + .../aurora/service/impl/UserServiceImpl.java | 5 + .../service/query/SysLogQueryService.java | 5 - .../java/me/aurora/util/AuroraConstant.java | 2 +- src/main/resources/templates/common/app.html | 132 ++++++++++++++---- .../resources/templates/system/log/index.html | 6 +- 15 files changed, 149 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/me/aurora/service/query/SysLogQueryService.java diff --git a/pom.xml b/pom.xml index e9067fa..f9a9229 100644 --- a/pom.xml +++ b/pom.xml @@ -71,12 +71,6 @@ spring-boot-starter-data-redis - - - org.crazycake - shiro-redis - 2.8.24 - org.springframework.boot @@ -84,6 +78,13 @@ + + + org.crazycake + shiro-redis + 2.8.24 + + com.google.guava diff --git a/src/main/java/me/aurora/app/rest/system/SysLogController.java b/src/main/java/me/aurora/app/rest/system/SysLogController.java index 85e59e0..d2dca2e 100644 --- a/src/main/java/me/aurora/app/rest/system/SysLogController.java +++ b/src/main/java/me/aurora/app/rest/system/SysLogController.java @@ -1,23 +1,16 @@ package me.aurora.app.rest.system; import lombok.extern.slf4j.Slf4j; -import me.aurora.annotation.Log; import me.aurora.repository.spec.LogSpec; -import org.slf4j.Logger; import me.aurora.service.SysLogService; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; - import java.util.Map; /** @@ -43,7 +36,7 @@ public class SysLogController { } /** - * 查询所有日志s + * 查询所有日志 * @param username * @param method * @param operation @@ -60,7 +53,6 @@ public class SysLogController { @RequestParam(value = "location",required = false) String location, @RequestParam(value = "page",defaultValue = "1")Integer page, @RequestParam(value = "limit",defaultValue = "10")Integer limit){ - log.warn("REST request to findAll Log"); Sort sort = new Sort(Sort.Direction.DESC,"createTime"); Pageable pageable = PageRequest.of(page-1,limit,sort); diff --git a/src/main/java/me/aurora/app/rest/web/WeatherController.java b/src/main/java/me/aurora/app/rest/web/WeatherController.java index 0c8063c..eae83df 100644 --- a/src/main/java/me/aurora/app/rest/web/WeatherController.java +++ b/src/main/java/me/aurora/app/rest/web/WeatherController.java @@ -29,7 +29,7 @@ public class WeatherController { String data = HttpUtils.sendPost(AuroraConstant.MEIZU_WEATHER_URL, "cityIds=" + areaId); return ResponseEntity.ok(data); } catch (Exception e) { - log.error("查询天气失败", e); + log.error("查询天气失败", e.getMessage()); return ResponseEntity.error("查询天气失败,请联系网站管理员!"); } } diff --git a/src/main/java/me/aurora/service/EmailService.java b/src/main/java/me/aurora/service/EmailService.java index 94bd5d7..29a87cb 100644 --- a/src/main/java/me/aurora/service/EmailService.java +++ b/src/main/java/me/aurora/service/EmailService.java @@ -5,6 +5,7 @@ import me.aurora.domain.vo.EmailVo; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.scheduling.annotation.Async; /** * @author 郑杰 @@ -33,5 +34,6 @@ public interface EmailService { * @param emailVo * @param emailConfig */ + @Async void send(EmailVo emailVo, EmailConfig emailConfig) throws Exception; } diff --git a/src/main/java/me/aurora/service/impl/EmailServiceImpl.java b/src/main/java/me/aurora/service/impl/EmailServiceImpl.java index 4c3e92f..059a0a8 100644 --- a/src/main/java/me/aurora/service/impl/EmailServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/EmailServiceImpl.java @@ -11,6 +11,7 @@ import me.aurora.service.EmailService; import me.aurora.util.EncryptHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * @author 郑杰 @@ -35,6 +36,7 @@ public class EmailServiceImpl implements EmailService { } @Override + @Transactional(readOnly = true) public EmailConfig findById(Long id) { EmailConfig emailConfig = emailRepo.findById(id).get(); return emailConfig; @@ -62,6 +64,13 @@ public class EmailServiceImpl implements EmailService { } //是否ssl方式发送 account.setStartttlsEnable(emailConfig.getSslEnable()); + + String content = emailVo.getContent() + "

\n" + + "
\n" + + "

\n" + + "

\n" + + " ------邮件来自Aurora的测试\n" + + "

"; /** * 发送 */ @@ -69,7 +78,7 @@ public class EmailServiceImpl implements EmailService { MailUtil.send(account, emailVo.getTos(), emailVo.getSubject(), - emailVo.getContent(), + content, emailVo.getIsHtml()); }catch (Exception e){ throw new AuroraException(HttpStatus.HTTP_INTERNAL_ERROR,e.getMessage()); diff --git a/src/main/java/me/aurora/service/impl/MenuServiceImpl.java b/src/main/java/me/aurora/service/impl/MenuServiceImpl.java index 7583b64..4f6867e 100644 --- a/src/main/java/me/aurora/service/impl/MenuServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/MenuServiceImpl.java @@ -64,6 +64,7 @@ public class MenuServiceImpl implements MenuService { } @Override + @Transactional(readOnly = true) public Map getMenuInfo(MenuSpec menuSpec, Pageable pageable) { Page menuPage = menuRepo.findAll(menuSpec,pageable); Page menuDTOS = menuPage.map(menuMapper::toDto); @@ -71,12 +72,14 @@ public class MenuServiceImpl implements MenuService { } @Override + @Transactional(readOnly = true) public List findAllMenus() { Integer level = 1; return menuRepo.findAllByLevel(level); } @Override + @Transactional(readOnly = true) public Menu findByPId(Integer pid) { Menu menu = menuRepo.findById(pid.longValue()).get(); ValidationUtil.isNull(menu,"pid:"+pid+"is not find"); @@ -128,6 +131,7 @@ public class MenuServiceImpl implements MenuService { } @Override + @Transactional(readOnly = true) public Menu findById(Long id) { Menu menu = menuRepo.findById(id).get(); ValidationUtil.isNull(menu,"id:"+id+"is not find"); diff --git a/src/main/java/me/aurora/service/impl/PermissionServiceImpl.java b/src/main/java/me/aurora/service/impl/PermissionServiceImpl.java index e95bf7a..6884ac8 100644 --- a/src/main/java/me/aurora/service/impl/PermissionServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/PermissionServiceImpl.java @@ -49,6 +49,7 @@ public class PermissionServiceImpl implements PermissionService { } @Override + @Transactional(readOnly = true) public Permission findById(Long id) { Permission permission = permissionRepo.findById(id).get(); ValidationUtil.isNull(permission,"id:"+id+"is not find"); @@ -78,6 +79,7 @@ public class PermissionServiceImpl implements PermissionService { } @Override + @Transactional(readOnly = true) public List getAll() { return permissionRepo.findAll(); } @@ -104,11 +106,13 @@ public class PermissionServiceImpl implements PermissionService { } @Override + @Transactional(readOnly = true) public List findByPid(int pid) { return permissionRepo.findByPid(pid); } @Override + @Transactional(readOnly = true) public List findByRoles(Set roles) { return permissionRepo.findByRoles(roles); } diff --git a/src/main/java/me/aurora/service/impl/PictureServiceImpl.java b/src/main/java/me/aurora/service/impl/PictureServiceImpl.java index 89c8209..9c65bdd 100644 --- a/src/main/java/me/aurora/service/impl/PictureServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/PictureServiceImpl.java @@ -54,6 +54,7 @@ public class PictureServiceImpl implements PictureService { private PictureMapper pictureMapper; @Override + @Transactional(readOnly = true) public Map getPictureInfo(PictureSpec pictureSpec, Pageable pageable) { Page picturePage = pictureRepo.findAll(pictureSpec,pageable); Page pictureDtos = picturePage.map(pictureMapper::toDto); @@ -90,6 +91,7 @@ public class PictureServiceImpl implements PictureService { } @Override + @Transactional(readOnly = true) public Picture findById(Long id) { Picture picture = pictureRepo.findById(id).get(); ValidationUtil.isNull(picture,"id:"+id+"is not find"); diff --git a/src/main/java/me/aurora/service/impl/RoleServiceImpl.java b/src/main/java/me/aurora/service/impl/RoleServiceImpl.java index 2c989c9..a419745 100644 --- a/src/main/java/me/aurora/service/impl/RoleServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/RoleServiceImpl.java @@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import java.util.*; /** @@ -46,11 +48,13 @@ public class RoleServiceImpl implements RoleService { } @Override + @Transactional(readOnly = true) public List getAllRole() { return roleRepo.findAll(); } @Override + @Transactional(readOnly = true) public Map getRoleInfo(RoleSpec roleSpec, Pageable pageable) { Page roles = roleRepo.findAll(roleSpec,pageable); Page roleDTOS = roles.map(roleMapper::toDto); @@ -67,6 +71,7 @@ public class RoleServiceImpl implements RoleService { } @Override + @Transactional(readOnly = true) public Role findById(Long id) { Role role = roleRepo.findById(id).get(); ValidationUtil.isNull(role,"id:"+id+"is not find"); diff --git a/src/main/java/me/aurora/service/impl/SysLogServiceImpl.java b/src/main/java/me/aurora/service/impl/SysLogServiceImpl.java index 3641223..0b47742 100644 --- a/src/main/java/me/aurora/service/impl/SysLogServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/SysLogServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import java.lang.reflect.Method; @@ -37,6 +38,7 @@ public class SysLogServiceImpl implements SysLogService { private SysLogMapper sysLogMapper; @Override + @Transactional(readOnly = true) public Map getLogInfo(LogSpec logSpec, Pageable pageable) { Page sysLogPage = sysLogRepo.findAll(logSpec,pageable); Page sysLogDTOS = sysLogPage.map(sysLogMapper::toDto); diff --git a/src/main/java/me/aurora/service/impl/UserServiceImpl.java b/src/main/java/me/aurora/service/impl/UserServiceImpl.java index f3edffe..6ac1ca8 100644 --- a/src/main/java/me/aurora/service/impl/UserServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/UserServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.sql.Timestamp; import java.util.*; @@ -44,6 +45,7 @@ public class UserServiceImpl implements UserService { private RoleService roleService; @Override + @Transactional(readOnly = true) public User findById(Long id) { User user = userRepo.findById(id).get(); ValidationUtil.isNull(user,"id:"+id+"is not find"); @@ -51,16 +53,19 @@ public class UserServiceImpl implements UserService { } @Override + @Transactional(readOnly = true) public User findByUsername(String userName) { return userRepo.findByUsername(userName); } @Override + @Transactional(readOnly = true) public User findByEmail(String email) { return userRepo.findByEmail(email); } @Override + @Transactional(readOnly = true) public Map getUsersInfo(UserSpec userSpec, Pageable pageable) { Page users = userRepo.findAll(userSpec,pageable); List userDTOS = new ArrayList<>(); diff --git a/src/main/java/me/aurora/service/query/SysLogQueryService.java b/src/main/java/me/aurora/service/query/SysLogQueryService.java deleted file mode 100644 index 98c2bbe..0000000 --- a/src/main/java/me/aurora/service/query/SysLogQueryService.java +++ /dev/null @@ -1,5 +0,0 @@ -package me.aurora.service.query; - -public class SysLogQueryService { - -} diff --git a/src/main/java/me/aurora/util/AuroraConstant.java b/src/main/java/me/aurora/util/AuroraConstant.java index a080c3d..9e09dd4 100644 --- a/src/main/java/me/aurora/util/AuroraConstant.java +++ b/src/main/java/me/aurora/util/AuroraConstant.java @@ -1,9 +1,9 @@ package me.aurora.util; /** + * 常用接口 * @author 郑杰 * @date 2018/09/29 12:52:06 - * 常用接口 */ public class AuroraConstant { diff --git a/src/main/resources/templates/common/app.html b/src/main/resources/templates/common/app.html index ece919b..fd2da25 100644 --- a/src/main/resources/templates/common/app.html +++ b/src/main/resources/templates/common/app.html @@ -78,30 +78,30 @@
-
-
-
快捷入口
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ + + + + + + + + + + + + + + + + + + + + + + +
版本信息
@@ -114,7 +114,7 @@ 版本号 - Aurora 1.0 + v1.0 前端框架 @@ -122,7 +122,7 @@ 作者 - zhengjie.me + zhengjie 邮箱 @@ -137,11 +137,81 @@
关于Aurora 1.0
-

Aurora是一个简单高效的后台管理系统

-

Aurora是一个简单高效的后台管理系统。项目基础框架采用全新的Java Web开发框架 —— Spring Boot2.0.4,消除了繁杂的XML配置,使得二次开发更为简单

-

数据访问层采用Spring boot Jpa,可快速高效的对单表进行增删改查操作,消除了大量传统XML配置SQL的代码

-

分页使用Pageable,安全框架采用时下流行的Apache Shiro,可实现对按钮级别的权限控制

-

前端页面使用KidAdmin构建,并提供多套配色以供选择。

+
    + +
  • + +
    +

    特别感谢以下开源项目:

    +

    +

    +

    +
    +
  • + +
  • + +
    +

    2018年9月5日 (v1.0)

    +

    + #完成了后台基本搭建,暂无成任何集成 +

      +
    • 主要框架:spring boot+Shiro+Redis
    • +
    • 页面模板:Thymeleaf 3.0.9.RELEASE
    • +
    • 权限管理:采用的是RBAC思想
    • +
    • 密码加密:采用MD5加盐加密
    • +
    • 系统日志:使用aop保存日志
    • +
    • 实体映射:使用MapStruct
    • +
    +

    +
    +
  • +
  • + +
    +

    2018年9月22日 (v1.0.1)

    +

    + #新增了一些常用功能 +

      +
    • 基于redis+shiro的在线用户管理
    • +
    • redis终端管理
    • +
    • 网络图床管理
    • +
    • 统一异常处理
    • +
    +

    +
    +
  • +
  • + +
    +

    2018年9月28日 - 至今 (v1.0.1)

    +

    + #集成了第三方工具 +

      +
    • 百度富文本编辑器
    • +
    • 邮件发送工具
    • +
    • 支付宝支付(开发中)
    • +
    • 微信支付(开发中)
    • +
    • 阿里大鱼(开发中)
    • +
    • 七牛云储存(开发中)
    • +
    +

    +
    +
  • +
  • + +
    + 更新说明 +
    +
  • + +
diff --git a/src/main/resources/templates/system/log/index.html b/src/main/resources/templates/system/log/index.html index e05047a..613772a 100644 --- a/src/main/resources/templates/system/log/index.html +++ b/src/main/resources/templates/system/log/index.html @@ -99,14 +99,14 @@ done: function () { form.render(); //监听提交 - form.on('submit(formDemo_hash)', function (data) { + form.on('submit(formDemo_hash)', function () { table.reload('ID', { where: { username: $('input[name="username"]').val(), operation: $('input[name="operation"]').val(), method: $('input[name="method"]').val(), - location: $('input[name="location"]').val()} - ,page: { + location: $('input[name="location"]').val() + },page: { curr: 1 //重新从第 1 页开始 } });