package com.simple.controller; import com.github.pagehelper.PageInfo; import com.simple.common.ErrorCode; import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxMerchant; import com.simple.domain.po.WxProfitSharingReceiver; import com.simple.service.WxMerchantService; import com.simple.service.WxProfitSharingReceiverService; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("wxProfitSharingReceiver") public class WxProfitSharingReceiverController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private WxProfitSharingReceiverService wxProfitSharingReceiverService; @Autowired private WxMerchantService wxMerchantService; @ApiOperation("分页列表接口") @GetMapping("list") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) public ResultData list(@ModelAttribute WxProfitSharingReceiver receiver, Integer pageNum, Integer pageSize) { if (null == receiver) receiver = new WxProfitSharingReceiver(); final PageInfo page = wxProfitSharingReceiverService.listAsPage(receiver, pageNum, pageSize); return new ResultData(page); } @ApiOperation("新增接口") @PostMapping("add") public ResultData add(@ModelAttribute WxProfitSharingReceiver receiver) { if (receiver == null) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); if (receiver.getMerchantId() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getReceiverType() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getReceiverComments() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getReceiverAccount() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getTrueName() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); if (merchant == null) return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); return wxProfitSharingReceiverService.addReceiver(merchant, receiver); } @ApiOperation("根据id删除接口") @GetMapping("del") public ResultData delete(@ModelAttribute WxProfitSharingReceiver receiver) { if (receiver == null) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); if (receiver.getMerchantId() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getReceiverType() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); if (receiver.getReceiverAccount() == null) return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); if (merchant == null) return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); return wxProfitSharingReceiverService.delReceiver(merchant, receiver); } }