123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- package com.txz.cif.web.mng;
- import cn.hutool.core.bean.BeanUtil;
- import com.txz.cif.core.AuthService;
- import com.txz.cif.core.Result;
- import com.txz.cif.core.ResultGenerator;
- import com.txz.cif.model.MidChannelMethod;
- import com.txz.cif.model.PaymentChannel;
- import com.txz.cif.model.PaymentMethod;
- import com.txz.cif.model.User;
- import com.txz.cif.service.MidChannelMethodService;
- import com.txz.cif.service.PaymentChannelService;
- import com.txz.cif.core.ResultCode;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.txz.cif.service.PaymentMethodService;
- import com.txz.cif.service.UserService;
- import com.txz.cif.web.bo.PaymentChannelBO;
- import com.txz.cif.web.para.PaymentChannelParam;
- import com.txz.cif.web.para.updateparam.PaymentChannelUpdateParam;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.*;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import com.txz.core.ServiceException;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import tk.mybatis.mapper.entity.Condition;
- import tk.mybatis.mapper.entity.Example.Criteria;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * Created by CodeGenerator on 2025/08/04.
- */
- @Api(tags = "[后台]paymentChannel管理")
- @RestController
- @RequestMapping("/payment/channel")
- public class PaymentChannelController {
- private static Logger log = LoggerFactory.getLogger(PaymentChannelController.class);
- @Resource
- private PaymentChannelService paymentChannelService;
- @Resource
- private UserService userService;
- @Resource
- private AuthService authService;
- @PostMapping("/add")
- @ApiOperation(value = "支付通道新增",httpMethod = "POST")
- public Result add(@RequestBody PaymentChannelParam paymentChannelParam,HttpServletRequest request) {
- if(paymentChannelParam == null){
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
- }
- // Long userId = authService.getTokenUserId(request);
- // if (userId == null ){
- // ResultGenerator.genFailResult(ResultCode.USERID_IS_NULL);
- // }
- // User user = userService.findById(userId);
- // if (user == null ){
- // ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
- // }
- try {
- // paymentChannel.setCreateTime(new Date());
- // paymentChannel.setCreateUserId(userId);
- PaymentChannel bean = BeanUtil.toBean(paymentChannelParam, PaymentChannel.class);
- bean.setIsValid((byte)1);
- bean.setVersion(1);
- bean.setCreateUser("lala");
- bean.setUpdateUser("lala");
- paymentChannelService.add(bean);
- } catch (Exception e) {
- log.error("新增对象操作异常e:{}",e);
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return ResultGenerator.genSuccessResult();
- }
- // @GetMapping("/delete")
- // @ApiOperation(value = "paymentChannel删除",httpMethod = "GET")
- // public Result delete(@RequestParam Integer id) {
- // if(id == null){
- // return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
- // }
- // try {
- // paymentChannelService.deleteById(id);
- // } catch (Exception e) {
- // log.error("删除对象操作异常e:{}",e);
- // return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
- // }
- // return ResultGenerator.genSuccessResult();
- // }
- @PostMapping("/update")
- @ApiOperation(value = "paymentChannel更新",httpMethod = "POST")
- public Result update(@RequestBody PaymentChannelUpdateParam paymentChannelUpdateParam) {
- if(paymentChannelUpdateParam == null){
- return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
- }
- if(paymentChannelUpdateParam.getId() == null){
- return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
- }
- PaymentChannel bean = BeanUtil.toBean(paymentChannelUpdateParam, PaymentChannel.class);
- try {
- // paymentChannel.setUpdateTime(new Date());
- // paymentChannel.setUpdateUserId(userId);
- paymentChannelService.modify(bean);
- } catch (Exception e) {
- log.error("更新对象操作异常e:{}",e);
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return ResultGenerator.genSuccessResult();
- }
- // @GetMapping("/detail")
- // @ApiOperation(value = "paymentChannel获取详情",httpMethod = "GET")
- // public Result<PaymentChannel> detail(@RequestParam Integer id) {
- // if(id == null){
- // return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
- // }
- //
- // PaymentChannel paymentChannel = null;
- // try {
- // paymentChannel = paymentChannelService.findById(id);
- // } catch (Exception e) {
- // log.error("查询对象操作异常e:{}",e);
- // return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
- // }
- //
- // return ResultGenerator.genSuccessResult(paymentChannel);
- // }
- @PostMapping("/list")
- @ApiOperation(value = "paymentChannel获取列表",httpMethod = "POST")
- public Result<List<PaymentChannelBO>> list() {
- // PageHelper.startPage(page, size);
- //
- // Condition condition = new Condition(paymentChannel.getClass());
- // Criteria criteria = condition.createCriteria();
- // criteria.andEqualTo("name", city.getName());
- // PageInfo pageInfo = null;
- List<PaymentChannelBO> resultList = new ArrayList<>();
- Byte b = (byte) 1;
- try {
- List<PaymentChannel> list = paymentChannelService.findAll();
- if(!CollectionUtils.isEmpty(list)) {
- resultList = list.stream().filter(a -> b.equals(a.getIsValid())).map(a -> BeanUtil.toBean(a, PaymentChannelBO.class)).collect(Collectors.toList());
- }
- } catch (Exception e) {
- log.error("查询对象操作异常e:{}",e);
- return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return ResultGenerator.genSuccessResult(resultList);
- }
- }
|