| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.panzhihua.common.constants.SecurityConstants; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.interfaces.OperLog; |
| | | import com.panzhihua.common.model.dtos.PageBaseDTO; |
| | | import com.panzhihua.common.model.vos.LoginReturnVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.sangeshenbian.SystemUserVo; |
| | | import com.panzhihua.common.service.auth.TokenService; |
| | | import com.panzhihua.sangeshenbian.model.SystemMenu; |
| | | import com.panzhihua.sangeshenbian.model.SystemRoleMenu; |
| | | import com.panzhihua.sangeshenbian.model.SystemUser; |
| | | import com.panzhihua.sangeshenbian.model.entity.SystemMenu; |
| | | import com.panzhihua.sangeshenbian.model.entity.SystemRoleMenu; |
| | | import com.panzhihua.sangeshenbian.model.entity.SystemUser; |
| | | import com.panzhihua.sangeshenbian.service.ISystemMenuService; |
| | | import com.panzhihua.sangeshenbian.service.ISystemRoleMenuService; |
| | | import com.panzhihua.sangeshenbian.service.ISystemUserService; |
| | | import com.panzhihua.sangeshenbian.warpper.LoginVo; |
| | | import com.panzhihua.sangeshenbian.warpper.SystemUserList; |
| | | import com.panzhihua.sangeshenbian.warpper.SystemUserListVo; |
| | | import com.panzhihua.sangeshenbian.warpper.TokenVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @PostMapping("/login") |
| | | @ApiOperation(value = "登录", tags = {"三个身边后台-登录"}) |
| | | @OperLog(operModul = "三个身边后台",operType = 0,businessType = "登录") |
| | | public R<LoginReturnVO> login(@RequestBody LoginVo vo){ |
| | | public R<TokenVo> login(@RequestBody LoginVo vo){ |
| | | String key = "login:" + vo.getPhone(); |
| | | Integer size = (Integer) redisTemplate.opsForValue().get(key); |
| | | if(null != size && max_err.equals(size)){ |
| | |
| | | //创建token |
| | | R<LoginReturnVO> reult = tokenService.loginThreeAround(systemUser.getId()); |
| | | redisTemplate.delete(key); |
| | | return reult; |
| | | LoginReturnVO loginReturnVO = reult.getData(); |
| | | TokenVo tokenVo = new TokenVo(); |
| | | BeanUtils.copyProperties(loginReturnVO, tokenVo); |
| | | List<SystemRoleMenu> list = systemRoleMenuService.list(new LambdaQueryWrapper<SystemRoleMenu>().eq(SystemRoleMenu::getSystemRoleId, systemUser.getSystemRoleId())); |
| | | List<Integer> collect = list.stream().map(SystemRoleMenu::getSystemMenuId).collect(Collectors.toList()); |
| | | Set<String> collect1 = new HashSet<>(); |
| | | if(collect.size() > 0){ |
| | | List<SystemMenu> systemMenus = systemMenuService.listByIds(collect); |
| | | collect1 = systemMenus.stream().map(SystemMenu::getUrl).collect(Collectors.toSet()); |
| | | } |
| | | tokenVo.setMenu(collect1); |
| | | tokenVo.setName(systemUser.getName()); |
| | | return R.ok(tokenVo); |
| | | } |
| | | |
| | | |
| | |
| | | if(4 == user.getAccountLevel() && 4 < systemUser.getAccountLevel()){ |
| | | return R.fail("不能添加街道、区县和市级账号"); |
| | | } |
| | | int count = systemUserService.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, systemUser.getPhone()).ne(SystemUser::getStatus, 3)); |
| | | long count = systemUserService.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, systemUser.getPhone()).ne(SystemUser::getStatus, 3)); |
| | | if(0 < count){ |
| | | return R.fail("手机号重复。"); |
| | | } |
| | |
| | | @ApiOperation(value = "编辑人员", tags = {"三个身边后台-人员管理"}) |
| | | @OperLog(operModul = "三个身边后台",operType = 2,businessType = "编辑人员") |
| | | public R edit(@RequestBody SystemUser systemUser){ |
| | | int count = systemUserService.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, systemUser.getPhone()) |
| | | long count = systemUserService.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, systemUser.getPhone()) |
| | | .ne(SystemUser::getStatus, 3).ne(SystemUser::getId, systemUser.getId())); |
| | | if(0 < count){ |
| | | return R.fail("手机号重复。"); |
| | |
| | | |
| | | @PutMapping("/freeze/{id}") |
| | | @ApiOperation(value = "冻结账号", tags = {"三个身边后台-人员管理"}) |
| | | @OperLog(operModul = "三个身边后台",operType = 0,businessType = "冻结账号") |
| | | @OperLog(operModul = "三个身边后台",operType = 2,businessType = "冻结账号") |
| | | public R freeze(@PathVariable("id") Integer id){ |
| | | SystemUser systemUser = systemUserService.getById(id); |
| | | if(2 == systemUser.getStatus()){ |
| | |
| | | |
| | | @PutMapping("/unfreeze/{id}") |
| | | @ApiOperation(value = "解冻账号", tags = {"三个身边后台-人员管理"}) |
| | | @OperLog(operModul = "三个身边后台",operType = 0,businessType = "解冻账号") |
| | | @OperLog(operModul = "三个身边后台",operType = 2,businessType = "解冻账号") |
| | | public R unfreeze(@PathVariable("id") Integer id){ |
| | | SystemUser systemUser = systemUserService.getById(id); |
| | | if(1 == systemUser.getStatus()){ |
| | |
| | | BeanUtils.copyProperties(systemUser, systemUserVo); |
| | | return R.ok(systemUserVo); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getAdministrativeDivision/{id}/{tier}") |
| | | @ApiOperation(value = "获取行政区划层级联动数据", tags = {"三个身边后台-人员管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "上级id", required = false, dataType = "string"), |
| | | @ApiImplicitParam(name = "tier", value = "数据层级(2=区县,3=街道,4=社区)", required = true, dataType = "int"), |
| | | }) |
| | | @OperLog(operModul = "三个身边后台",operType = 0,businessType = "获取行政区划层级联动数据") |
| | | public R<List<Map<String, Object>>> getAdministrativeDivision(@PathVariable("id") String id, @PathVariable("tier") Integer tier){ |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | //区县 |
| | | if(2 == tier){ |
| | | list = systemUserService.getRegion("510400"); |
| | | } |
| | | //街道 |
| | | if(3 == tier){ |
| | | list = systemUserService.getStreet(id); |
| | | } |
| | | //社区 |
| | | if(4 == tier){ |
| | | list = systemUserService.getCommunity(id); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | } |