| package com.xzx.gc.user.controller;  | 
|   | 
|   | 
| import cn.hutool.core.collection.CollUtil;  | 
| import cn.hutool.core.util.StrUtil;  | 
| import com.github.pagehelper.PageHelper;  | 
| import com.github.pagehelper.PageInfo;  | 
| import com.xzx.gc.common.Result;  | 
| import com.xzx.gc.common.annotations.PassToken;  | 
| import com.xzx.gc.common.constant.CommonEnum;  | 
| import com.xzx.gc.common.constant.Constants;  | 
| import com.xzx.gc.common.dto.log.OperationAppLog;  | 
| import com.xzx.gc.common.request.BaseController;  | 
| import com.xzx.gc.entity.AddressInfo;  | 
| import com.xzx.gc.entity.UserScrapStore;  | 
| import com.xzx.gc.model.IdDTO;  | 
| import com.xzx.gc.model.system.ItemUserListDTO;  | 
| import com.xzx.gc.model.system.ItemUserListResDTO;  | 
| import com.xzx.gc.model.user.UserScrapStoreListParamDTO;  | 
| import com.xzx.gc.model.user.UserScrapSubscribeParamDTO;  | 
| import com.xzx.gc.user.service.AddressService;  | 
| import com.xzx.gc.user.service.UserScrapStoreService;  | 
| import com.xzx.gc.user.service.UserService;  | 
| import io.swagger.annotations.Api;  | 
| import io.swagger.annotations.ApiOperation;  | 
| import lombok.extern.slf4j.Slf4j;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.validation.annotation.Validated;  | 
| import org.springframework.web.bind.annotation.PostMapping;  | 
| import org.springframework.web.bind.annotation.RequestBody;  | 
| import org.springframework.web.bind.annotation.RestController;  | 
|   | 
| import javax.servlet.http.HttpServletRequest;  | 
| import java.util.List;  | 
|   | 
| @RestController  | 
| @Validated  | 
| @Slf4j  | 
| @Api(tags = "废品站管理")  | 
| public class UserScrapStoreController  extends BaseController {  | 
|   | 
|     @Autowired  | 
|     private UserScrapStoreService userScrapStoreService;  | 
|     @Autowired  | 
|     private UserService userService;  | 
|   | 
|     @ApiOperation(value = "查询用户是否已入驻废品站")  | 
|     @PostMapping("/userScrapStore/enter")  | 
|     public Result<UserScrapStore> enter(HttpServletRequest request) {  | 
|         String userId = getUserId(request);  | 
|         String mobilePhone = userService.findById(userId).getMobilePhone();  | 
|         UserScrapStore byMobile1 = userScrapStoreService.findByMobile(mobilePhone);  | 
|         return Result.success(byMobile1);  | 
|     }  | 
|   | 
|   | 
|     @ApiOperation(value = "查询废品站列表")  | 
|     @PostMapping(value = {"/userScrapStore/list","/admin/front/userScrapStore/list"})  | 
|     @PassToken  | 
|     public Result<PageInfo<UserScrapStore>> list(HttpServletRequest request, @RequestBody UserScrapStoreListParamDTO userScrapStoreListParamDTO) {  | 
|         //只查询同一个区的  | 
| //        if(StrUtil.isNotBlank(userScrapStoreListParamDTO.getUserId())) {  | 
| //            AddressInfo byUserId = addressService.findByUserId(userScrapStoreListParamDTO.getUserId());  | 
| //            if (byUserId != null) {  | 
| //                userScrapStoreListParamDTO.setTownShipId(byUserId.getTownshipId());  | 
| //            }  | 
| //        }  | 
|         PageHelper.startPage(userScrapStoreListParamDTO.getPageNo(),userScrapStoreListParamDTO.getPageSize());  | 
|         List<UserScrapStore> list=userScrapStoreService.list(userScrapStoreListParamDTO);  | 
|         PageInfo<UserScrapStore> pageInfo = new PageInfo<>(list);  | 
|         //关联了订单 总会有数据进行特殊处理  | 
|         if(CollUtil.isEmpty(list)){  | 
|             pageInfo.setTotal(0);  | 
|         }  | 
|         return Result.success(pageInfo);  | 
|     }  | 
|   | 
|     @ApiOperation(value = "编辑废品站")  | 
|     @PostMapping(value = {"/admin/front/userScrapStore/update"})  | 
|     public Result update(HttpServletRequest request, @RequestBody UserScrapStore userScrapStore) {  | 
|         userScrapStoreService.update(userScrapStore);  | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))  | 
|                 .methodName(Constants.USER_MODUL_NAME).operateAction("编辑废品站-"+userScrapStore.getId()).build();  | 
|         mqUtil.sendApp(build);  | 
|         return Result.success();  | 
|     }  | 
|   | 
|     @ApiOperation(value = "删除废品站")  | 
|     @PostMapping(value = {"/admin/front/userScrapStore/delete"})  | 
|     public Result delete(HttpServletRequest request, @RequestBody IdDTO idDTO) {  | 
|         userScrapStoreService.deleteById(idDTO.getId());  | 
|         OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))  | 
|                 .methodName(Constants.USER_MODUL_NAME).operateAction("删除废品站-"+idDTO.getId()).build();  | 
|         mqUtil.sendApp(build);  | 
|         return Result.success();  | 
|     }  | 
|   | 
|     @ApiOperation(value = "预约废品站")  | 
|     @PostMapping("/userScrapStore/subscribe")  | 
|     public Result subscribe(HttpServletRequest request, @RequestBody UserScrapSubscribeParamDTO userScrapSubscribeParamDTO) {  | 
|         userScrapStoreService.subscribe(userScrapSubscribeParamDTO);  | 
|         return Result.success();  | 
|     }  | 
|   | 
|     @ApiOperation(value = "查询废品站报价")  | 
|     @PostMapping("/userScrapStore/price")  | 
|     public Result<PageInfo<ItemUserListResDTO>> price(HttpServletRequest request,@RequestBody ItemUserListDTO itemUserListDTO) {  | 
|         PageHelper.startPage(itemUserListDTO.getPageNo(),itemUserListDTO.getPageSize());  | 
|         List<ItemUserListResDTO> list= userScrapStoreService.itemUserList(itemUserListDTO);  | 
|         return Result.success(new PageInfo<>(list));  | 
|     }  | 
| }  |