Merge remote-tracking branch 'origin/master'

master
星期八 5 years ago
commit 5a3d8d2475
  1. 2
      src/main/java/com/lq/cms/service/impl/SysLogServiceImpl.java
  2. 18
      src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java
  3. 8
      src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java
  4. 20
      src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java
  5. 2
      src/main/java/com/lq/cms/service/impl/SysRoleServiceImpl.java
  6. 2
      src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java
  7. 2
      src/main/java/com/lq/cms/service/impl/SysUserServiceImpl.java
  8. 2
      src/main/java/com/lq/cms/service/impl/WechatInfoServiceImpl.java
  9. 27
      src/main/java/com/lq/cms/web/sys/UserController.java
  10. 10
      src/main/java/com/lq/code/dao/BaseDao.java
  11. 1
      src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java
  12. 36
      src/main/java/com/lq/code/service/BaseService.java
  13. 2
      src/main/java/com/lq/code/service/impl/BaseServiceImpl.java
  14. 20
      src/main/java/com/lq/code/util/ArrayUtil.java
  15. 2
      src/main/profile/dev/jdbc.properties
  16. 2
      src/main/profile/dev/redis.properties
  17. 2
      src/main/profile/pro/file.properties
  18. 2
      src/main/profile/pro/jdbc.properties
  19. 2
      src/main/profile/pro/redis.properties
  20. 3
      src/main/resources/mybatis/mapping/SysPermissionDao.xml
  21. 5
      src/main/webapp/WEB-INF/views/jsp/cms/login.jsp
  22. 17
      src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp
  23. 27
      src/main/webapp/WEB-INF/views/jsp/cms/main/userEdit.jsp
  24. 6
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/info/index.jsp
  25. 2
      src/test/java/com/lq/BaseTest.java
  26. 5
      src/test/java/com/lq/SysPermissionServiceTest.java
  27. 22
      src/test/java/com/lq/code/util/ArrayUtilTest.java

