彭雪彬
2025-07-14 c1d20b425b10e8ba59f102dd1ab413055883eed0
oying-system/src/main/java/com/oying/modules/system/rest/UserMerchantController.java
New file
@@ -0,0 +1,77 @@
package com.oying.modules.system.rest;
import com.oying.annotation.Log;
import com.oying.modules.system.domain.UserMerchant;
import com.oying.modules.system.service.UserMerchantService;
import com.oying.modules.system.domain.dto.UserMerchantQueryCriteria;
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-06-16
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:商户管理员信息")
@RequestMapping("/api/userMerchant")
public class UserMerchantController {
    private final UserMerchantService userMerchantService;
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('userMerchant:list')")
    public void exportUserMerchant(HttpServletResponse response, UserMerchantQueryCriteria criteria) throws IOException {
        userMerchantService.download(userMerchantService.queryAll(criteria), response);
    }
    @GetMapping
    @ApiOperation("查询商户管理员信息")
    @PreAuthorize("@el.check('userMerchant:list')")
    public ResponseEntity<Object> queryUserMerchant(UserMerchantQueryCriteria criteria) {
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(R.success(userMerchantService.queryAll(criteria, page)), HttpStatus.OK);
    }
    @PostMapping
    @Log("新增商户管理员信息")
    @ApiOperation("新增商户管理员信息")
    @PreAuthorize("@el.check('userMerchant:add')")
    public ResponseEntity<Object> createUserMerchant(@Validated @RequestBody UserMerchant resources) {
        userMerchantService.create(resources);
        return new ResponseEntity<>(R.success(), HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改商户管理员信息")
    @ApiOperation("修改商户管理员信息")
    @PreAuthorize("@el.check('userMerchant:edit')")
    public ResponseEntity<Object> updateUserMerchant(@Validated @RequestBody UserMerchant resources) {
        userMerchantService.update(resources);
        return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除商户管理员信息")
    @ApiOperation("删除商户管理员信息")
    @PreAuthorize("@el.check('userMerchant:del')")
    public ResponseEntity<Object> deleteUserMerchant(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
        userMerchantService.deleteAll(ids);
        return new ResponseEntity<>(R.success(), HttpStatus.OK);
    }
}