SaleServiceController.java 3.7 KB
package com.huaheng.pc.saleService.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.exam.answer.domain.AnswerType;
import com.huaheng.pc.exam.answer.service.AnswerTypeService;
import com.huaheng.pc.saleService.domain.SaleService;
import com.huaheng.pc.saleService.service.SaleServicesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author:zhouhong
 * 2022021
 */
@Api(tags = {"验证码类"})
@Controller
@RequestMapping("/saleService")
public class SaleServiceController extends BaseController {
    @Resource
    private SaleServicesService saleServicesService;

    private String prefix = "saleService";

    @GetMapping()
    public String verificationCodeList()
    {
        return prefix + "/list";
    }
    /**
     * 查询验证码列表
     */
    @ApiOperation(value = "查看验证码列表",
            notes = "根据姓名、电话、类型筛选答卷信息",
            httpMethod = "POST")
    @Log(title = "试卷管理-验证码列表", operating = "查看验证码列表", action = BusinessType.GRANT)
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list (SaleService saleService) {
        LambdaQueryWrapper<SaleService> lambdaQueryWrapper = Wrappers.lambdaQuery();
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        lambdaQueryWrapper.like(StringUtils.isNotEmpty(saleService.getPerson()),SaleService::getPerson,saleService.getPerson())
                .eq(StringUtils.isNotEmpty(saleService.getPhone()), SaleService::getPhone,saleService.getPhone())
                .eq(StringUtils.isNotEmpty(saleService.getProductType()), SaleService::getProductType,saleService.getProductType());
        if(StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
            /*使用分页查询*/
            Page<SaleService> page = new Page<>(pageNum, pageSize);
            IPage<SaleService> iPage = saleServicesService.page(page, lambdaQueryWrapper);
            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
        } else {
            List<SaleService> list = saleServicesService.list(lambdaQueryWrapper);
            return getDataTable(list);
        }
    }





    @Log(title = "管理", operating = "删除", action = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        try
        {
            return toAjax(saleServicesService.removeByIds(Arrays.asList(Convert.toIntArray(ids))));
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }



}