diff --git a/src/main/java/com/lq/cms/service/impl/SysLogServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysLogServiceImpl.java index 5e3e398..c5a807a 100755 --- a/src/main/java/com/lq/cms/service/impl/SysLogServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysLogServiceImpl.java @@ -15,7 +15,7 @@ import java.util.List; * Created by qi_liang on 2018/6/21. */ @Service -public class SysLogServiceImpl extends BaseServiceImpl implements SysLogService { +public class SysLogServiceImpl implements SysLogService { @Autowired private SysLogDao sysLogDao; diff --git a/src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java index 6310155..daef001 100644 --- a/src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysPermissionServiceImpl.java @@ -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 implements SysPermissionService{ +public class SysPermissionServiceImpl implements SysPermissionService{ @Autowired private SysPermissionDao sysPermissionDao; @@ -39,20 +40,23 @@ public class SysPermissionServiceImpl extends BaseServiceImpl imp public List findListPage(SysPermissionVo vo) { List sysPermissionVos = sysPermissionDao.findListPage(vo); sysPermissionVos.forEach(sysPermissionVo1->{ - if (sysPermissionVo1.getSysResourceId()!=null) { - SysResource sysResource = sysResourceDao.findOne(sysPermissionVo1.getSysResourceId()); + Optional 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 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 updateUserIdOptional = Optional.of(sysPermissionVo1.getUpdateUserId()); + if (updateUserIdOptional.isPresent()) { + SysUser updateUser = sysUserDao.findOne(updateUserIdOptional.get()); if (updateUser!=null) { sysPermissionVo1.setUpdateUserName(updateUser.getLoginName()); } diff --git a/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java index 2770678..4fc6597 100755 --- a/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysResourceServiceImpl.java @@ -52,13 +52,13 @@ public class SysResourceServiceImpl extends BaseServiceImpl impleme @Override public List findMenusListBySysUserId(Long sysUserId, String contextPath) { - Map map=new HashMap(3); + Map map=new HashMap(3); map.put("userId",sysUserId); map.put("parentId", Constant.TOP_PARENT_ID); map.put("permissionId", PermissionTyepEnum.SELECT.getValue()); List menusItmeList=sysResourceDao.findMenu(map); List 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 impleme menusItem.add(menus); } list.add(menusItem); - } + + }); + return list; } diff --git a/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java index 744544b..49aa6d0 100755 --- a/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysRoleResourcePermissionServiceImpl.java @@ -27,7 +27,7 @@ import java.util.*; * Created by qi_liang on 2018/6/21. */ @Service -public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl implements SysRoleResourcePermissionService { +public class SysRoleResourcePermissionServiceImpl implements SysRoleResourcePermissionService { public static final String RESOURCE_SYMBOL = "_"; @@ -128,10 +128,10 @@ public class SysRoleResourcePermissionServiceImpl extends BaseServiceImpl findAllPermissonVo() { List list = new ArrayList<>(); List sysResourceList = sysResourceDao.findAll(); - Iterator iterator = sysResourceList.iterator(); + Iterator 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 getAttributes(Long resourceId,Long permissionId){ - Map map=new HashMap<>(); + Map map=new HashMap<>(1); map.put(PERMISSIONID_KEY,resourceId+RESOURCE_SYMBOL+permissionId); return map; } diff --git a/src/main/java/com/lq/cms/service/impl/SysRoleServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysRoleServiceImpl.java index 1505379..3a8ed0e 100755 --- a/src/main/java/com/lq/cms/service/impl/SysRoleServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysRoleServiceImpl.java @@ -22,7 +22,7 @@ import java.util.Map; * Created by qi_liang on 2018/6/21. */ @Service -public class SysRoleServiceImpl extends BaseServiceImpl implements SysRoleService { +public class SysRoleServiceImpl implements SysRoleService { @Autowired private SysRoleDao sysRoleDao; diff --git a/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java index 7b7fab1..5a3c0f5 100755 --- a/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java @@ -19,7 +19,7 @@ import java.util.Map; * Created by qi_liang on 2018/6/21. */ @Service -public class SysUserRoleServiceImpl extends BaseServiceImpl implements SysUserRoleService { +public class SysUserRoleServiceImpl implements SysUserRoleService { @Autowired private SysUserRoleDao sysUserRoleDao; diff --git a/src/main/java/com/lq/cms/service/impl/SysUserServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysUserServiceImpl.java index 8d2c5fa..872eade 100755 --- a/src/main/java/com/lq/cms/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysUserServiceImpl.java @@ -18,7 +18,7 @@ import java.util.List; * Created by qi_liang on 2018/6/21. */ @Service -public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService { +public class SysUserServiceImpl implements SysUserService { @Autowired private SysUserDao sysUserDao; diff --git a/src/main/java/com/lq/cms/service/impl/WechatInfoServiceImpl.java b/src/main/java/com/lq/cms/service/impl/WechatInfoServiceImpl.java index 506591a..ff1277b 100755 --- a/src/main/java/com/lq/cms/service/impl/WechatInfoServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/WechatInfoServiceImpl.java @@ -15,7 +15,7 @@ import java.util.List; * Created by qi_liang on 2018/6/21. */ @Service -public class WechatInfoServiceImpl extends BaseServiceImpl implements WechatInfoService { +public class WechatInfoServiceImpl implements WechatInfoService { @Autowired private WechatInfoDao wechatInfoDao; diff --git a/src/main/java/com/lq/cms/web/sys/UserController.java b/src/main/java/com/lq/cms/web/sys/UserController.java index 7bd4760..e62139d 100755 --- a/src/main/java/com/lq/cms/web/sys/UserController.java +++ b/src/main/java/com/lq/cms/web/sys/UserController.java @@ -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; } diff --git a/src/main/java/com/lq/code/dao/BaseDao.java b/src/main/java/com/lq/code/dao/BaseDao.java index 06c9b99..1f1fcc2 100755 --- a/src/main/java/com/lq/code/dao/BaseDao.java +++ b/src/main/java/com/lq/code/dao/BaseDao.java @@ -23,7 +23,7 @@ public interface BaseDao extends BaseMapper { * @param entity * @return */ - void update(T entity); + int update(T entity); /** * 通过id 查找单个对象 @@ -43,25 +43,25 @@ public interface BaseDao extends BaseMapper { * 删除一条数据 * @param id */ - void delete(@Param("id") Long id); + int delete(@Param("id") Long id); /** * 批量保存数据 * @param entitylist */ - void batchSave(List entitylist); + int batchSave(List entitylist); /** * 批量更新数据 * @param entitylist */ - void batchUpdate(List entitylist); + int batchUpdate(List entitylist); /** * 批量删除数据 * @param entitylist */ - void batchDelete(List entitylist); + int batchDelete(List entitylist); } diff --git a/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java b/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java index f271a58..b415b08 100755 --- a/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java +++ b/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java @@ -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); } } diff --git a/src/main/java/com/lq/code/service/BaseService.java b/src/main/java/com/lq/code/service/BaseService.java index 21f1f36..863c3ac 100755 --- a/src/main/java/com/lq/code/service/BaseService.java +++ b/src/main/java/com/lq/code/service/BaseService.java @@ -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 { BaseDao getBaseDao(); - T findOne(Long id); + default T findOne(Long id){ + return getBaseDao().findOne(id); + } - List findAll(); + default List 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 entitylist); + @Transactional + default void batchSave(List entitylist){ + getBaseDao().batchSave(entitylist); + } - void batchUpdate(List entitylist); + @Transactional + default void batchUpdate(List entitylist){ + getBaseDao().batchSave(entitylist); + } - void batchDelete(List entitylist); + @Transactional + default void batchDelete(List entitylist){ + getBaseDao().batchDelete(entitylist); + } } diff --git a/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java b/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java index 1f52d4f..534f880 100755 --- a/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java +++ b/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java @@ -8,7 +8,9 @@ import java.util.List; /** * Created by qi_liang on 2018/6/21. + *  采用jdk8 默认方法,所以该实现类废弃 */ +@Deprecated public abstract class BaseServiceImpl implements BaseService{ @Override public abstract BaseDao getBaseDao(); diff --git a/src/main/java/com/lq/code/util/ArrayUtil.java b/src/main/java/com/lq/code/util/ArrayUtil.java new file mode 100644 index 0000000..7f68585 --- /dev/null +++ b/src/main/java/com/lq/code/util/ArrayUtil.java @@ -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 + * @return + */ + public static T [] of(T... values){ + + return values; + } +} diff --git a/src/main/profile/dev/jdbc.properties b/src/main/profile/dev/jdbc.properties index 2087517..cf92f01 100644 --- a/src/main/profile/dev/jdbc.properties +++ b/src/main/profile/dev/jdbc.properties @@ -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 #--------数据库连接池配置 ------- diff --git a/src/main/profile/dev/redis.properties b/src/main/profile/dev/redis.properties index 80de386..9b38d93 100644 --- a/src/main/profile/dev/redis.properties +++ b/src/main/profile/dev/redis.properties @@ -1,4 +1,4 @@ -redis.host=192.168.31.110 +redis.host=localhost redis.port=6379 redis.pass= redis.timeout=-1 diff --git a/src/main/profile/pro/file.properties b/src/main/profile/pro/file.properties index 70c8c53..6c6a3a8 100644 --- a/src/main/profile/pro/file.properties +++ b/src/main/profile/pro/file.properties @@ -1 +1 @@ -file.upload=/Users/qi/java/fileManger/ \ No newline at end of file +file.upload=/home/nfs/fileManger/ \ No newline at end of file diff --git a/src/main/profile/pro/jdbc.properties b/src/main/profile/pro/jdbc.properties index cf92f01..8741005 100644 --- a/src/main/profile/pro/jdbc.properties +++ b/src/main/profile/pro/jdbc.properties @@ -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 #--------数据库连接池配置 ------- diff --git a/src/main/profile/pro/redis.properties b/src/main/profile/pro/redis.properties index 80be888..b61b6af 100644 --- a/src/main/profile/pro/redis.properties +++ b/src/main/profile/pro/redis.properties @@ -1,4 +1,4 @@ -redis.host=127.0.0.1 +redis.host=192.168.31.19 redis.port=6379 redis.pass= redis.timeout=-1 diff --git a/src/main/resources/mybatis/mapping/SysPermissionDao.xml b/src/main/resources/mybatis/mapping/SysPermissionDao.xml index 7923095..900dc2a 100644 --- a/src/main/resources/mybatis/mapping/SysPermissionDao.xml +++ b/src/main/resources/mybatis/mapping/SysPermissionDao.xml @@ -55,7 +55,8 @@ - + + UPDATE sys_permission diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/login.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/login.jsp index 4036cbc..32b0b59 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/login.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/login.jsp @@ -52,7 +52,7 @@

- cms + ssm 管理后台应用

© 星期八

@@ -131,7 +131,7 @@
-
+
diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp index 7858c4f..71bb332 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/main/head.jsp @@ -25,14 +25,14 @@ - ACE后台管理系统 + ssm后台管理系统