|
@@ -13,20 +13,15 @@ import com.fdkanfang.common.exception.CommonBaseException;
|
|
|
import com.fdkanfang.common.model.PageDto;
|
|
|
import com.fdkanfang.common.util.*;
|
|
|
import com.fdkanfang.domain.backend.*;
|
|
|
-import com.fdkanfang.domain.dto.HouseDto;
|
|
|
-import com.fdkanfang.domain.dto.ImageDto;
|
|
|
-import com.fdkanfang.domain.dto.PanoDto;
|
|
|
-import com.fdkanfang.domain.dto.SceneJsonDto;
|
|
|
+import com.fdkanfang.domain.dto.*;
|
|
|
import com.fdkanfang.domain.response.HouseResponse;
|
|
|
import com.fdkanfang.domain.response.UserResponse;
|
|
|
import com.fdkanfang.service.backend.*;
|
|
|
+import com.fdkanfang.web.backend.utils.UserUtils;
|
|
|
import com.fdkanfang.web.mq.config.RabbitConfig;
|
|
|
import com.fdkanfang.web.shiro.JWTUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
@@ -85,6 +80,9 @@ public class HouseController extends BaseController {
|
|
|
@Autowired
|
|
|
private RoleService2 roleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserUtils userUtils;
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -93,15 +91,17 @@ public class HouseController extends BaseController {
|
|
|
public R list(@RequestBody PageDto param){
|
|
|
|
|
|
String token = getToken();
|
|
|
- List userRole = JWTUtil.getUserRole(token);
|
|
|
- Long userId = JWTUtil.getUserId(token);
|
|
|
+ // 获取用户角色
|
|
|
+ List<String> userRoles = userUtils.getRolesByToken(token);
|
|
|
+ UserEntity user = userUtils.getUserByToken(token);
|
|
|
+ Long userId = user.getId();
|
|
|
|
|
|
- PageInfo<HouseResponse> page = null;
|
|
|
- if (userRole.contains("admin")) {
|
|
|
+ PageInfo<HouseResponse> page = null;
|
|
|
+ if (userRoles.contains("admin")) {
|
|
|
page = new PageInfo<>(houseService2.findAllBySearchKey(param, null, null));
|
|
|
- } else if (userRole.contains("edit")){
|
|
|
+ } else if (userRoles.contains("edit")){
|
|
|
|
|
|
- if (userRole.size() == 2) {
|
|
|
+ if (userRoles.size() == 2) {
|
|
|
log.info("有edit、upload权限");
|
|
|
// 有edit、upload
|
|
|
// page = new PageInfo<>(houseService2.findAllBySearchKey(param, userId, userId));
|
|
@@ -157,7 +157,8 @@ public class HouseController extends BaseController {
|
|
|
HouseEntity house = null;
|
|
|
if (param.getId() == null) {
|
|
|
house = new HouseEntity();
|
|
|
- house.setUserId(JWTUtil.getUserId(getToken()));
|
|
|
+ UserEntity user = userUtils.getUserByToken(getToken());
|
|
|
+ house.setUserId(user.getId());
|
|
|
param.setId(null);
|
|
|
BeanUtils.copyProperties(param, house);
|
|
|
Integer byMaxNum = houseService2.findByMaxNum();
|
|
@@ -290,27 +291,21 @@ public class HouseController extends BaseController {
|
|
|
|
|
|
@ApiOperation("预审")
|
|
|
@ResponseBody
|
|
|
- @GetMapping(value = "/auditHouse")
|
|
|
+ @PostMapping(value = "/auditHouse")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "houseId", value = "房源Id", dataType = "Long"),
|
|
|
- @ApiImplicitParam(name = "result", value = "审核结果: 1 通过 0 不通过", dataType = "Integer"),
|
|
|
- @ApiImplicitParam(name = "desc", value = "审核描述(不通过时使用)", dataType = "String")})
|
|
|
- public Result auditHouse(@RequestParam(name = "houseId") Long houseId,
|
|
|
- @RequestParam(name = "result") Integer result,
|
|
|
- @RequestParam(name = "desc") String desc) {
|
|
|
- if(StringUtils.isBlank(desc) || null == result || null == houseId){
|
|
|
+ public Result auditHouse(@RequestBody @ApiParam(name = "用户登录注册实体", value = "传入json格式", required = true) HouseAuditDto houseAuditDto) {
|
|
|
+ if(StringUtils.isBlank(houseAuditDto.getDesc()) || null == houseAuditDto.getHouseId() || null == houseAuditDto.getResult()){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D3001);
|
|
|
}
|
|
|
- HouseEntity houseEntity = houseService2.findById(houseId);
|
|
|
+ HouseEntity houseEntity = houseService2.findById(houseAuditDto.getHouseId());
|
|
|
if(null == houseEntity){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "房源不存在");
|
|
|
}
|
|
|
- if(result.compareTo(1) != 0 && result.compareTo(0) != 0){
|
|
|
+ if(houseAuditDto.getResult().compareTo(1) != 0 && houseAuditDto.getResult().compareTo(0) != 0){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "审批结果格式不正确");
|
|
|
}
|
|
|
- houseEntity.setAuditResult(result);
|
|
|
- houseEntity.setAuditDesc(desc);
|
|
|
+ houseEntity.setAuditResult(houseAuditDto.getResult());
|
|
|
+ houseEntity.setAuditDesc(houseAuditDto.getDesc());
|
|
|
houseEntity.setUpdateTime(new Date());
|
|
|
int update = houseService2.update(houseEntity);
|
|
|
if(update != 1){
|
|
@@ -321,21 +316,17 @@ public class HouseController extends BaseController {
|
|
|
|
|
|
@ApiOperation("标记不能编辑")
|
|
|
@ResponseBody
|
|
|
- @GetMapping(value = "/markFail")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "houseId", value = "房源Id", dataType = "Long"),
|
|
|
- @ApiImplicitParam(name = "desc", value = "标记原因", dataType = "String")})
|
|
|
- public Result markCannotEditHouse(@RequestParam(name = "houseId") Long houseId,
|
|
|
- @RequestParam(name = "desc") String desc) {
|
|
|
- if(StringUtils.isBlank(desc) || null == houseId){
|
|
|
+ @PostMapping(value = "/markFail")
|
|
|
+ public Result markCannotEditHouse(@RequestBody @ApiParam(name = "用户登录注册实体", value = "传入json格式", required = true) HouseAuditDto houseAuditDto) {
|
|
|
+ if(StringUtils.isBlank(houseAuditDto.getDesc()) || null == houseAuditDto.getHouseId()){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D3001);
|
|
|
}
|
|
|
- HouseEntity houseEntity = houseService2.findById(houseId);
|
|
|
+ HouseEntity houseEntity = houseService2.findById(houseAuditDto.getHouseId());
|
|
|
if(null == houseEntity){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D101 , "房源不存在");
|
|
|
}
|
|
|
houseEntity.setCanNotEdit(0);
|
|
|
- houseEntity.setCanNotEditDesc(desc);
|
|
|
+ houseEntity.setCanNotEditDesc(houseAuditDto.getDesc());
|
|
|
houseEntity.setUpdateTime(new Date());
|
|
|
int update = houseService2.update(houseEntity);
|
|
|
if(update != 1){
|
|
@@ -373,14 +364,15 @@ public class HouseController extends BaseController {
|
|
|
@GetMapping("removes/{ids}")
|
|
|
public R removes(@PathVariable String ids){
|
|
|
|
|
|
- List userRole = JWTUtil.getUserRole(getToken());
|
|
|
- Long loginUserId = JWTUtil.getUserId(getToken());
|
|
|
+ List<String> userRoles = userUtils.getRolesByToken(getToken());
|
|
|
+ UserEntity user = userUtils.getUserByToken(getToken());
|
|
|
+ Long loginUserId = user.getId();
|
|
|
|
|
|
|
|
|
String roleKey = null;
|
|
|
// 只有一个权限时
|
|
|
- if (userRole.size() == 1) {
|
|
|
- roleKey = (String)userRole.get(0);
|
|
|
+ if (userRoles.size() == 1) {
|
|
|
+ roleKey = (String)userRoles.get(0);
|
|
|
}
|
|
|
|
|
|
String[] split = ids.split(",");
|
|
@@ -405,7 +397,7 @@ public class HouseController extends BaseController {
|
|
|
return new R(MsgCode.e_COMMON_3002,"没有权限删除房源");
|
|
|
}
|
|
|
|
|
|
- if (!loginUserId.equals(houseEntity.getUserId()) && !userRole.contains("admin")) {
|
|
|
+ if (!loginUserId.equals(houseEntity.getUserId()) && !userRoles.contains("admin")) {
|
|
|
log.error("userId: {}, loginUserId: {}", houseEntity.getUserId(), loginUserId);
|
|
|
log.error("用户不相等时, edit,upload不能删除他人房源");
|
|
|
return new R(MsgCode.e_COMMON_3002,"没有权限删除房源");
|