|
@@ -1,7 +1,5 @@
|
|
|
package fcb.project.manager.core.controller;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import fcb.project.manager.base.entity.ContextTokenBean;
|
|
|
import fcb.project.manager.base.entity.TmEstate;
|
|
@@ -33,7 +31,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
@RestController
|
|
|
@RequestMapping("fcb/project/project")
|
|
|
@Log4j2
|
|
|
-public class ProjectController {
|
|
|
+public class ProjectController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private TmEstateServiceImpl tmEstateService;
|
|
@@ -51,74 +49,56 @@ public class ProjectController {
|
|
|
@ApiImplicitParam(name = "belongCompany", value = "所属公司", paramType = "query", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "pageNum", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "query", required = true, dataType = "Long")
|
|
|
- })
|
|
|
+ })
|
|
|
public Result<Object> getProjectList(@RequestParam(required = false) String estateName,
|
|
|
@RequestParam(required = false) String belongCompany,
|
|
|
- @RequestParam(name = "pageNum")Long pageNum,
|
|
|
- @RequestParam(name = "pageSize")Long pageSize){
|
|
|
+ @RequestParam(name = "pageNum") Long pageNum,
|
|
|
+ @RequestParam(name = "pageSize") Long pageSize) {
|
|
|
|
|
|
- IPage<TmEstate> resultPage = tmEstateService.getListByNameOrBelong(estateName , belongCompany , pageNum , pageSize);
|
|
|
- return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
+ IPage<TmEstate> resultPage = tmEstateService.getListByNameOrBelong(estateName, belongCompany, pageNum, pageSize);
|
|
|
+ return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/addEstate")
|
|
|
@ApiOperation(value = "创建楼盘项目")
|
|
|
- public Result<Object> addNewEstate(@RequestBody TmEstate tmEstate , HttpServletRequest request){
|
|
|
+ public Result<Object> addNewEstate(@RequestBody TmEstate tmEstate, HttpServletRequest request) {
|
|
|
|
|
|
- if(!StringUtils.isNoneBlank(tmEstate.getEstateName() )){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D101 , "楼盘名称不能为空");
|
|
|
+ if (!StringUtils.isNoneBlank(tmEstate.getEstateName())) {
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101, "楼盘名称不能为空");
|
|
|
}
|
|
|
- String token = request.getHeader("token");
|
|
|
- if(StringUtils.isBlank(token)){
|
|
|
- return Result.failure("token缺失");
|
|
|
+ ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
+ TmEstate dbEstate = tmEstateService.getOneByNameAndBelong(tmEstate.getEstateName(), tokenMap.getDepartmentName());
|
|
|
+ if (null != dbEstate) {
|
|
|
+ log.info("{}公司下面的楼盘{}已经存在", tmEstate.getBelongCompanyName(), tmEstate.getEstateName());
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101, "楼盘已经存在,无需再添加");
|
|
|
}
|
|
|
- JSONObject tokenJson = new JSONObject();
|
|
|
- try {
|
|
|
- tokenJson = (JSONObject) redisTemplate.opsForValue().get(token);
|
|
|
- if(null == tokenJson){
|
|
|
- return Result.failure("登录失效,需要重新登录");
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- log.info("json数据转换出现异常:{}" , e);
|
|
|
- }
|
|
|
- ContextTokenBean tokenMap = JSON.parseObject(tokenJson.toJSONString() , ContextTokenBean.class);
|
|
|
- if(null == tokenMap){
|
|
|
- return Result.failure("解析token失败");
|
|
|
- }else{
|
|
|
- log.info("解析token成功");
|
|
|
- }
|
|
|
- TmEstate dbEstate = tmEstateService.getOneByNameAndBelong(tmEstate.getEstateName() , tokenMap.getDepartmentName());
|
|
|
- if(null != dbEstate){
|
|
|
- log.info("{}公司下面的楼盘{}已经存在" , tmEstate.getBelongCompanyName() , tmEstate.getEstateName());
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D101 , "楼盘已经存在,无需再添加");
|
|
|
- }
|
|
|
- if(null != tokenMap){
|
|
|
+ if (null != tokenMap) {
|
|
|
tmEstate.setBelongCompanyId(tokenMap.getDepartmentId());
|
|
|
tmEstate.setBelongCompanyName(tokenMap.getDepartmentName());
|
|
|
tmEstate.setCreateById(tokenMap.getId());
|
|
|
tmEstate.setCreateByName(tokenMap.getUserName());
|
|
|
}
|
|
|
- if(tmEstateService.insertNew(tmEstate)){
|
|
|
- return Result.success("新增成功");
|
|
|
- }else{
|
|
|
+ if (tmEstateService.insertNew(tmEstate)) {
|
|
|
+ return Result.success("新增成功");
|
|
|
+ } else {
|
|
|
return Result.failure("新增失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping("/deleteEstate")
|
|
|
@ApiOperation(value = "删除楼盘信息")
|
|
|
- public Result<Object> deleteEstate(String estateId){
|
|
|
+ public Result<Object> deleteEstate(String estateId) {
|
|
|
|
|
|
- if(StringUtils.isBlank(estateId)){
|
|
|
+ if (StringUtils.isBlank(estateId)) {
|
|
|
return Result.failure("楼盘ID不能为空");
|
|
|
}
|
|
|
IPage<TmHouse> page = tmHouseService.checkEstateCanDelete(estateId);
|
|
|
- if(null != page && page.getTotal() > 0){
|
|
|
+ if (null != page && page.getTotal() > 0) {
|
|
|
return Result.failure("楼盘下存在VR项目时不可删除");
|
|
|
}
|
|
|
int delete = tmEstateService.deleteEstateById(estateId);
|
|
|
- if(delete != 1){
|
|
|
+ if (delete != 1) {
|
|
|
return Result.failure("删除失败");
|
|
|
}
|
|
|
|
|
@@ -128,26 +108,25 @@ public class ProjectController {
|
|
|
|
|
|
@PostMapping("/updateEstate")
|
|
|
@ApiOperation(value = "修改楼盘项目信息")
|
|
|
- public Result<Object> updateEstate(@RequestBody TmEstate tmEstate){
|
|
|
+ public Result<Object> updateEstate(@RequestBody TmEstate tmEstate) {
|
|
|
|
|
|
- if(null == tmEstate){
|
|
|
+ if (null == tmEstate) {
|
|
|
return Result.failure("入参为空");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(tmEstate.getId())){
|
|
|
+ if (StringUtils.isBlank(tmEstate.getId())) {
|
|
|
return Result.failure("id不能为空");
|
|
|
}
|
|
|
TmEstate dbEstate = tmEstateService.getById(tmEstate.getId());
|
|
|
- if(tmEstate.getIsDelete().compareTo(1) == 0 && dbEstate.getIsDelete().compareTo(0) == 0){
|
|
|
+ if (tmEstate.getIsDelete().compareTo(1) == 0 && dbEstate.getIsDelete().compareTo(0) == 0) {
|
|
|
//删除楼盘操作,需要检查楼盘下面是否还有有效房源
|
|
|
|
|
|
}
|
|
|
- if(tmEstateService.updateEstate(tmEstate)){
|
|
|
+ if (tmEstateService.updateEstate(tmEstate)) {
|
|
|
return Result.success("修改成功");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return Result.failure("修改失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|