合并回滚了的代码

This commit is contained in:
meng 2018-12-11 23:11:41 +08:00
parent 6d8d45634c
commit 30da1e50de
7 changed files with 129 additions and 32 deletions

View File

@ -69,5 +69,7 @@ public interface BaseService<T, E extends Serializable> {
public ReType show(T t, int page, int limit);
public ReType getList(T t, int page, int limit);
public String showAll(T t);
}

View File

@ -9,6 +9,7 @@ import com.len.base.CurrentUser;
import com.len.exception.MyException;
import com.len.util.ReType;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.RowBounds;
import org.apache.shiro.SecurityUtils;
import java.io.Serializable;
@ -66,6 +67,7 @@ public abstract class BaseServiceImpl<T, E extends Serializable> implements Base
}
@Override
public int deleteByPrimaryKey(E id) {
return getMappser().deleteByPrimaryKey(id);
}
@ -236,4 +238,64 @@ public abstract class BaseServiceImpl<T, E extends Serializable> implements Base
return JSON.toJSONString(tList);
}
@Override
public ReType getList(T t, int page, int limit) {
List<T> tList = null;
Page<T> tPage = PageHelper.startPage(page, limit);
try {
tList = getMappser().selectListByPage(t);
} catch (MyException e) {
log.error("class:BaseServiceImpl ->method:getList->message:" + e.getMessage());
e.printStackTrace();
}
return new ReType(tPage.getTotal(),tPage.getPageNum(), tList);
}
@Override
public int deleteByExample(Object o) {
return getMappser().deleteByExample(o);
}
@Override
public List<T> selectByExample(Object o) {
return getMappser().selectByExample(o);
}
@Override
public int selectCountByExample(Object o) {
return getMappser().selectCountByExample(o);
}
@Override
public T selectOneByExample(Object o) {
return getMappser().selectOneByExample(o);
}
@Override
public int updateByExample(T t, Object o) {
return getMappser().updateByExample(t,o);
}
@Override
public int updateByExampleSelective(T t, Object o) {
return getMappser().updateByExampleSelective(t,o);
}
@Override
public List<T> selectByExampleAndRowBounds(Object o, RowBounds rowBounds) {
return getMappser().selectByExampleAndRowBounds(o,rowBounds);
}
@Override
public List<T> selectByRowBounds(T t, RowBounds rowBounds) {
return getMappser().selectByRowBounds(t,rowBounds);
}
}

View File

@ -2,6 +2,8 @@ package com.len.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.len.base.BaseController;
import com.len.core.annotation.Log;
import com.len.core.annotation.Log.LOG_TYPE;
@ -13,27 +15,18 @@ import com.len.service.RoleUserService;
import com.len.service.SysUserService;
import com.len.util.*;
import io.swagger.annotations.ApiOperation;
import java.io.*;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author zhuxiaomeng
* @date 2017/12/6.
@ -79,12 +72,12 @@ public class UserController extends BaseController {
@GetMapping(value = "listByRoleId")
@ResponseBody
@RequiresPermissions("user:show")
public String showUser(Model model, String roleId,int page, int limit) {
public String showUser(Model model, String roleId, int page, int limit) {
JSONObject returnValue = new JSONObject();
List<SysUser> users = userService.getUserByRoleId(roleId,page,limit);
int counts = userService.countUserByRoleId(roleId,page,limit);
returnValue.put("users",users);
returnValue.put("totals",counts);
Page<Object> startPage = PageHelper.startPage(page, limit);
List<SysUser> users = userService.getUserByRoleId(roleId);
returnValue.put("users", users);
returnValue.put("totals", startPage.getTotal());
return JSON.toJSONString(returnValue);
}
@ -256,7 +249,7 @@ public class UserController extends BaseController {
@ResponseBody
public JsonUtil imgUpload(HttpServletRequest req, @RequestParam("file") MultipartFile file,
ModelMap model) {
String fileName=uploadUtil.upload(file);
String fileName = uploadUtil.upload(file);
JsonUtil j = new JsonUtil();
j.setMsg(fileName);
return j;

View File

@ -27,6 +27,5 @@ public interface SysUserMapper extends com.len.base.BaseMapper<SysUser,String> {
*/
int rePass(SysUser user);
List<SysUser> getUserByRoleId(Map map);
int countUserByRoleId(Map map);
List<SysUser> getUserByRoleId(@Param("roleId")String roleId);
}

View File

@ -63,7 +63,7 @@ public interface SysUserService extends BaseService<SysUser,String> {
int rePass(SysUser user);
List<SysUser> getUserByRoleId(String roleId,int page,int limit);
List<SysUser> getUserByRoleId(String roleId);
int countUserByRoleId(String roleId,int page,int limit);
public void setMenuAndRoles(String username);
}

View File

@ -197,8 +197,53 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, String> impleme
return checkboxList;
}
@Override
public int rePass(SysUser user) {
return sysUserMapper.rePass(user);
}
@Override
public int rePass(SysUser user) {
return sysUserMapper.rePass(user);
}
@Override
public List<SysUser> getUserByRoleId(String roleId) {
return sysUserMapper.getUserByRoleId(roleId);
}
@Override
public void setMenuAndRoles(String username) {
SysUser s = new SysUser();
s.setUsername(username);
s = this.selectOne(s);
CurrentUser currentUser = new CurrentUser(s.getId(), s.getUsername(), s.getAge(), s.getEmail(), s.getPhoto(), s.getRealName());
Subject subject = ShiroUtil.getSubject();
/*角色权限封装进去*/
//根据用户获取菜单
Session session = subject.getSession();
List<SysMenu> menuList = menuService.getUserMenu(s.getId());
JSONArray json = menuService.getMenuJsonByUser(menuList);
session.setAttribute("menu", json);
List<CurrentMenu> currentMenuList = new ArrayList<>();
List<SysRole> roleList = new ArrayList<>();
for (SysMenu m : menuList) {
CurrentMenu currentMenu = new CurrentMenu();
BeanUtil.copyNotNullBean(m, currentMenu);
currentMenuList.add(currentMenu);
roleList.addAll(m.getRoleList());
}
roleList = new ArrayList<>(new HashSet<>(roleList));
List<CurrentRole> currentRoleList = new ArrayList<>();
for (SysRole r : roleList) {
CurrentRole role = new CurrentRole();
BeanUtil.copyNotNullBean(r, role);
currentRoleList.add(role);
}
currentUser.setCurrentRoleList(currentRoleList);
currentUser.setCurrentMenuList(currentMenuList);
session.setAttribute("curentUser", currentUser);
}
}

View File

@ -141,13 +141,9 @@
</update>
<select id="getUserByRoleId" parameterType="java.util.Map" resultMap="BaseResultMap">
<select id="getUserByRoleId" resultMap="BaseResultMap">
select sysuser.id,sysuser.real_name,sysuser.username from sys_user sysuser inner join sys_role_user roleuser on sysuser.id = roleuser.user_id and roleuser.role_id = #{roleId,jdbcType=VARCHAR}
limit #{page},#{limit}
</select>
<select id="countUserByRoleId" parameterType="java.util.Map" resultType="java.lang.Integer">
select count(1) from sys_user sysuser inner join sys_role_user roleuser on sysuser.id = roleuser.user_id and roleuser.role_id = #{roleId,jdbcType=VARCHAR}
</select>
</mapper>