New file |
| | |
| | | package com.oying.modules.pc.store.rest; |
| | | |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import com.oying.annotation.Log; |
| | | import com.oying.utils.R; |
| | | import com.oying.modules.pc.store.domain.StoreQualification; |
| | | import com.oying.modules.pc.store.domain.dto.StoreQualificationCreateRequest; |
| | | import com.oying.modules.pc.store.domain.dto.StoreQualificationQueryCriteria; |
| | | import com.oying.modules.pc.store.domain.dto.StoreQualificationUpdateRequest; |
| | | import com.oying.modules.pc.store.service.StoreQualificationService; |
| | | import com.oying.modules.pc.store.view.StoreQualificationMerchantView; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author lzp |
| | | * @date 2025-04-23 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "店铺资质(商户端)") |
| | | @RequestMapping("/api/pc/merchant/store/{storeId}/qualification") |
| | | public class StoreQualificationMerchantController { |
| | | |
| | | private final StoreQualificationService storeQualificationService; |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("查询店铺资质") |
| | | //@PreAuthorize("@el.check('merchant:storeQualification:list') " + |
| | | // "and @storeMerchantOwnershipService.check(#storeId)") |
| | | public ResponseEntity<?> getList(@PathVariable Long storeId) { |
| | | StoreQualificationQueryCriteria criteria = new StoreQualificationQueryCriteria(); |
| | | criteria.setStoreId(storeId); |
| | | List<StoreQualification> storeQualificationList = storeQualificationService.queryAll(criteria); |
| | | List<StoreQualificationMerchantView> viewList = Optional.ofNullable(storeQualificationList).orElse(ListUtil.empty()).stream().map(i -> { |
| | | StoreQualificationMerchantView view = new StoreQualificationMerchantView(); |
| | | view.setId(i.getQualificationId()); |
| | | view.setType(i.getQualificationType()); |
| | | view.setName(i.getQualificationName()); |
| | | view.setImageUrl(""); |
| | | return view; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | return ResponseEntity.ok(R.success(viewList)); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增店铺资质") |
| | | @ApiOperation("新增店铺资质") |
| | | //@PreAuthorize("@el.check('merchant:storeQualification:add') " + |
| | | // "and @storeMerchantOwnershipService.check(#storeId)") |
| | | public ResponseEntity<?> create(@PathVariable Long storeId, |
| | | @Validated @RequestBody StoreQualificationCreateRequest request) { |
| | | |
| | | StoreQualification resources = new StoreQualification(); |
| | | resources.setStoreId(storeId); |
| | | resources.setQualificationType(request.getType()); |
| | | resources.setQualificationImageId(request.getImageUploadFileId()); |
| | | storeQualificationService.create(resources); |
| | | return ResponseEntity.status(HttpStatus.CREATED).build(); |
| | | } |
| | | |
| | | @PutMapping("/{qualificationId}") |
| | | @Log("修改店铺资质") |
| | | @ApiOperation("修改店铺资质") |
| | | //@PreAuthorize("@el.check('merchant:storeQualification:edit') " + |
| | | // "and @storeMerchantOwnershipService.check(#storeId)") |
| | | public ResponseEntity<?> update(@PathVariable Long storeId, |
| | | @PathVariable Long qualificationId, |
| | | @Validated @RequestBody StoreQualificationUpdateRequest request) { |
| | | |
| | | StoreQualification resources = new StoreQualification(); |
| | | resources.setQualificationId(qualificationId); |
| | | resources.setStoreId(storeId); |
| | | resources.setQualificationType(request.getType()); |
| | | resources.setQualificationImageId(request.getImageUploadFileId()); |
| | | storeQualificationService.update(resources); |
| | | return ResponseEntity.noContent().build(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除店铺资质") |
| | | @ApiOperation("删除店铺资质") |
| | | //@PreAuthorize("@el.check('merchant:storeQualification:batchDel') " + |
| | | // "and @storeMerchantOwnershipService.check(#storeId)") |
| | | public ResponseEntity<?> batchDel(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) { |
| | | storeQualificationService.deleteAll(ids); |
| | | return ResponseEntity.noContent().build(); |
| | | } |
| | | } |