@ -15,7 +15,7 @@ import java.util.List;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class SysLogServiceImpl extends BaseServiceImpl<SysLog> implements SysLogService {
public class SysLogServiceImpl implements SysLogService {
@Autowired
private SysLogDao sysLogDao;

@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* @Author: qi
@ -26,7 +27,7 @@ import java.util.List;
* @Date: Create in 12:06 AM 2019/7/23
*/
@Service
public class SysPermissionServiceImpl extends BaseServiceImpl<SysPermission> implements SysPermissionService{
public class SysPermissionServiceImpl implements SysPermissionService{
@Autowired
private SysPermissionDao sysPermissionDao;
@ -39,20 +40,23 @@ public class SysPermissionServiceImpl extends BaseServiceImpl<SysPermission> imp
public List<SysPermissionVo> findListPage(SysPermissionVo vo) {
List<SysPermissionVo> sysPermissionVos = sysPermissionDao.findListPage(vo);
sysPermissionVos.forEach(sysPermissionVo1->{
if (sysPermissionVo1.getSysResourceId()!=null) {
SysResource sysResource = sysResourceDao.findOne(sysPermissionVo1.getSysResourceId());
Optional<Long> sysResourceIdOptional = Optional.of(sysPermissionVo1.getSysResourceId());
if (sysResourceIdOptional.isPresent()) {
SysResource sysResource = sysResourceDao.findOne(sysResourceIdOptional.get());
if (sysResource!=null) {
sysPermissionVo1.setSysResourceName(sysResource.getMenuName());
}
}
if (sysPermissionVo1.getCreateUserId()!=null) {
SysUser createUser = sysUserDao.findOne(sysPermissionVo1.getCreateUserId());
Optional<Long> createUserIdOptional = Optional.of(sysPermissionVo1.getCreateUserId());
if (createUserIdOptional.isPresent()) {
SysUser createUser = sysUserDao.findOne(createUserIdOptional.get());
if (createUser!=null) {
sysPermissionVo1.setCreateUserName(createUser.getLoginName());
}
}
if (sysPermissionVo1.getUpdateUserId()!=null) {
SysUser updateUser = sysUserDao.findOne(sysPermissionVo1.getUpdateUserId());
Optional<Long> updateUserIdOptional = Optional.of(sysPermissionVo1.getUpdateUserId());
if (updateUserIdOptional.isPresent()) {
SysUser updateUser = sysUserDao.findOne(updateUserIdOptional.get());
if (updateUser!=null) {
sysPermissionVo1.setUpdateUserName(updateUser.getLoginName());
}

@ -52,13 +52,13 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> impleme
@Override
public List<MenusComposite> findMenusListBySysUserId(Long sysUserId, String contextPath) {
Map<String,Object> map=new HashMap(3);
Map<String,Object> map=new HashMap(3);
map.put("userId",sysUserId);
map.put("parentId", Constant.TOP_PARENT_ID);
map.put("permissionId", PermissionTyepEnum.SELECT.getValue());
List<SysResource> menusItmeList=sysResourceDao.findMenu(map);
List<MenusComposite> list=new ArrayList<>();
for (SysResource sysResource:menusItmeList){
menusItmeList.forEach(sysResource->{
MenusItem menusItem=new MenusItem();
menusItem.setMenuname(sysResource.getMenuName());
menusItem.setIcon(sysResource.getMenuIco());
@ -74,7 +74,9 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> impleme
menusItem.add(menus);
}
list.add(menusItem);
}
});
return list;
}

@ -27,7 +27,7 @@ import java.util.*;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRoleResourcePermission> implements SysRoleResourcePermissionService {
public class SysRoleResourcePermissionServiceImpl implements SysRoleResourcePermissionService {
public static final String RESOURCE_SYMBOL = "_";
@ -128,10 +128,10 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRol
public List<PermissionVo> findAllPermissonVo() {
List<PermissionVo> list = new ArrayList<>();
List<SysResource> sysResourceList = sysResourceDao.findAll();
Iterator iterator = sysResourceList.iterator();
Iterator<SysResource> iterator = sysResourceList.iterator();
PermissionTyepEnum[] tyepEnums = PermissionTyepEnum.values();
while (iterator.hasNext()){
SysResource sysResource = (SysResource) iterator.next();
SysResource sysResource = iterator.next();
if (sysResource!=null){
for (PermissionTyepEnum permissionTyepEnum:tyepEnums){
PermissionVo permissionVo = new PermissionVo();
@ -151,19 +151,21 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl<SysRol
*内部方法用于判断角色是否有权限
*/
private boolean isCheck(Long resourceId,Long permissionId,Long roleId){
SysRoleResourcePermission roleResourcePermission=sysRoleResourcePermissionDao.getByResourceIdAndPermissionIdAndRoleId(resourceId,permissionId,roleId);
if (roleResourcePermission!=null&&StatusTypeEnum.STATUS_ACTIVITY_YES.getValue().equals(roleResourcePermission.getStatus())){
return true;
}else{
return false;
boolean result = false;
if (permissionId!=null&&roleId!=null){
SysRoleResourcePermission roleResourcePermission=sysRoleResourcePermissionDao.getByResourceIdAndPermissionIdAndRoleId(resourceId,permissionId,roleId);
if (roleResourcePermission!=null&&StatusTypeEnum.STATUS_ACTIVITY_YES.getValue().equals(roleResourcePermission.getStatus())){
result = true;
}
}
return result;
}
/**
*内部方法拼接资源和权限ID
*/
private Map<String,Object> getAttributes(Long resourceId,Long permissionId){
Map<String,Object> map=new HashMap<>();
Map<String,Object> map=new HashMap<>(1);
map.put(PERMISSIONID_KEY,resourceId+RESOURCE_SYMBOL+permissionId);
return map;
}

@ -22,7 +22,7 @@ import java.util.Map;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class SysRoleServiceImpl extends BaseServiceImpl<SysRole> implements SysRoleService {
public class SysRoleServiceImpl implements SysRoleService {
@Autowired
private SysRoleDao sysRoleDao;

@ -19,7 +19,7 @@ import java.util.Map;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class SysUserRoleServiceImpl extends BaseServiceImpl<SysUserRole> implements SysUserRoleService {
public class SysUserRoleServiceImpl implements SysUserRoleService {
@Autowired
private SysUserRoleDao sysUserRoleDao;

@ -18,7 +18,7 @@ import java.util.List;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class SysUserServiceImpl extends BaseServiceImpl<SysUser> implements SysUserService {
public class SysUserServiceImpl implements SysUserService {
@Autowired
private SysUserDao sysUserDao;

@ -15,7 +15,7 @@ import java.util.List;
* Created by qi_liang on 2018/6/21.
*/
@Service
public class WechatInfoServiceImpl extends BaseServiceImpl<WechatInfo> implements WechatInfoService {
public class WechatInfoServiceImpl implements WechatInfoService {
@Autowired
private WechatInfoDao wechatInfoDao;

@ -8,11 +8,17 @@ import com.lq.cms.service.SysUserService;
import com.lq.cms.vo.SysUserRoleVo;
import com.lq.cms.vo.SysUserVo;
import com.lq.code.entity.AjaxResult;
import com.lq.code.interceptor.shiro.ShiroRealm;
import com.lq.code.util.*;
import com.lq.entity.SysUser;
import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.mgt.RealmSecurityManager;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -136,7 +142,7 @@ public class UserController {
}
//内部方法 ,上传文件,并返回文件路径
private String upLoadFile(MultipartFile multipartFile){
final private String upLoadFile(MultipartFile multipartFile){
String newFileName = null;
if (multipartFile!=null && multipartFile.getSize()>0){
UUID uuid = UUID.randomUUID();
@ -181,15 +187,28 @@ public class UserController {
return ajaxResult;
}
public AjaxResult updateUser(SysUser sysUser){
@RequestMapping("/updateUser")
@ResponseBody
public AjaxResult updateUser(SysUser sysUser,@RequestParam(value = "uploadFile",required = false) MultipartFile uploadFile){
Subject subject = SecurityUtils.getSubject();
SysUser loginUser =(SysUser)subject.getPrincipal();
if (loginUser!=null){
BeanUtil.copyNotNull(loginUser,sysUser);
String uploadFileName =upLoadFile(uploadFile);
loginUser.setUpdateTime(new Date());
if (StringUtil.isNotNull(uploadFileName)) {
loginUser.setImgUrl(uploadFileName);
}
sysUserService.update(loginUser);
RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
PrincipalCollection principalCollection = subject.getPrincipals();
String realName = principalCollection.getRealmNames().iterator().next();
PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(loginUser,realName);
subject.runAs(newPrincipalCollection);
}
return new AjaxResult();
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.setData(loginUser);
return ajaxResult;
}

@ -23,7 +23,7 @@ public interface BaseDao<T> extends BaseMapper<T> {
* @param entity
* @return
*/
void update(T entity);
int update(T entity);
/**
* 通过id 查找单个对象
@ -43,25 +43,25 @@ public interface BaseDao<T> extends BaseMapper<T> {
* 删除一条数据
* @param id
*/
void delete(@Param("id") Long id);
int delete(@Param("id") Long id);
/**
* 批量保存数据
* @param entitylist
*/
void batchSave(List<T> entitylist);
int batchSave(List<T> entitylist);
/**
* 批量更新数据
* @param entitylist
*/
void batchUpdate(List<T> entitylist);
int batchUpdate(List<T> entitylist);
/**
* 批量删除数据
* @param entitylist
*/
void batchDelete(List<T> entitylist);
int batchDelete(List<T> entitylist);
}

@ -87,7 +87,6 @@ public class ShiroRealm extends AuthorizingRealm {
sysUser.setLastLoginTime(new Date());
sysUserService.update(sysUser);
String realmName=this.getName();
// Object principal= token.getPrincipal();
return new SimpleAuthenticationInfo(sysUser,password,realmName);
}
}

@ -1,6 +1,7 @@
package com.lq.code.service;
import com.lq.code.dao.BaseDao;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -11,20 +12,39 @@ public interface BaseService<T> {
BaseDao<T> getBaseDao();
T findOne(Long id);
default T findOne(Long id){
return getBaseDao().findOne(id);
}
List<T> findAll();
default List<T> findAll(){
return getBaseDao().findAll();
}
Long save(T entity);
default Long save(T entity){
return getBaseDao().save(entity);
}
void update(T entity);
default void update(T entity){
getBaseDao().update(entity);
}
void delete(Long id);
default void delete(Long id){
getBaseDao().delete(id);
}
void batchSave(List<T> entitylist);
@Transactional
default void batchSave(List<T> entitylist){
getBaseDao().batchSave(entitylist);
}
void batchUpdate(List<T> entitylist);
@Transactional
default void batchUpdate(List<T> entitylist){
getBaseDao().batchSave(entitylist);
}
void batchDelete(List<T> entitylist);
@Transactional
default void batchDelete(List<T> entitylist){
getBaseDao().batchDelete(entitylist);
}
}

@ -8,7 +8,9 @@ import java.util.List;
/**
* Created by qi_liang on 2018/6/21.
*  采用jdk8 默认方法所以该实现类废弃
*/
@Deprecated
public abstract class BaseServiceImpl<T> implements BaseService<T>{
@Override
public abstract BaseDao<T> getBaseDao();

@ -0,0 +1,20 @@
package com.lq.code.util;
/**
* @Author: qi
* @Description:数组工具类
* @Date: Create in 10:42 PM 2019/9/19
*/
public class ArrayUtil {
/**
* 生成数组
* @param values
* @param <T>
* @return
*/
public static <T> T [] of(T... values){
return values;
}
}

@ -1,6 +1,6 @@
#--------- jdbc 配置---------
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.31.110:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.user=root
jdbc.password=mysql
#--------数据库连接池配置 -------

@ -1,4 +1,4 @@
redis.host=192.168.31.110
redis.host=localhost
redis.port=6379
redis.pass=
redis.timeout=-1

@ -1 +1 @@
file.upload=/Users/qi/java/fileManger/
file.upload=/home/nfs/fileManger/

@ -1,6 +1,6 @@
#--------- jdbc 配置---------
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.url=jdbc:mysql://192.168.31.19:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
jdbc.user=root
jdbc.password=mysql
#--------数据库连接池配置 -------

@ -1,4 +1,4 @@
redis.host=127.0.0.1
redis.host=192.168.31.19
redis.port=6379
redis.pass=
redis.timeout=-1

@ -55,7 +55,8 @@
</insert>
<update id="update" parameterType="com.lq.entity.SysPermission">
<update id="update" parameterType="com.lq.entity.SysPermission" >
UPDATE
sys_permission
<trim prefix="set" suffixOverrides=",">

@ -52,7 +52,7 @@
<div class="center">
<h1>
<i class="icon-leaf green"></i>
<span class="red">cms</span>
<span class="red">ssm</span>
<span class="white">管理后台应用</span>
</h1>
<h4 class="blue">&copy; 星期八</h4>
@ -131,7 +131,7 @@
</div>
</div><!-- /widget-main -->
<div class="toolbar clearfix">
<!-- <div class="toolbar clearfix">
<div>
<a href="#" onclick="show_box('forgot-box'); return false;" class="forgot-password-link">
<i class="icon-arrow-left"></i>
@ -146,6 +146,7 @@
</a>
</div>
</div>
-->
</div><!-- /widget-body -->
</div><!-- /login-box -->

@ -25,14 +25,14 @@
<a href="#" class="navbar-brand">
<small>
<i class="icon-leaf"></i>
ACE后台管理系统
ssm后台管理系统
</small>
</a><!-- /.brand -->
</div><!-- /.navbar-header -->
<div class="navbar-header pull-right" role="navigation">
<ul class="nav ace-nav">
<li class="grey">
<!-- <li class="grey">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<i class="icon-tasks"></i>
<span class="badge badge-grey">4</span>
@ -240,7 +240,7 @@
</li>
</ul>
</li>
-->
<li class="light-blue">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
@ -256,13 +256,13 @@
</a>
<ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
<li>
<a href="#">
<!-- <li>
<a href="javascript:openSetting()">
<i class="icon-cog"></i>
设置
</a>
</li>
-->
<li>
<a href="javascript:setUserData()">
<i class="icon-user"></i>
@ -375,5 +375,10 @@
}
});
}
//设置
function openSetting() {
layer.alert("功能正在开发中。。。。");
}
</script>

@ -33,7 +33,7 @@
用户名:
</td>
<td class="right_td">
<input type="text" name="userName" value="${sysUser.loginName}">
<input type="text" id="loginName" name="loginName" value="${sysUser.loginName}">
</td>
</tr>
<tr>
@ -41,7 +41,7 @@
邮箱:
</td>
<td class="right_td">
<input type="text" name="email" value="${sysUser.email}" >
<input type="text" id="email" name="email" value="${sysUser.email}" >
</td>
</tr>
<tr>
@ -52,21 +52,22 @@
<img src="${ctx}/loadFile/${sysUser.imgUrl}" border="2"
width="100" height="100" style="border-radius:12px;"
id="uploadBtn" onerror="imageError(this)">
<input type="file" style="visibility:hidden;" id="uploadFile">
<input type="file" style="visibility:hidden;" id="uploadFile" name="uploadFile">
</td>
</tr>
<tr>
<td class="left_td">
备注:
</td>
<td>
<textarea id="" rows="4"> </textarea>
<td class="right_td">
<textarea id="remarks" rows="4">${sysUser.remarks}</textarea>
</td>
</tr>
</table>
</body>
<script type="text/javascript" src="${ctx}/resources/code/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/code/js/imageUtil.js"></script>
<script type="text/javascript" src="${ctx}/resources/code/js/ajaxfileupload.js"></script>
<script>
$(function () {
$("#uploadBtn").click(function () {
@ -79,7 +80,21 @@
});
function postDate() {
alert("提交数据");
var obj = new Object();
obj.loginName=$("#loginName").val();
obj.remarks=$("#remarks").val();
obj.email=$("#email").val();
$.ajaxFileUpload({
url: "${ctx}/cms/user/updateUser",
dataType:"json",
type:"post",
data:obj,
fileElementId:"uploadFile",
success: function(result){
if(result.success==true){
layer.msg(result.msg);
}
}});
}
</script>

@ -26,9 +26,9 @@
console.log(row);
var html="<a href='#' onclick='openEdit(\"编辑\","+row.id+")'>编辑</a>&nbsp&nbsp";
html+="<a href='#' onclick='del("+row.id+")'>删除</a>&nbsp&nbsp";
if (row.wechatInfoType!=1){
html+="<a href='#' onclick='openMenu("+row.id+")'>菜单</a>&nbsp&nbsp";
}
// if (row.wechatInfoType!=1){
// html+="<a href='#' onclick='openMenu("+row.id+")'>菜单</a>&nbsp&nbsp";
// }
html+="<a href='#' onclick='openRule("+row.id+")'>回复</a>&nbsp&nbsp";
return html;
}},

@ -6,5 +6,5 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {"/spring-mybatis-config.xml","/spring-import.xml"})
public class BaseTest {
public abstract class BaseTest {
}

@ -16,7 +16,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
public class SysPermissionServiceTest extends BaseTest {
@Autowired
@ -27,6 +26,10 @@ public class SysPermissionServiceTest extends BaseTest {
private SysResourceDao sysResourceDao;
@Test
public void test1(){
}
public void test(){
//1.查询所有菜单

@ -0,0 +1,22 @@
package com.lq.code.util;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @Author: qi
* @Description:
* @Date: Create in 10:44 PM 2019/9/19
*/
public class ArrayUtilTest {
@Test
public void of() {
String [] strArray = ArrayUtil.of("hello","world","!");
Integer[] intArray = ArrayUtil.of(1,2,2,3,4,5);
}
}
Loading…
Cancel
Save