|
|
@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
|
+import com.zhiqiyun.open.core.models.bz.BaseDataInfo;
|
|
|
import com.zhiqiyun.open.core.models.bz.HomeStayInfo;
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
import com.zhiqiyun.open.core.service.HomeStayInfoService;
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
|
-import com.zhiqiyun.open.mvc.params.QueryHomeStayInfoParams;
|
|
|
-import com.zhiqiyun.open.mvc.params.SaveHomeStayInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.QueryHomeStayInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.SaveHomeStayInfoParams;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -31,7 +36,10 @@ public class HomeStayInfoController {
|
|
|
@Autowired
|
|
|
private SequenceService sequenceService;
|
|
|
|
|
|
- @Permission(value = "bz.base.home.stay.find", tags = "查询场馆")
|
|
|
+ @Autowired
|
|
|
+ private OauthService oauthService;
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.home.stay.find", tags = "查询民宿")
|
|
|
@PostMapping("/findPage")
|
|
|
public Result findPage(@RequestBody QueryHomeStayInfoParams params) {
|
|
|
|
|
|
@@ -60,33 +68,47 @@ public class HomeStayInfoController {
|
|
|
return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
}
|
|
|
|
|
|
- @Permission(value = "bz.base.home.stay.add", tags = "保存场馆")
|
|
|
+ @Permission(value = "bz.base.home.stay.add", tags = "保存民宿")
|
|
|
@PostMapping("/save")
|
|
|
public Result save(@Valid @RequestBody SaveHomeStayInfoParams params) {
|
|
|
|
|
|
- HomeStayInfo homeStayInfo = new HomeStayInfo();
|
|
|
- BeanUtils.copyProperties(params, homeStayInfo);
|
|
|
- homeStayInfo.setId(this.sequenceService.nextId());
|
|
|
- this.homeStayInfoService.save(homeStayInfo);
|
|
|
+ this.homeStayInfoService.save(this.buildEntity(this.sequenceService.nextId(), params));
|
|
|
|
|
|
return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
}
|
|
|
|
|
|
- @Permission(value = "bz.base.home.stay.edit", tags = "编辑场馆")
|
|
|
+ @Permission(value = "bz.base.home.stay.edit", tags = "编辑民宿")
|
|
|
@PostMapping("/updateById")
|
|
|
public Result updateById(Long id, @Valid @RequestBody SaveHomeStayInfoParams params) {
|
|
|
|
|
|
- HomeStayInfo homeStayInfo = new HomeStayInfo();
|
|
|
- BeanUtils.copyProperties(params, homeStayInfo);
|
|
|
- homeStayInfo.setId(id);
|
|
|
-
|
|
|
- this.homeStayInfoService.updateById(homeStayInfo);
|
|
|
+ this.homeStayInfoService.updateById(this.buildEntity(id, params));
|
|
|
|
|
|
return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Permission(value = "bz.base.home.stay.delete", tags = "删除场馆")
|
|
|
+ private HomeStayInfo buildEntity(Long id, @Valid SaveHomeStayInfoParams params) {
|
|
|
+
|
|
|
+ HomeStayInfo entity = new HomeStayInfo();
|
|
|
+ BaseDataInfo baseDataInfo = new BaseDataInfo();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(params, entity);
|
|
|
+ BeanUtils.copyProperties(params.getBaseDataInfo(), baseDataInfo);
|
|
|
+
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ baseDataInfo.setCreatedTime(DateUtil.current());
|
|
|
+ baseDataInfo.setUpdatedTime(DateUtil.current());
|
|
|
+ baseDataInfo.setCreatedBy(oauthInfo.getId());
|
|
|
+ baseDataInfo.setUpdatedBy(oauthInfo.getId());
|
|
|
+
|
|
|
+ entity.setBaseDataInfo(baseDataInfo);
|
|
|
+ entity.setId(id);
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.home.stay.delete", tags = "删除民宿")
|
|
|
@PostMapping("/deleteByIds")
|
|
|
public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
this.homeStayInfoService.removeByIds(ids);
|