|
@@ -1,9 +1,22 @@
|
|
|
package kankan.daikan.core.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import fdage.back.sdk.base.entity.Result;
|
|
|
+import fdage.back.sdk.base.enums.ResultCodeEnum;
|
|
|
+import fdage.back.sdk.base.exception.CommonBaseException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import kankan.daikan.base.entity.TmGoods;
|
|
|
+import kankan.daikan.base.entity.TmHouse;
|
|
|
+import kankan.daikan.base.entity.TmShop;
|
|
|
+import kankan.daikan.base.service.impl.TmShopServiceImpl;
|
|
|
+import kankan.daikan.base.utils.DataUtils;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@Api(tags = "看店店铺操作相关接口")
|
|
|
@RestController
|
|
@@ -11,4 +24,96 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@Log4j2
|
|
|
public class ShopController extends BaseController{
|
|
|
|
|
|
-}
|
|
|
+ @Autowired
|
|
|
+ private TmShopServiceImpl shopService;
|
|
|
+
|
|
|
+ @ApiOperation("新增店铺")
|
|
|
+ @PostMapping(value = "/addNew")
|
|
|
+ public Result<Object> addNewProject(@RequestBody TmShop tmShop){
|
|
|
+
|
|
|
+ if(!StringUtils.isNoneBlank(tmShop.getTitle() , tmShop.getSceneNum())){
|
|
|
+ return Result.failure("标题或者场景码不能为空");
|
|
|
+ }
|
|
|
+ if(null == tmShop.getTemplateType()){
|
|
|
+ return Result.failure("模板类型不能为空");
|
|
|
+ }
|
|
|
+ int add = shopService.addNew(tmShop);
|
|
|
+ if(add != 1){
|
|
|
+ return Result.failure("新增失败");
|
|
|
+ }
|
|
|
+ return Result.success("新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改店铺")
|
|
|
+ @PostMapping(value = "/update")
|
|
|
+ public Result<Object> updateHouse(@RequestBody TmShop tmShop){
|
|
|
+
|
|
|
+ if(null == tmShop || StringUtils.isBlank(tmShop.getId())){
|
|
|
+ return Result.failure("缺少店铺id等参数");
|
|
|
+ }
|
|
|
+ TmShop dbShop = shopService.getWithId(tmShop.getId());
|
|
|
+ if(null == dbShop){
|
|
|
+ return Result.failure("店铺不存在");
|
|
|
+ }
|
|
|
+ if(!StringUtils.equals(dbShop.getTitle() , tmShop.getTitle())){
|
|
|
+ //TODO:修改了房源标题,需要更改项目标题
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!StringUtils.equals(dbShop.getSceneNum() , tmShop.getSceneNum())){
|
|
|
+ //TODO:修改了场景码,需要更改项目场景码
|
|
|
+
|
|
|
+ }
|
|
|
+ int update = shopService.updateHouse(dbShop);
|
|
|
+ if(update != 1){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新失败");
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/getDetail")
|
|
|
+ @ApiOperation(value = "获取店铺详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "shopId", value = "店铺ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result<Object> getDetail(@RequestParam("shopId") String shopId) {
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(shopId)) {
|
|
|
+ return Result.failure("店铺ID不能为空");
|
|
|
+ }
|
|
|
+ TmShop shop = shopService.getWithId(shopId);
|
|
|
+ if(null == shop){
|
|
|
+ return Result.failure("店铺不存在");
|
|
|
+ }
|
|
|
+ return Result.success(shop);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("拉取店铺列表")
|
|
|
+ @GetMapping(value = "/queryList")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "shopName", value = "店铺ID", paramType = "query", required = false, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "type", value = "类型:1->服装;2->家具;3->数码;4->美妆;5->餐饮;6->其他", paramType = "query", required = false, 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> queryList(@RequestParam(name = "shopName" , required = false) String shopName ,
|
|
|
+ @RequestParam(name = "type" , required = false) Integer type ,
|
|
|
+ @RequestParam(name = "pageNum") Long pageNum ,
|
|
|
+ @RequestParam(name = "pageSize") Long pageSize) {
|
|
|
+
|
|
|
+ if(null == pageNum || null == pageSize){
|
|
|
+ return Result.failure("缺失分页参数");
|
|
|
+ }
|
|
|
+
|
|
|
+ IPage<TmShop> resultPage = shopService.getPage(shopName , type , pageNum , pageSize);
|
|
|
+
|
|
|
+ if(null == resultPage){
|
|
|
+ return Result.failure("获取分页数据失败");
|
|
|
+ }
|
|
|
+ return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
+ resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|