jeecg-boot各层自我练习

Controller 控制层

@Api(tags="Test")
@RestController
@RequestMapping("/safe/safetyTest")
@Slf4j
package org.jeecg.modules.safe.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.safe.entity.SafetyTaskHistory;

import org.jeecg.modules.safe.service.ISafetyTestService;
import org.jeecg.modules.safe.entity.SafetyTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * @Description:
 * @Author: Wangjq
 * @Date: 2022/07/06 14:06
 * @Version: V1.0
 **/
@Api(tags="Test")
@RestController
@RequestMapping("/safe/safetyTest")
@Slf4j
public class SafetyTestController extends JeecgController {

    @Autowired
    private ISafetyTestService safetyTestService;

    /**
     * 分页列表查询
     *
     * @param safetyTest
     * @param pageNo
     * @param pageSize
     * @param request
     * @return
     */
    //@AutoLog(value = "测试任务-分页列表查询")
    @ApiOperation(value="测试任务-分页列表查询", notes="测试任务-分页列表查询")
    @GetMapping(value = "/list")
    public Result> queryPageList(SafetyTest safetyTest,
                                                               @RequestParam(name = "pageNo",defaultValue = "1")Integer pageNo,
                                                               @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
                                                               HttpServletRequest request){
        QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(safetyTest, request.getParameterMap());
        Page page = new Page<>(pageNo, pageSize);
        IPage pageList = safetyTestService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

}

Service 服务层

服务层接口

主要继承extends IService<实体类>

package org.jeecg.modules.safe.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.safe.entity.SafetyTest;

/**
 * @author Wangyiyi
 * @date 2022/07/06 14:18
 **/
public interface ISafetyTestService extends IService {
}

服务层实现类

@Service
package org.jeecg.modules.safe.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.safe.entity.SafetyTest;
import org.jeecg.modules.safe.mapper.SafetyTestMapper;
import org.jeecg.modules.safe.service.ISafetyTestService;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * @Author: Wangjq
 * @Date: 2022/07/06 14:19
 * @Version: V1.0
 **/
@Service
public class SafetyTestServiceImpl extends ServiceImpl implements ISafetyTestService {
}

 

主要继承extends BaseMapper<实体类> 

package org.jeecg.modules.safe.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.safe.entity.SafetyTest;

/**
 * @author Wangyiyi
 * @date 2022/07/06 14:20
 **/
public interface SafetyTestMapper extends BaseMapper {
}

entity 实体层

主要实现 implements Serializable

@Data
@TableName("safetyTest")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "safetyTest",description = "safetyTest")
package org.jeecg.modules.safe.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;

import java.io.Serializable;

/**
 * @Description:
 * @Author: Wangjq
 * @Date: 2022/07/06 14:08
 * @Version: V1.0
 **/
@Data
@TableName("safetyTest")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "safetyTest",description = "safetyTest")
public class SafetyTest implements Serializable {

    /**id*/
    @Excel(name = "id", width = 15)
    @ApiModelProperty(value = "id")
    private Integer id;
    /**组织*/
    @Excel(name = "组织", width = 15)
    @ApiModelProperty(value = "组织")
    private Integer orgId;

    /**任务名称*/
    @Excel(name = "任务名称", width = 15)
    @ApiModelProperty(value = "任务名称")
    private String name;
}

你可能感兴趣的:(大数据)