119 lines
3.9 KiB
Java
119 lines
3.9 KiB
Java
package com.gxwebsoft.shop.controller;
|
|
|
|
import com.gxwebsoft.common.core.web.BaseController;
|
|
import com.gxwebsoft.shop.service.WechatDepositService;
|
|
import com.gxwebsoft.shop.entity.WechatDeposit;
|
|
import com.gxwebsoft.shop.param.WechatDepositParam;
|
|
import com.gxwebsoft.common.core.web.ApiResult;
|
|
import com.gxwebsoft.common.core.web.PageResult;
|
|
import com.gxwebsoft.common.core.web.BatchParam;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 押金控制器
|
|
*
|
|
* @author 科技小王子
|
|
* @since 2024-05-03 15:50:28
|
|
*/
|
|
@Api(tags = "押金管理")
|
|
@RestController
|
|
@RequestMapping("/api/shop/wechat-deposit")
|
|
public class WechatDepositController extends BaseController {
|
|
@Resource
|
|
private WechatDepositService wechatDepositService;
|
|
|
|
@ApiOperation("分页查询押金")
|
|
@GetMapping("/page")
|
|
public ApiResult<PageResult<WechatDeposit>> page(WechatDepositParam param) {
|
|
// 使用关联查询
|
|
return success(wechatDepositService.pageRel(param));
|
|
}
|
|
|
|
@ApiOperation("查询全部押金")
|
|
@GetMapping()
|
|
public ApiResult<List<WechatDeposit>> list(WechatDepositParam param) {
|
|
// 使用关联查询
|
|
return success(wechatDepositService.listRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:list')")
|
|
@ApiOperation("根据id查询押金")
|
|
@GetMapping("/{id}")
|
|
public ApiResult<WechatDeposit> get(@PathVariable("id") Integer id) {
|
|
// 使用关联查询
|
|
return success(wechatDepositService.getByIdRel(id));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:list')")
|
|
@ApiOperation("添加押金")
|
|
@PostMapping()
|
|
public ApiResult<?> save(@RequestBody WechatDeposit wechatDeposit) {
|
|
// 记录当前登录用户id
|
|
// User loginUser = getLoginUser();
|
|
// if (loginUser != null) {
|
|
// wechatDeposit.setUserId(loginUser.getUserId());
|
|
// }
|
|
if (wechatDepositService.save(wechatDeposit)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:update')")
|
|
@ApiOperation("修改押金")
|
|
@PutMapping()
|
|
public ApiResult<?> update(@RequestBody WechatDeposit wechatDeposit) {
|
|
if (wechatDepositService.updateById(wechatDeposit)) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:remove')")
|
|
@ApiOperation("删除押金")
|
|
@DeleteMapping("/{id}")
|
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
|
if (wechatDepositService.removeById(id)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:save')")
|
|
@ApiOperation("批量添加押金")
|
|
@PostMapping("/batch")
|
|
public ApiResult<?> saveBatch(@RequestBody List<WechatDeposit> list) {
|
|
if (wechatDepositService.saveBatch(list)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:update')")
|
|
@ApiOperation("批量修改押金")
|
|
@PutMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<WechatDeposit> batchParam) {
|
|
if (batchParam.update(wechatDepositService, "id")) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('shop:wechatDeposit:remove')")
|
|
@ApiOperation("批量删除押金")
|
|
@DeleteMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
|
if (wechatDepositService.removeByIds(ids)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
}
|