mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
增加 代码生成与MybatisPlus测试案例 cstest
This commit is contained in:
@ -0,0 +1,114 @@
|
||||
package com.ruoyi.project.cstest.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
||||
import com.ruoyi.project.cstest.domain.CsTest;
|
||||
import com.ruoyi.project.cstest.service.ICsTestService;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 测试Controller
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2020-02-14
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cstest/cstest" )
|
||||
public class CsTestController extends BaseController {
|
||||
|
||||
private final ICsTestService iCsTestService;
|
||||
|
||||
/**
|
||||
* 查询测试列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:list')" )
|
||||
@GetMapping("/list" )
|
||||
public TableDataInfo list(CsTest csTest) {
|
||||
startPage();
|
||||
LambdaQueryWrapper<CsTest> lqw = new LambdaQueryWrapper<CsTest>();
|
||||
if (StringUtils.isNotBlank(csTest.getTestKey())){
|
||||
lqw.like(CsTest::getTestKey ,csTest.getTestKey());
|
||||
}
|
||||
if (StringUtils.isNotBlank(csTest.getValue())){
|
||||
lqw.like(CsTest::getValue ,csTest.getValue());
|
||||
}
|
||||
if (csTest.getCreateTime() != null){
|
||||
lqw.eq(CsTest::getCreateTime ,csTest.getCreateTime());
|
||||
}
|
||||
List<CsTest> list = iCsTestService.list(lqw);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出测试列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:export')" )
|
||||
@Log(title = "测试" , businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export" )
|
||||
public AjaxResult export(CsTest csTest) {
|
||||
LambdaQueryWrapper<CsTest> lqw = new LambdaQueryWrapper<CsTest>(csTest);
|
||||
List<CsTest> list = iCsTestService.list(lqw);
|
||||
ExcelUtil<CsTest> util = new ExcelUtil<CsTest>(CsTest. class);
|
||||
return util.exportExcel(list, "cstest" );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测试详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:query')" )
|
||||
@GetMapping(value = "/{id}" )
|
||||
public AjaxResult getInfo(@PathVariable("id" ) Integer id) {
|
||||
return AjaxResult.success(iCsTestService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增测试
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:add')" )
|
||||
@Log(title = "测试" , businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CsTest csTest) {
|
||||
return toAjax(iCsTestService.save(csTest) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改测试
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:edit')" )
|
||||
@Log(title = "测试" , businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CsTest csTest) {
|
||||
return toAjax(iCsTestService.updateById(csTest) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除测试
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cstest:cstest:remove')" )
|
||||
@Log(title = "测试" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}" )
|
||||
public AjaxResult remove(@PathVariable Integer[] ids) {
|
||||
return toAjax(iCsTestService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.ruoyi.project.cstest.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 测试对象 chkj_test
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2020-02-14
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("chkj_test")
|
||||
public class CsTest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
|
||||
/** key键 */
|
||||
@Excel(name = "key键")
|
||||
private String testKey;
|
||||
|
||||
|
||||
/** 值 */
|
||||
@Excel(name = "值")
|
||||
private String value;
|
||||
|
||||
|
||||
/** 版本 */
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
/** 删除状态 */
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.project.cstest.mapper;
|
||||
|
||||
import com.ruoyi.project.cstest.domain.CsTest;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 测试Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2020-02-14
|
||||
*/
|
||||
public interface CsTestMapper extends BaseMapper<CsTest> {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.project.cstest.service;
|
||||
|
||||
import com.ruoyi.project.cstest.domain.CsTest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 测试Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2020-02-14
|
||||
*/
|
||||
public interface ICsTestService extends IService<CsTest> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.project.cstest.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.project.cstest.mapper.CsTestMapper;
|
||||
import com.ruoyi.project.cstest.domain.CsTest;
|
||||
import com.ruoyi.project.cstest.service.ICsTestService;
|
||||
|
||||
/**
|
||||
* 测试Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2020-02-14
|
||||
*/
|
||||
@Service
|
||||
public class CsTestServiceImpl extends ServiceImpl<CsTestMapper, CsTest> implements ICsTestService {
|
||||
|
||||
}
|
17
ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml
Normal file
17
ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.project.cstest.mapper.CsTestMapper">
|
||||
|
||||
<resultMap type="CsTest" id="CsTestResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="testKey" column="test_key" />
|
||||
<result property="value" column="value" />
|
||||
<result property="version" column="version" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="deleted" column="deleted" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user