结对作业02

Bean层
package com.cxk.baseframe.config.common.entity.systemmanage.system;

import com.cxk.baseframe.config.common.annotation.Excel;
import com.cxk.baseframe.config.common.entity.common.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 整条线路对象 a_lines
 *
 * @author cxk
 * @date 2024-04-14
 */
public class ALines extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键id */
    private Long id;

    /** 线路号 */
    @Excel(name = "线路号")
    private String lineNo;

    /** 全部站点 */
    @Excel(name = "全部站点")
    private String stations;

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }
    public void setLineNo(String lineNo)
    {
        this.lineNo = lineNo;
    }

    public String getLineNo()
    {
        return lineNo;
    }
    public void setStations(String stations)
    {
        this.stations = stations;
    }

    public String getStations()
    {
        return stations;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("lineNo", getLineNo())
            .append("stations", getStations())
            .toString();
    }
}
controller
package com.cxk.baseframe.project.systemmanage.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;

import com.cxk.baseframe.config.common.annotation.Log;
import com.cxk.baseframe.config.common.entity.common.domain.AjaxResult;
import com.cxk.baseframe.config.common.entity.common.domain.page.TableDataInfo;
import com.cxk.baseframe.config.common.entity.systemmanage.system.ALines;
import com.cxk.baseframe.config.common.enums.BusinessType;
import com.cxk.baseframe.config.common.response.BaseController;
import com.cxk.baseframe.config.common.utils.MapUtil;
import com.cxk.baseframe.config.common.utils.poi.ExcelUtil;
import com.cxk.baseframe.project.systemmanage.service.IALinesService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 整条线路Controller
 *
 * @author cxk
 * @date 2024-04-14
 */
@Api(tags={"整条线路管理"})
@RestController
@RequestMapping("/system-manage-service/system/lines")
public class ALinesController extends BaseController
{
    @Resource
    private IALinesService aLinesService;

    /**
     * 查询整条线路列表
     */
    @ApiOperation(value="查询整条线路列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "aLines", value = "整条线路实体", dataType = "ALines", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", defaultValue = "1", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", dataType = "Integer", defaultValue = "10", required = false)
    })
    @GetMapping("/list")
    public TableDataInfo list(ALines aLines)
    {
        startPage();
        List<ALines> list = aLinesService.selectALinesList(aLines);
        return getDataTable(list);
    }

    /**
     * 导出整条线路列表
     */
    @ApiOperation(value="导出整条线路列表")
    @ApiImplicitParam(name = "aLines", value = "整条线路实体", dataType = "ALines", required = false)
    @Log(title = "整条线路", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ALines aLines)
    {
        List<ALines> list = aLinesService.selectALinesList(aLines);
        ExcelUtil<ALines> util = new ExcelUtil<ALines>(ALines.class);
        util.exportExcel(response, list, "整条线路数据");
    }

    /**
     * 获取整条线路详细信息
     */
    @ApiOperation(value="获取整条线路详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "整条线路Id", dataType = "Long", paramType = "query", required = true)
    })
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestParam Long id)
    {
        return success(aLinesService.selectALinesById(id));
    }

    /**
     * 新增整条线路
     */
    @ApiOperation(value="新增整条线路")
    @ApiImplicitParam(name = "aLines", value = "整条线路实体", dataType = "ALines", required = true)
    @Log(title = "整条线路", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ALines aLines)
    {
        return toAjax(aLinesService.insertALines(aLines));
    }

    /**
     * 修改整条线路
     */
    @ApiOperation(value="修改整条线路")
    @ApiImplicitParam(name = "aLines", value = "整条线路实体", dataType = "ALines", required = true)
    @Log(title = "整条线路", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ALines aLines)
    {
        return toAjax(aLinesService.updateALines(aLines));
    }

    /**
     * 删除整条线路
     */
    @ApiOperation(value="删除整条线路")
    @ApiImplicitParam(name = "ids", value = "整条线路数组", dataType = "Long[]", required = true)
    @Log(title = "整条线路", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam Long[] ids)
    {
        return toAjax(aLinesService.deleteALinesByIds(ids));
    }

    /**
     * uniapp端删除整条线路
     */
    @ApiOperation(value="uniapp端删除整条线路")
    @ApiImplicitParam(name = "ids", value = "整条线路id(多个以逗号分隔)", dataType = "String", required = true)
    @Log(title = "整条线路", businessType = BusinessType.DELETE)
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String,String> map)
    {
        if(MapUtil.checkContains(map,"ids")){
            String[] ids = map.get("ids").split(",");
            Long[] idArr = new Long[ids.length];
            for (int i = 0; i < ids.length; i++) {
                    idArr[i] = Long.parseLong(ids[i]);
            }
            return toAjax(aLinesService.deleteALinesByIds(idArr));
        }
        return AjaxResult.error("请先选择整条线路!");
    }
}
service
package com.cxk.baseframe.project.systemmanage.service.Impl;

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

