package com.oying.modules.system.rest;
|
|
import com.oying.annotation.Log;
|
import com.oying.modules.system.domain.Merchant;
|
import com.oying.modules.system.service.MerchantService;
|
import com.oying.modules.system.domain.dto.MerchantsQueryCriteria;
|
import com.oying.utils.R;
|
import lombok.RequiredArgsConstructor;
|
|
import java.util.List;
|
|
import org.springframework.http.HttpStatus;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
import io.swagger.annotations.*;
|
|
import java.io.IOException;
|
import javax.servlet.http.HttpServletResponse;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
/**
|
* @author lixin
|
* @date 2025-05-29
|
**/
|
@RestController
|
@RequiredArgsConstructor
|
@Api(tags = "系统:商户信息")
|
@RequestMapping("/api/merchant")
|
public class MerchantController {
|
|
private final MerchantService merchantService;
|
|
@ApiOperation("导出数据")
|
@GetMapping(value = "/download")
|
@PreAuthorize("@el.check('merchant:list')")
|
public void exportMerchants(HttpServletResponse response, MerchantsQueryCriteria criteria) throws IOException {
|
merchantService.download(merchantService.queryAll(criteria), response);
|
}
|
|
@GetMapping
|
@ApiOperation("查询商户信息")
|
@PreAuthorize("@el.check('merchant:list')")
|
public ResponseEntity<Object> queryMerchants(MerchantsQueryCriteria criteria) {
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
return new ResponseEntity<>(R.success(merchantService.queryAll(criteria, page)), HttpStatus.OK);
|
}
|
|
@PostMapping
|
@Log("新增商户信息")
|
@ApiOperation("新增商户信息")
|
@PreAuthorize("@el.check('merchant:add')")
|
public ResponseEntity<Object> createMerchants(@Validated @RequestBody Merchant resources) {
|
merchantService.create(resources);
|
return new ResponseEntity<>(R.success(), HttpStatus.CREATED);
|
}
|
|
@PutMapping
|
@Log("修改商户信息")
|
@ApiOperation("修改商户信息")
|
@PreAuthorize("@el.check('merchant:edit')")
|
public ResponseEntity<Object> updateMerchants(@Validated @RequestBody Merchant resources) {
|
merchantService.update(resources);
|
return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT);
|
}
|
|
@DeleteMapping
|
@Log("删除商户信息")
|
@ApiOperation("删除商户信息")
|
@PreAuthorize("@el.check('merchant:del')")
|
public ResponseEntity<Object> deleteMerchants(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
|
merchantService.deleteAll(ids);
|
return new ResponseEntity<>(R.success(), HttpStatus.OK);
|
}
|
}
|