代码生成器样例

v1.4.1
Parker 5 years ago
parent 4977b177c2
commit c973bff5ef

@ -0,0 +1,136 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.api.web.gentest.carinfo;
import org.opsli.api.base.result.ResultVo;
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.RequestParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.opsli.api.wrapper.gentest.carinfo.TestCarModel;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.api.web.gentest.carinfo
* @Author: Parker
* @CreateTime: 2020-12-20 20:12:57
* @Description:
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
public interface TestCarRestApi {
/** 标题 */
String TITLE = "汽车信息";
/**
*
* @param model
* @return ResultVo
*/
@GetMapping("/get")
ResultVo<TestCarModel> get(TestCarModel model);
/**
*
* @param pageNo
* @param pageSize
* @param request request
* @return ResultVo
*/
@GetMapping("/findPage")
ResultVo<?> findPage(
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request
);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/insert")
ResultVo<?> insert(@RequestBody TestCarModel model);
/**
*
* @param model
* @return ResultVo
*/
@PostMapping("/update")
ResultVo<?> update(@RequestBody TestCarModel model);
/**
*
* @param id ID
* @return ResultVo
*/
@PostMapping("/del")
ResultVo<?> del(String id);
/**
*
* @param ids ID
* @return ResultVo
*/
@PostMapping("/delAll")
ResultVo<?> delAll(String[] ids);
/**
* Excel
*
* Token
*
* 使2
*
* socketJava
* response javascript alert
*
* @param request request
* @param response response
* @return ResultVo
*/
@GetMapping("/exportExcel")
void exportExcel(HttpServletRequest request, HttpServletResponse response);
/**
* Excel
* @param request request
* @return ResultVo
*/
@PostMapping("/importExcel")
ResultVo<?> importExcel(MultipartHttpServletRequest request);
/**
* Excel
* @param response response
* @return ResultVo
*/
@GetMapping("/importExcel/template")
void importTemplate(HttpServletResponse response);
}

@ -0,0 +1,88 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.api.wrapper.gentest.carinfo;
import java.util.Date;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.api.wrapper.gentest.carinfo
* @Author: Parker
* @CreateTime: 2020-12-20 20:12:57
* @Description:
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class TestCarModel extends ApiWrapper {
/** 汽车名称 */
@ApiModelProperty(value = "汽车名称")
@ExcelProperty(value = "汽车名称", order = 1)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(20)
private String carName;
/** 汽车类型 */
@ApiModelProperty(value = "汽车类型")
@ExcelProperty(value = "汽车类型", order = 2)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(20)
private String carType;
/** 汽车品牌 */
@ApiModelProperty(value = "汽车品牌")
@ExcelProperty(value = "汽车品牌", order = 3)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50)
private String carBrand;
/** 生产日期 */
@ApiModelProperty(value = "生产日期")
@ExcelProperty(value = "生产日期", order = 4)
@ExcelInfo
// 验证器
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date produceData;
/** 是否启用 */
@ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 5)
@ExcelInfo( dictType = "no_yes" )
// 验证器
@ValidationArgsLenMax(1)
private String izUsable;
}

@ -38,6 +38,9 @@ public class DictWrapper {
/** 字典值 */
private String dictValue;
/** 排序 */
private Integer dictSort;
/** 消息 */
private DictDetailModel model;

@ -0,0 +1,88 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.api.wrapper.testt;
import java.util.Date;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.api.wrapper.testt
* @Author: parker
* @CreateTime: 2020-12-20 18:27:04
* @Description: 3
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Test3Model extends ApiWrapper {
/** 金钱 */
@ApiModelProperty(value = "金钱")
@ExcelProperty(value = "金钱", order = 1)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY})
@ValidationArgsLenMax(10)
private Double money;
/** 年龄 */
@ApiModelProperty(value = "年龄")
@ExcelProperty(value = "年龄", order = 2)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_NUMBER})
@ValidationArgsLenMax(3)
private Integer age;
/** 名称 */
@ApiModelProperty(value = "名称")
@ExcelProperty(value = "名称", order = 3)
@ExcelInfo
// 验证器
@ValidationArgs({ValiArgsType.IS_CHINESE})
@ValidationArgsLenMax(50)
private String name;
/** 生日 */
@ApiModelProperty(value = "生日")
@ExcelProperty(value = "生日", order = 4)
@ExcelInfo
// 验证器
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date birth;
/** 是否启用 */
@ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 5)
@ExcelInfo( dictType = "no_yes" )
// 验证器
@ValidationArgsLenMax(1)
private String izUsable;
}
Loading…
Cancel
Save