Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev
1 files added
9 files modified
| | |
| | | import com.moral.api.entity.Group; |
| | | import com.moral.api.service.GroupService; |
| | | import com.moral.api.service.UserGroupService; |
| | | import com.moral.api.utils.OperationLogUtils; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.PageResult; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"组"}) |
| | |
| | | if (!result.isEmpty()) { |
| | | return ResultMessage.fail((int) result.get("code"), result.get("msg").toString()); |
| | | } |
| | | |
| | | //日志 |
| | | String content = "添加了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "deleteGroup", method = RequestMethod.POST) |
| | | public ResultMessage deleteGroup(@RequestBody Map<String, Object> parameters) { |
| | | if (!parameters.containsKey("groupId")) { |
| | | public ResultMessage deleteGroup(@RequestBody Group group, HttpServletRequest request) { |
| | | if (group.getId() == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("id", parameters.get("groupId")); |
| | | Group group = groupService.getOne(queryWrapper); |
| | | queryWrapper.eq("id", group.getId()); |
| | | group = groupService.getOne(queryWrapper); |
| | | if (group == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | } |
| | | groupService.deleteGroup(group); |
| | | |
| | | //日志 |
| | | String content = "删除了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | if (!result.isEmpty()) { |
| | | return ResultMessage.fail((int) result.get("code"), result.get("msg").toString()); |
| | | } |
| | | |
| | | //日志 |
| | | String content = "修改了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.SysConfig; |
| | | import com.moral.api.entity.UserLog; |
| | | import com.moral.api.service.SysConfigService; |
| | | import com.moral.api.service.UserLogService; |
| | | import com.moral.api.service.UserService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | |
| | | import com.moral.pojo.VerificationCode; |
| | | import com.moral.util.KaptchaUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"登陆"}) |
| | |
| | | @Autowired |
| | | private SysConfigService sysConfigService; |
| | | |
| | | @Autowired |
| | | private UserLogService userLogService; |
| | | |
| | | @ApiOperation(value = "登陆", notes = "登陆") |
| | | @RequestMapping(value = "login", method = RequestMethod.POST) |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters) { |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters, HttpServletRequest request) { |
| | | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | |
| | | if (!result.containsKey("data")) { |
| | | return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); |
| | | } |
| | | return ResultMessage.ok(result.get("data")); |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | Map<String, Object> userInfo = (Map<String, Object>) data.get("user"); |
| | | UserLog userLog = new UserLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | userLog.setIp(ip); |
| | | userLog.setOperateId((Integer) userInfo.get("userId")); |
| | | userLog.setOrganizationId((Integer) userInfo.get("organizationId")); |
| | | userLog.setContent(userInfo.get("account") + "登陆了"); |
| | | userLogService.save(userLog); |
| | | return ResultMessage.ok(data); |
| | | } |
| | | |
| | | @ApiOperation(value = "退出", notes = "退出") |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.User; |
| | | import com.moral.api.service.UserService; |
| | | import com.moral.api.utils.OperationLogUtils; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.PageResult; |
| | |
| | | if (!result.isEmpty()) { |
| | | return ResultMessage.fail((int) result.get("code"), result.get("msg").toString()); |
| | | } |
| | | |
| | | //日志 |
| | | String content = "添加了账户:" + user.getAccount(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除账户", notes = "删除账户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "Integer") |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "deleteUser", method = RequestMethod.POST) |
| | | public ResultMessage deleteUser(@RequestBody Map<String, Object> parameters) { |
| | | if (!parameters.containsKey("uid")) { |
| | | public ResultMessage deleteUser(@RequestBody User user, HttpServletRequest request) { |
| | | if (user.getId() == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("id", parameters.get("uid")); |
| | | User user = userService.getOne(queryWrapper); |
| | | queryWrapper.eq("id", user.getId()); |
| | | user = userService.getOne(queryWrapper); |
| | | if (user == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), |
| | | ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | } |
| | | userService.deleteUser(user); |
| | | |
| | | //日志 |
| | | String content = "删除了账户:" + user.getAccount(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | if (!result.isEmpty()) { |
| | | return ResultMessage.fail((int) result.get("code"), result.get("msg").toString()); |
| | | } |
| | | |
| | | //日志 |
| | | String content = "修改了账户:" + user.getAccount(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | //正则校验密码 |
| | | String password = user.getPassword(); |
| | | if (password != null) { |
| | | //密码解密 |
| | | //password = AESUtils.decrypt(password, AESKey); |
| | | if (!RegexUtils.checkPassword(password)) { |
| | | result.put("code", ResponseCodeEnum.PASSWORD_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | |
| | | //密码解密 |
| | | //password = AESUtils.decrypt(password, AESKey); |
| | | if (!RegexUtils.checkPassword(password)) { |
| | | result.put("code", ResponseCodeEnum.PASSWORD_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | |
| | | //正则校验手机号 |
| | | if (user.getMobile() != null && !RegexUtils.checkMobile(user.getMobile())) { |
| | | result.put("code", ResponseCodeEnum.MOBILE_INVALID.getCode()); |
New file |
| | |
| | | package com.moral.api.utils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.moral.api.entity.UserLog; |
| | | import com.moral.api.service.UserLogService; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class OperationLogUtils { |
| | | |
| | | private static UserLogService userLogService; |
| | | |
| | | @Autowired |
| | | public void setUserLogService(UserLogService userLogService) { |
| | | this.userLogService = userLogService; |
| | | } |
| | | |
| | | public static void insertLog(HttpServletRequest request, String content) { |
| | | String token = request.getHeader("token"); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | UserLog userLog = new UserLog(); |
| | | userLog.setIp(WebUtils.getIpAddr(request)); |
| | | userLog.setOperateId((Integer) currentUserInfo.get("userId")); |
| | | userLog.setOrganizationId((Integer) currentUserInfo.get("organizationId")); |
| | | userLog.setContent(content); |
| | | userLogService.save(userLog); |
| | | } |
| | | } |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @RequestMapping(value = "getAllManageRole", method = RequestMethod.GET) |
| | | public ResultMessage getAllManageRole(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | List<ManageRole> re = manageRoleService.getAllWithPagingQuery(parameters); |
| | | Map<String,Object> re = manageRoleService.getAllWithPagingQuery(parameters); |
| | | return ResultMessage.ok(re); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增角色", notes = "新增角色") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "desc", value = "备注", required = true, paramType = "query", dataType = "String") |
| | | @ApiImplicitParam(name = "desc", value = "备注", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "menuIds", value = "菜单集合", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "insertOneManageRole", method = RequestMethod.POST) |
| | | public ResultMessage insertOneManageRole(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | ManageRole manageRole = JSON.parseObject(JSON.toJSONString(parameters), ManageRole.class); |
| | | @ResponseBody |
| | | public ResultMessage insertOneManageRole(@RequestBody Map<String, Object> parameters) { |
| | | List list = new ArrayList(); |
| | | list.add(1); |
| | | list.add(2); |
| | | list.add(3); |
| | | list.add(4); |
| | | if (parameters.get("menuIds") != null){ |
| | | String menuIdsStr = parameters.get("menuIds").toString(); |
| | | menuIdsStr = menuIdsStr.replace(" ",""); |
| | | if (menuIdsStr.length() > 2){ |
| | | menuIdsStr = menuIdsStr.substring(1,menuIdsStr.length()-1); |
| | | String[] menuIdsArray = menuIdsStr.split(","); |
| | | list = Arrays.asList(menuIdsArray); |
| | | } |
| | | parameters.remove("menuIds"); |
| | | } |
| | | ManageRole manageRole = JSON.parseObject(JSON.toJSONString(parameters), ManageRole.class); |
| | | Map<String,Object> resultMap = manageRoleService.insertOne(manageRole,list); |
| | | String msg = resultMap.get("msg").toString(); |
| | | boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); |
| | | if (flag){ |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | | //return null; |
| | | } |
| | | |
| | | @ApiOperation(value = "更新角色", notes = "更新角色") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "desc", value = "备注", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "updateManageRole", method = RequestMethod.POST) |
| | | public ResultMessage updateManageRole(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | public ResultMessage updateManageRole(@RequestBody Map<String, Object> parameters) { |
| | | Map<String,Object> resultMap = manageRoleService.updateManageRole(parameters); |
| | | String msg = resultMap.get("msg").toString(); |
| | | boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); |
| | | if (flag){ |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | |
| | | @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int") |
| | | }) |
| | | @RequestMapping(value = "deleteManageRole", method = RequestMethod.POST) |
| | | public ResultMessage deleteManageRole(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | public ResultMessage deleteManageRole(@RequestBody Map<String, Object> parameters) { |
| | | Map<String,Object> resultMap = manageRoleService.deleteManageRole(parameters); |
| | | String msg = resultMap.get("msg").toString(); |
| | | boolean flag = Boolean.parseBoolean(resultMap.get("flag").toString()); |
| | | if (flag){ |
| | | int code = Integer.parseInt(resultMap.get("code").toString()); |
| | | if (code == 0){ |
| | | return ResultMessage.ok(msg); |
| | | } |
| | | return ResultMessage.fail(msg); |
| | |
| | | @ApiImplicitParam(name = "id", value = "序号", required = true, paramType = "query", dataType = "int") |
| | | }) |
| | | @RequestMapping(value = "updateRoleMenu", method = RequestMethod.POST) |
| | | public ResultMessage updateRoleMenu(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | int id = Integer.parseInt(parameters.get("id").toString()); |
| | | public ResultMessage updateRoleMenu(@RequestBody Map<String, Object> parameters) { |
| | | List list = new ArrayList(); |
| | | //list.add(1); |
| | | //list.add(2); |
| | | list.add(3); |
| | | list.add(4); |
| | | list.add(5); |
| | | list.add(6); |
| | | if (parameters.get("menuIds") != null){ |
| | | String menuIdsStr = parameters.get("menuIds").toString(); |
| | | menuIdsStr = menuIdsStr.replace(" ",""); |
| | | if (menuIdsStr.length() > 2){ |
| | | menuIdsStr = menuIdsStr.substring(1,menuIdsStr.length()-1); |
| | | String[] menuIdsArray = menuIdsStr.split(","); |
| | | list = Arrays.asList(menuIdsArray); |
| | | } |
| | | parameters.remove("menuIds"); |
| | | } |
| | | int id = Integer.parseInt(parameters.get("id").toString()); |
| | | Map<String,Object> re = manageRoleMenuService.updateRoleMenu(list,id); |
| | | return ResultMessage.ok(re); |
| | | } |
| | |
| | | public interface ManageRoleService extends IService<ManageRole> { |
| | | |
| | | @Transactional |
| | | List<ManageRole> getAllWithPagingQuery(Map map); |
| | | Map<String,Object> getAllWithPagingQuery(Map map); |
| | | |
| | | @Transactional |
| | | Map<String,Object> insertOne(ManageRole manageRole,List list); |
| | |
| | | limitMap.put("start", (Integer.parseInt(map.get("current").toString()) - 1) * Integer.parseInt(map.get("size").toString())); |
| | | limitMap.put("number", Integer.parseInt(map.get("size").toString())); |
| | | List<ManageMenu> manageMenus = manageMenuMapper.getDataWithPage(limitMap); |
| | | System.out.println(manageMenus); |
| | | return manageMenus; |
| | | } |
| | | |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.ManageAccountRole; |
| | | import com.moral.api.entity.ManageMenu; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<ManageRole> getAllWithPagingQuery(Map map) { |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<ManageRole> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(Integer.parseInt(map.get("current").toString()), Integer.parseInt(map.get("size").toString())); |
| | | public Map<String,Object> getAllWithPagingQuery(Map map) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | int current = Integer.parseInt(map.get("current").toString()); |
| | | int size = Integer.parseInt(map.get("size").toString()); |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<ManageRole> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(current, size); |
| | | QueryWrapper<ManageRole> wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete",0); |
| | | wrapper.orderByDesc("create_time"); |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page resultpage = manageRoleMapper.selectPage(page,wrapper); |
| | | List<ManageRole> manageRoles = resultpage.getRecords(); |
| | | return manageRoles; |
| | | SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | List<Map<String,Object>> manageRolesList = new ArrayList<>(); |
| | | for (ManageRole manageRole:manageRoles) { |
| | | Map manageRoleMap = JSON.parseObject(JSON.toJSONString(manageRole),Map.class); |
| | | String createTime = SDF.format(manageRole.getCreateTime()); |
| | | String updateTime = SDF.format(manageRole.getUpdateTime()); |
| | | manageRoleMap.put("createTime",createTime); |
| | | manageRoleMap.put("updateTime",updateTime); |
| | | manageRolesList.add(manageRoleMap); |
| | | } |
| | | resultMap.put("manageRoles",manageRolesList); |
| | | int totalNumber = manageRoleMapper.selectCount(wrapper); |
| | | resultMap.put("totalNumber",totalNumber); |
| | | resultMap.put("current",current); |
| | | int totalPageNumber = totalNumber/size; |
| | | if(totalNumber%size != 0){ |
| | | totalPageNumber += 1; |
| | | } |
| | | resultMap.put("totalPageNumber",totalPageNumber); |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | - /role/getAllManageRole |
| | | - /role/getManageRoleByNameFuzzy |
| | | - /role/insertOneManageRole |
| | | - /role/updateManageRole |
| | | - /role/updateRoleMenu |
| | | - /role/deleteManageRole |
| | | - /menu/getAllManageMenu |
| | | - /menu/getManageMenuByNameFuzzy |
| | | - /api/** |