import com.cxk.baseframe.config.common.entity.systemmanage.system.ALines;
import com.cxk.baseframe.project.systemmanage.mapper.ALinesMapper;
import com.cxk.baseframe.project.systemmanage.service.IALinesService;
import org.springframework.stereotype.Service;

/**
 * 整条线路Service业务层处理
 *
 * @author cxk
 * @date 2024-04-14
 */
@Service
public class ALinesServiceImpl implements IALinesService
{
    @Resource
    private ALinesMapper aLinesMapper;

    /**
     * 查询整条线路
     *
     * @param id 整条线路主键
     * @return 整条线路
     */
    @Override
    public ALines selectALinesById(Long id)
    {
        return aLinesMapper.selectALinesById(id);
    }

    /**
     * 查询整条线路列表
     *
     * @param aLines 整条线路
     * @return 整条线路
     */
    @Override
    public List<ALines> selectALinesList(ALines aLines)
    {
        return aLinesMapper.selectALinesList(aLines);
    }

    /**
     * 新增整条线路
     *
     * @param aLines 整条线路
     * @return 结果
     */
    @Override
    public int insertALines(ALines aLines)
    {
        return aLinesMapper.insertALines(aLines);
    }

    /**
     * 修改整条线路
     *
     * @param aLines 整条线路
     * @return 结果
     */
    @Override
    public int updateALines(ALines aLines)
    {
        return aLinesMapper.updateALines(aLines);
    }

    /**
     * 批量删除整条线路
     *
     * @param ids 需要删除的整条线路主键
     * @return 结果
     */
    @Override
    public int deleteALinesByIds(Long[] ids)
    {
        return aLinesMapper.deleteALinesByIds(ids);
    }

    /**
     * 删除整条线路信息
     *
     * @param id 整条线路主键
     * @return 结果
     */
    @Override
    public int deleteALinesById(Long id)
    {
        return aLinesMapper.deleteALinesById(id);
    }
}
package com.cxk.baseframe.project.systemmanage.mapper;

import com.cxk.baseframe.config.common.entity.systemmanage.system.ALines;

import java.util.List;

/**
 * 整条线路Mapper接口
 *
 * @author cxk
 * @date 2024-04-14
 */
public interface ALinesMapper
{
    /**
     * 查询整条线路
     *
     * @param id 整条线路主键
     * @return 整条线路
     */
    public ALines selectALinesById(Long id);

    /**
     * 查询整条线路列表
     *
     * @param aLines 整条线路
     * @return 整条线路集合
     */
    public List<ALines> selectALinesList(ALines aLines);

    /**
     * 新增整条线路
     *
     * @param aLines 整条线路
     * @return 结果
     */
    public int insertALines(ALines aLines);

    /**
     * 修改整条线路
     *
     * @param aLines 整条线路
     * @return 结果
     */
    public int updateALines(ALines aLines);

    /**
     * 删除整条线路
     *
     * @param id 整条线路主键
     * @return 结果
     */
    public int deleteALinesById(Long id);

    /**
     * 批量删除整条线路
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteALinesByIds(Long[] ids);
}

 

posted @ 2024-04-14 16:17  艾鑫4646  阅读(6)  评论(0编辑  收藏  举报