新增mybatisplus代码生成器
This commit is contained in:
1 parent
4ae8d364b9
commit
60a95160fe
198 files changed
+12403
-95
No files matched your search
+4
-3
@@ -37,6 +37,7 @@
|
||||
<hutool.version>4.1.1</hutool.version>
|
||||
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
|
||||
<version>3.5.0</version>
|
||||
<mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -122,12 +123,12 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generate</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.api;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 响应码
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public enum ApiCode {
|
||||
|
||||
SUCCESS(200, "操作成功"),
|
||||
|
||||
UNAUTHORIZED(401, "非法访问"),
|
||||
|
||||
NOT_PERMISSION(403, "没有权限"),
|
||||
|
||||
NOT_FOUND(404, "你请求的路径不存在"),
|
||||
|
||||
FAIL(500, "操作失败"),
|
||||
|
||||
SYSTEM_EXCEPTION(5000,"系统异常!"),
|
||||
|
||||
PARAMETER_EXCEPTION(5001,"请求参数校验异常"),
|
||||
|
||||
PARAMETER_PARSE_EXCEPTION(5002,"请求参数解析异常"),
|
||||
|
||||
HTTP_MEDIA_TYPE_EXCEPTION(5003,"HTTP Media 类型异常"),
|
||||
|
||||
SYSTEM_LOGIN_EXCEPTION(5005,"系统登录异常")
|
||||
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
ApiCode(final int code, final String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static ApiCode getApiCode(int code) {
|
||||
ApiCode[] ecs = ApiCode.values();
|
||||
for (ApiCode ec : ecs) {
|
||||
if (ec.getCode() == code) {
|
||||
return ec;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ApiResultEST API 公共控制器
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class ApiController {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求成功
|
||||
* </p>
|
||||
*
|
||||
* @param data 数据内容
|
||||
* @param <T> 对象泛型
|
||||
* @return
|
||||
*/
|
||||
protected <T> ApiResult<T> ok(T data) {
|
||||
return ApiResult.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param msg 提示内容
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(String msg) {
|
||||
return ApiResult.fail(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param apiCode 请求错误码
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(ApiCode apiCode) {
|
||||
return ApiResult.fail(apiCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.api;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 返回结果
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class ApiResult<T> implements Serializable {
|
||||
|
||||
private int code;
|
||||
|
||||
private T data;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date time;
|
||||
|
||||
public ApiResult() {
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult result(boolean flag){
|
||||
if (flag){
|
||||
return ok();
|
||||
}
|
||||
return fail("");
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,Object data){
|
||||
return result(apiCode,null,data);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,String msg,Object data){
|
||||
String message = apiCode.getMsg();
|
||||
if (StringUtils.isNotBlank(msg)){
|
||||
message = msg;
|
||||
}
|
||||
return ApiResult.builder()
|
||||
.code(apiCode.getCode())
|
||||
.msg(message)
|
||||
.data(data)
|
||||
.time(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static ApiResult ok(){
|
||||
return ok(null);
|
||||
}
|
||||
|
||||
public static ApiResult ok(Object data){
|
||||
return result(ApiCode.SUCCESS,data);
|
||||
}
|
||||
|
||||
public static ApiResult ok(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return ok(map);
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult fail(String msg){
|
||||
return result(ApiCode.FAIL,msg,null);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode,Object data){
|
||||
if (ApiCode.SUCCESS == apiCode){
|
||||
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode());
|
||||
}
|
||||
return result(apiCode,data);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return result(ApiCode.FAIL,map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.api.IErrorCode;
|
||||
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 业务断言<br>
|
||||
* 参考:org.junit.Assert
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
protected Assert() {
|
||||
// to do noting
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于O
|
||||
*/
|
||||
public static void gtZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num <= 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于等于O
|
||||
*/
|
||||
public static void geZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num < 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于num2
|
||||
*/
|
||||
public static void gt(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 <= num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于等于num2
|
||||
*/
|
||||
public static void ge(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 < num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* obj1 eq obj2
|
||||
*/
|
||||
public static void eq(Object obj1, Object obj2, IErrorCode errorCode) {
|
||||
if (!obj1.equals(obj2)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isTrue(boolean condition, IErrorCode errorCode) {
|
||||
if (!condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isFalse(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNotNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 失败结果
|
||||
* </p>
|
||||
*
|
||||
* @param errorCode 异常错误码
|
||||
*/
|
||||
public static void fail(IErrorCode errorCode) {
|
||||
throw new ApiException(errorCode);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fail(String message) {
|
||||
throw new ApiException(message);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, String message) {
|
||||
if (condition) {
|
||||
Assert.fail(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Object[] array, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void noNullElements(Object[] array, IErrorCode errorCode) {
|
||||
if (array != null) {
|
||||
for (Object element : array) {
|
||||
if (element == null) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Collection<?> collection, IErrorCode errorCode) {
|
||||
if (CollectionUtils.isNotEmpty(collection)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Map<?, ?> map, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(map)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isInstanceOf(Class<?> type, Object obj, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, type);
|
||||
if (!type.isInstance(obj)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isAssignable(Class<?> superType, Class<?> subType, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, superType);
|
||||
if (subType == null || !superType.isAssignableFrom(subType)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.constant;
|
||||
|
||||
|
||||
public interface CacheKey {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
|
||||
/**
|
||||
* 默认页码为1
|
||||
*/
|
||||
Integer DEFAULT_PAGE_INDEX = 1;
|
||||
|
||||
/**
|
||||
* 默认页大小为10
|
||||
*/
|
||||
Integer DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "loginSysUser";
|
||||
|
||||
/**
|
||||
* 登陆token
|
||||
*/
|
||||
String TOKEN = "token";
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
String REFRESH_TOKEN = "refresh_token";
|
||||
|
||||
/**
|
||||
* 初始密码
|
||||
*/
|
||||
String INIT_PWD = "123456";
|
||||
|
||||
/**
|
||||
* 默认头像
|
||||
*/
|
||||
String DEFAULT_HEAD_URL = "";
|
||||
|
||||
/**
|
||||
* 管理员角色名称
|
||||
*/
|
||||
String ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
String ADMIN_LOGIN = "adminLogin";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
* <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 com.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* redis key 常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2019-05-23
|
||||
**/
|
||||
public interface CommonRedisKey {
|
||||
|
||||
/**
|
||||
* 系统登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "login:sys:user:%s";
|
||||
/**
|
||||
* 系统登录token
|
||||
*/
|
||||
String LOGIN_TOKEN = "login:token";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 日期格式常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface DatePattern {
|
||||
|
||||
/**
|
||||
* 年-月-日
|
||||
*/
|
||||
String yyyy_MM_dd = "yyyy-MM-dd";
|
||||
/**
|
||||
* 年-月-日 时:分
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
|
||||
/**
|
||||
* 年-月-日 时:分:秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 年-月-日 时:分:秒:毫秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss_S = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 时:分
|
||||
*/
|
||||
String HH_mm = "HH:mm";
|
||||
/**
|
||||
* 时:分:秒
|
||||
*/
|
||||
String HH_mm_ss = "HH:mm:ss";
|
||||
/**
|
||||
* 时:分:秒:毫秒
|
||||
*/
|
||||
String HH_mm_ss_S = "HH:mm:ss:S";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
package com.ruoyi.app.common.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("BaseEntity")
|
||||
public abstract class BaseEntity implements Serializable{
|
||||
}
|
||||
@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.app.common.service.BaseService;
|
||||
import com.ruoyi.app.common.web.param.OrderQueryParam;
|
||||
import com.ruoyi.app.common.web.param.QueryParam;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -32,7 +34,33 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam) {
|
||||
return setPageParam(queryParam,null);
|
||||
}
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) {
|
||||
Page page = new Page();
|
||||
// 设置当前页码
|
||||
page.setCurrent(queryParam.getCurrent());
|
||||
// 设置页大小
|
||||
page.setSize(queryParam.getSize());
|
||||
/**
|
||||
* 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序
|
||||
* 否则使用默认排序
|
||||
*/
|
||||
if (queryParam instanceof OrderQueryParam){
|
||||
OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam;
|
||||
List<OrderItem> orderItems = orderQueryParam.getOrders();
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}else{
|
||||
page.setOrders(orderItems);
|
||||
}
|
||||
}else{
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Api文档
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/docs")
|
||||
@ApiIgnore
|
||||
public class ApiDocController extends BaseController {
|
||||
|
||||
/**
|
||||
* swaggerUI
|
||||
*/
|
||||
@GetMapping("")
|
||||
public String swaggerUI(){
|
||||
return "redirect:/swagger-ui.html";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.controller;
|
||||
|
||||
import com.ruoyi.app.common.api.ApiController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class BaseController extends ApiController {
|
||||
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return request
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.controller;
|
||||
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目根路径提示信息
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018/11/12
|
||||
*/
|
||||
@RestController
|
||||
@ApiIgnore
|
||||
@Slf4j
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping("/index")
|
||||
public ApiResult<String> index(){
|
||||
log.debug("index...");
|
||||
return ApiResult.ok("Welcome to Spring Boot Plus Project...");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("ID参数")
|
||||
public class IdParam implements Serializable {
|
||||
private static final long serialVersionUID = -5353973980674510450L;
|
||||
|
||||
@NotBlank(message="ID不能为空")
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("主键状态VO")
|
||||
public class IdStatusParam implements Serializable {
|
||||
private static final long serialVersionUID = -7581307955242965701L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("状态,1:启用 0:禁用")
|
||||
private Integer status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IdStatusVo{" +
|
||||
"id='" + id + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 名称参数
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("名称参数")
|
||||
public class NameParam implements Serializable {
|
||||
private static final long serialVersionUID = -3710501706034574149L;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NameParam{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.param;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 可排序查询参数对象
|
||||
* @author geekidea
|
||||
* @since 2019-08-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("可排序查询参数对象")
|
||||
public abstract class OrderQueryParam extends QueryParam{
|
||||
private static final long serialVersionUID = 57714391204790143L;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private List<OrderItem> orders;
|
||||
|
||||
public void defaultOrder(OrderItem orderItem){
|
||||
this.defaultOrders(Arrays.asList(orderItem));
|
||||
}
|
||||
|
||||
public void defaultOrders(List<OrderItem> orderItems){
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
return;
|
||||
}
|
||||
this.orders = orderItems;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.param;
|
||||
|
||||
import com.ruoyi.app.common.constant.CommonConstant;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("查询参数对象")
|
||||
public abstract class QueryParam implements Serializable{
|
||||
private static final long serialVersionUID = -3263921252635611410L;
|
||||
|
||||
@ApiModelProperty(value = "页码,默认为1")
|
||||
private Integer current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
@ApiModelProperty(value = "页大小,默认为10")
|
||||
private Integer size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
@ApiModelProperty(value = "搜索字符串")
|
||||
private String keyword;
|
||||
|
||||
public void setCurrent(Integer current) {
|
||||
if (current == null || current <= 0){
|
||||
this.current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
}else{
|
||||
this.current = current;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
if (size == null || size <= 0){
|
||||
this.size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
}else{
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公共ID-NAME-VO对象
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@ApiModel("ID-NAME-VO")
|
||||
public class CommonIdName {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName(String id, String name) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommonIdName [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.app.common.web.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("分页")
|
||||
public class Paging<T> implements Serializable {
|
||||
private static final long serialVersionUID = -1683800405530086022L;
|
||||
|
||||
@ApiModelProperty("总行数")
|
||||
@JSONField(name = "total")
|
||||
@JsonProperty("total")
|
||||
private long total = 0;
|
||||
|
||||
@ApiModelProperty("数据列表")
|
||||
@JSONField(name = "records")
|
||||
@JsonProperty("records")
|
||||
private List<T> records = Collections.emptyList();
|
||||
|
||||
public Paging() {
|
||||
}
|
||||
|
||||
public Paging(IPage page) {
|
||||
this.total = page.getTotal();
|
||||
this.records = page.getRecords();
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<T> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(List<T> records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Paging{" +
|
||||
"total=" + total +
|
||||
", records=" + records +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.app.modular.distribution.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.app.common.entity.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="StoreSubstitute对象", description="代发货表")
|
||||
public class StoreSubstitute extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "收货手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "城市信息")
|
||||
private String cityInfo;
|
||||
|
||||
@ApiModelProperty(value = "收货详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "产品明细")
|
||||
private String productInfo;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Integer createTime;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.app.modular.distribution.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Repository
|
||||
public interface StoreSubstituteMapper extends BaseMapper<StoreSubstitute> {
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreSubstituteQueryVo getStoreSubstituteById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param storeSubstituteQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<StoreSubstituteQueryVo> getStoreSubstitutePageList(@Param("page") Page page, @Param("param") StoreSubstituteQueryParam storeSubstituteQueryParam);
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.app.modular.distribution.service;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.common.service.BaseService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
public interface StoreSubstituteService extends BaseService<StoreSubstitute> {
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreSubstituteQueryVo getStoreSubstituteById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param storeSubstituteQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<StoreSubstituteQueryVo> getStoreSubstitutePageList(StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception;
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.app.modular.distribution.service.impl;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.modular.distribution.mapper.StoreSubstituteMapper;
|
||||
import com.ruoyi.app.modular.distribution.service.StoreSubstituteService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class StoreSubstituteServiceImpl extends BaseServiceImpl<StoreSubstituteMapper, StoreSubstitute> implements StoreSubstituteService {
|
||||
|
||||
@Autowired
|
||||
private StoreSubstituteMapper storeSubstituteMapper;
|
||||
|
||||
@Override
|
||||
public StoreSubstituteQueryVo getStoreSubstituteById(Serializable id) throws Exception{
|
||||
return storeSubstituteMapper.getStoreSubstituteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<StoreSubstituteQueryVo> getStoreSubstitutePageList(StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception{
|
||||
Page page = setPageParam(storeSubstituteQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<StoreSubstituteQueryVo> iPage = storeSubstituteMapper.getStoreSubstitutePageList(page,storeSubstituteQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.ruoyi.app.modular.distribution.web.controller;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.modular.distribution.service.StoreSubstituteService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.web.controller.BaseController;
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 javax.validation.Valid;
|
||||
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
import com.ruoyi.app.common.web.param.IdParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/storeSubstitute")
|
||||
@Api("代发货表 API")
|
||||
public class StoreSubstituteController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private StoreSubstituteService storeSubstituteService;
|
||||
|
||||
/**
|
||||
* 添加代发货表
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加StoreSubstitute对象",notes = "添加代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> addStoreSubstitute(@Valid @RequestBody StoreSubstitute storeSubstitute) throws Exception{
|
||||
boolean flag = storeSubstituteService.save(storeSubstitute);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改代发货表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改StoreSubstitute对象",notes = "修改代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> updateStoreSubstitute(@Valid @RequestBody StoreSubstitute storeSubstitute) throws Exception{
|
||||
boolean flag = storeSubstituteService.updateById(storeSubstitute);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除代发货表
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除StoreSubstitute对象",notes = "删除代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> deleteStoreSubstitute(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = storeSubstituteService.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代发货表
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取StoreSubstitute对象详情",notes = "查看代发货表",response = StoreSubstituteQueryVo.class)
|
||||
public ApiResult<StoreSubstituteQueryVo> getStoreSubstitute(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
StoreSubstituteQueryVo storeSubstituteQueryVo = storeSubstituteService.getStoreSubstituteById(idParam.getId());
|
||||
return ApiResult.ok(storeSubstituteQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代发货表分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取StoreSubstitute分页列表",notes = "代发货表分页列表",response = StoreSubstituteQueryVo.class)
|
||||
public ApiResult<Paging<StoreSubstituteQueryVo>> getStoreSubstitutePageList(@Valid @RequestBody(required = false) StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception{
|
||||
Paging<StoreSubstituteQueryVo> paging = storeSubstituteService.getStoreSubstitutePageList(storeSubstituteQueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.app.distribution.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import com.ruoyi.app.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="StoreSubstituteQueryParam对象", description="代发货表查询参数")
|
||||
public class StoreSubstituteQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.app.distribution.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="StoreSubstituteQueryVo对象", description="代发货表查询参数")
|
||||
public class StoreSubstituteQueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "收货手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "城市信息")
|
||||
private String cityInfo;
|
||||
|
||||
@ApiModelProperty(value = "收货详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "产品明细")
|
||||
private String productInfo;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Integer createTime;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.app.modular.distribution.mapper.StoreSubstituteMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, phone, city_info, address, product_info, create_time, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="getStoreSubstituteById" resultType="com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getStoreSubstitutePageList" resultType="com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.app.modular.distribution.mapper.StoreSubstituteMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, phone, city_info, address, product_info, create_time, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="getStoreSubstituteById" resultType="com.ruoyi.app.modular.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getStoreSubstitutePageList" resultType="com.ruoyi.app.modular.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,92 +1,92 @@
|
||||
package com.ruoyi.generator;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自动生成
|
||||
*/
|
||||
public class EntityGenerator {
|
||||
|
||||
@Test
|
||||
public void entityGenerator() {
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
gc.setOutputDir("E:\\java\\Supply\\ruoyi-api\\src\\main\\java");//这里写你自己的java目录
|
||||
gc.setFileOverride(true);//是否覆盖
|
||||
gc.setActiveRecord(true);
|
||||
gc.setEnableCache(false);// XML 二级缓存
|
||||
gc.setBaseResultMap(true);// XML ResultMap
|
||||
gc.setBaseColumnList(false);// XML columList
|
||||
gc.setAuthor("hupeng");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
dsc.setTypeConvert(new MySqlTypeConvert() {
|
||||
// 自定义数据库表字段类型转换【可选】
|
||||
@Override
|
||||
public DbColumnType processTypeConvert(String fieldType) {
|
||||
return super.processTypeConvert(fieldType);
|
||||
}
|
||||
});
|
||||
dsc.setDriverName("com.mysql.jdbc.Driver");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("root");
|
||||
dsc.setUrl("jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||
strategy.setInclude(new String[]{"store_order",});
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setParent(null);
|
||||
pc.setEntity("com.ruoyi.app.common.persistence.model");
|
||||
pc.setMapper("com.ruoyi.app.common.persistence.dao");
|
||||
pc.setXml("com.ruoyi.app.common.persistence.dao.mapping");
|
||||
pc.setService("TTT"); //本项目没用,生成之后删掉
|
||||
pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉
|
||||
pc.setController("TTT"); //本项目没用,生成之后删掉
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
// 执行生成
|
||||
mpg.execute();
|
||||
|
||||
// 打印注入设置
|
||||
System.err.println(mpg.getCfg().getMap().get("abc"));
|
||||
}
|
||||
}
|
||||
//package com.ruoyi.generator;
|
||||
//
|
||||
//
|
||||
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
//import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.DbType;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 自动生成
|
||||
// */
|
||||
//public class EntityGenerator {
|
||||
//
|
||||
// @Test
|
||||
// public void entityGenerator() {
|
||||
// AutoGenerator mpg = new AutoGenerator();
|
||||
//
|
||||
// // 全局配置
|
||||
// GlobalConfig gc = new GlobalConfig();
|
||||
// gc.setOutputDir("E:\\java\\Supply\\ruoyi-api\\src\\main\\java");//这里写你自己的java目录
|
||||
// gc.setFileOverride(true);//是否覆盖
|
||||
// gc.setActiveRecord(true);
|
||||
// gc.setEnableCache(false);// XML 二级缓存
|
||||
// gc.setBaseResultMap(true);// XML ResultMap
|
||||
// gc.setBaseColumnList(false);// XML columList
|
||||
// gc.setAuthor("hupeng");
|
||||
// mpg.setGlobalConfig(gc);
|
||||
//
|
||||
// // 数据源配置
|
||||
// DataSourceConfig dsc = new DataSourceConfig();
|
||||
// dsc.setDbType(DbType.MYSQL);
|
||||
// dsc.setTypeConvert(new MySqlTypeConvert() {
|
||||
// // 自定义数据库表字段类型转换【可选】
|
||||
// @Override
|
||||
// public DbColumnType processTypeConvert(String fieldType) {
|
||||
// return super.processTypeConvert(fieldType);
|
||||
// }
|
||||
// });
|
||||
// dsc.setDriverName("com.mysql.jdbc.Driver");
|
||||
// dsc.setUsername("root");
|
||||
// dsc.setPassword("root");
|
||||
// dsc.setUrl("jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
|
||||
// mpg.setDataSource(dsc);
|
||||
//
|
||||
// // 策略配置
|
||||
// StrategyConfig strategy = new StrategyConfig();
|
||||
// //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||
// strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||
// strategy.setInclude(new String[]{"store_order",});
|
||||
// mpg.setStrategy(strategy);
|
||||
//
|
||||
// // 包配置
|
||||
// PackageConfig pc = new PackageConfig();
|
||||
// pc.setParent(null);
|
||||
// pc.setEntity("com.ruoyi.app.common.persistence.model");
|
||||
// pc.setMapper("com.ruoyi.app.common.persistence.dao");
|
||||
// pc.setXml("com.ruoyi.app.common.persistence.dao.mapping");
|
||||
// pc.setService("TTT"); //本项目没用,生成之后删掉
|
||||
// pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉
|
||||
// pc.setController("TTT"); //本项目没用,生成之后删掉
|
||||
// mpg.setPackageInfo(pc);
|
||||
//
|
||||
// // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
|
||||
// InjectionConfig cfg = new InjectionConfig() {
|
||||
// @Override
|
||||
// public void initMap() {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
|
||||
// this.setMap(map);
|
||||
// }
|
||||
// };
|
||||
// mpg.setCfg(cfg);
|
||||
//
|
||||
// // 执行生成
|
||||
// mpg.execute();
|
||||
//
|
||||
// // 打印注入设置
|
||||
// System.err.println(mpg.getCfg().getMap().get("abc"));
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
package com.ruoyi.plus.test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BaseTest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 com.ruoyi.plus.test;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* spring-boot-plus代码生成器入口类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
|
||||
private static final String USER_NAME = "root";
|
||||
private static final String PASSWORD = "root";
|
||||
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
|
||||
private static final String DRIVER_URL = "jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
|
||||
|
||||
private static final String PARENT_PACKAGE = "com.ruoyi.app";
|
||||
private static final String SUPER_ENTITY = PARENT_PACKAGE + ".common.entity.BaseEntity";
|
||||
private static final String[] SUPER_ENTITY_COMMON_COLUMNS = new String[]{};
|
||||
private static final String SUPER_CONTROLLER = PARENT_PACKAGE + ".common.web.controller.BaseController";
|
||||
private static final String SUPER_SERVICE = PARENT_PACKAGE + ".common.service.BaseService";
|
||||
private static final String SUPER_SERVICE_IMPL = PARENT_PACKAGE + ".common.service.impl.BaseServiceImpl";
|
||||
|
||||
private static final String PROJECT_PACKAGE_PATH = "com/ruoyi/app";
|
||||
|
||||
|
||||
// ############################ 配置部分 start ############################
|
||||
// 模块名称
|
||||
private static final String MODULE_NAME = "distribution";
|
||||
// 作者
|
||||
private static final String AUTHOR = "hupeng";
|
||||
// 生成的表名称
|
||||
private static final String TABLE_NAME = "store_substitute";
|
||||
// 主键数据库列名称
|
||||
private static final String PK_ID_COLUMN_NAME = "id";
|
||||
// 代码生成策略 true:All/false:SIMPLE
|
||||
private static final boolean GENERATOR_STRATEGY = true;
|
||||
// 分页列表查询是否排序 true:有排序参数/false:无
|
||||
private static final boolean PAGE_LIST_ORDER = false;
|
||||
// ############################ 配置部分 end ############################
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
String projectPath = System.getProperty("user.dir");
|
||||
gc.setOutputDir(projectPath + "/ruoyi-api/src/main/java");
|
||||
gc.setAuthor(AUTHOR);
|
||||
gc.setOpen(true); // 是否打开输出目录
|
||||
gc.setSwagger2(true); // 启用swagger注解
|
||||
gc.setIdType(IdType.ID_WORKER); // 主键类型:ID_WORKER
|
||||
gc.setServiceName("%sService"); // 自定义文件命名,注意 %s 会自动填充表实体属性!
|
||||
gc.setFileOverride(true); // 是否覆盖已有文件
|
||||
gc.setDateType(DateType.ONLY_DATE); // 设置日期类型为Date
|
||||
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl(DRIVER_URL);
|
||||
// dsc.setSchemaName("public");
|
||||
dsc.setDriverName(DRIVER_NAME);
|
||||
dsc.setUsername(USER_NAME);
|
||||
dsc.setPassword(PASSWORD);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName(MODULE_NAME);
|
||||
pc.setParent("com.ruoyi.app.modular");
|
||||
pc.setController("web.controller");
|
||||
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 自定义配置
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("customField", "Hello " + this.getConfig().getGlobalConfig().getAuthor());
|
||||
// 查询参数包路径
|
||||
map.put("queryParamPath",PARENT_PACKAGE + StringPool.DOT + pc.getModuleName() + ".web.param." + underlineToPascal(TABLE_NAME) + "QueryParam");
|
||||
// 查询参数共公包路径
|
||||
map.put("queryParamCommonPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "QueryParam");
|
||||
// 查询参数共公包路径
|
||||
map.put("idParamPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "IdParam");
|
||||
// 响应结果包路径
|
||||
map.put("queryVoPath",PARENT_PACKAGE + StringPool.DOT + pc.getModuleName() + ".web.vo." + underlineToPascal(TABLE_NAME) + "QueryVo");
|
||||
// 实体对象名称
|
||||
map.put("entityObjectName",underlineToCamel(TABLE_NAME));
|
||||
// service对象名称
|
||||
map.put("serviceObjectName",underlineToCamel(TABLE_NAME) + "Service");
|
||||
// mapper对象名称
|
||||
map.put("mapperObjectName",underlineToCamel(TABLE_NAME) + "Mapper");
|
||||
// 主键ID列名
|
||||
map.put("pkIdColumnName",PK_ID_COLUMN_NAME);
|
||||
// 主键ID驼峰名称
|
||||
map.put("pkIdCamelName",underlineToCamel(PK_ID_COLUMN_NAME));
|
||||
// 导入分页类
|
||||
map.put("paging",PARENT_PACKAGE + ".common.web.vo.Paging");
|
||||
// 导入排序枚举
|
||||
map.put("orderEnum",PARENT_PACKAGE + ".common.enums.OrderEnum");
|
||||
// 分页列表查询是否排序
|
||||
map.put("pageListOrder",PAGE_LIST_ORDER);
|
||||
// 导入排序查询参数类
|
||||
map.put("orderQueryParamPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "OrderQueryParam");
|
||||
// 代码生成策略
|
||||
map.put("generatorStrategy",GENERATOR_STRATEGY);
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
List<FileOutConfig> focList = new ArrayList<>();
|
||||
focList.add(new FileOutConfig("/templates/mapper.xml.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
// 自定义输入文件名称
|
||||
return projectPath + "/ruoyi-api/src/main/resources/mapper/" + pc.getModuleName()
|
||||
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义queryParam模板
|
||||
focList.add(new FileOutConfig("/templates/queryParam.java.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return projectPath + "/ruoyi-api/src/main/java/"+ PROJECT_PACKAGE_PATH +"/modular/" + pc.getModuleName() + "/web/param/" + tableInfo.getEntityName() + "QueryParam" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义queryVo模板
|
||||
focList.add(new FileOutConfig("/templates/queryVo.java.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return projectPath + "/ruoyi-api/src/main/java/"+ PROJECT_PACKAGE_PATH +"/modular/" + pc.getModuleName() + "/web/vo/" + tableInfo.getEntityName() + "QueryVo" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cfg.setFileOutConfigList(focList);
|
||||
mpg.setCfg(cfg);
|
||||
mpg.setTemplate(new TemplateConfig().setXml(null));
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setSuperEntityClass(SUPER_ENTITY);
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setSuperControllerClass(SUPER_CONTROLLER);
|
||||
strategy.setSuperServiceClass(SUPER_SERVICE);
|
||||
strategy.setSuperServiceImplClass(SUPER_SERVICE_IMPL);
|
||||
strategy.setInclude(TABLE_NAME);
|
||||
strategy.setSuperEntityColumns(SUPER_ENTITY_COMMON_COLUMNS);
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
/**
|
||||
* 注意,根据实际情况,进行设置
|
||||
* 当表名称的前缀和模块名称一样时,会去掉表的前缀
|
||||
* 比如模块名称为user,表明为user_info,则生成的实体名称是Info.java,一定要注意
|
||||
*/
|
||||
//strategy.setTablePrefix(pc.getModuleName() + "_");
|
||||
mpg.setStrategy(strategy);
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
public static String underlineToCamel(String underline){
|
||||
if (StringUtils.isNotBlank(underline)){
|
||||
return NamingStrategy.underlineToCamel(underline);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String underlineToPascal(String underline){
|
||||
if (StringUtils.isNotBlank(underline)){
|
||||
return NamingStrategy.capitalFirst(NamingStrategy.underlineToCamel(underline));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.plus.test;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2019/8/4
|
||||
*/
|
||||
public class IpTest {
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package ${package.Controller};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
#if(${superControllerClassPackage})
|
||||
import ${superControllerClassPackage};
|
||||
#end
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
#end
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
#if(${restControllerStyle})
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
#else
|
||||
import org.springframework.stereotype.Controller;
|
||||
#end
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import ${cfg.paging};
|
||||
import ${cfg.idParamPath};
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Slf4j
|
||||
#if(${restControllerStyle})
|
||||
@RestController
|
||||
#else
|
||||
@Controller
|
||||
#end
|
||||
@RequestMapping("/${cfg.entityObjectName}")
|
||||
@Api("$!{table.comment} API")
|
||||
#if(${kotlin})
|
||||
class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
|
||||
|
||||
#else
|
||||
#if(${superControllerClass})
|
||||
public class ${table.controllerName} extends ${superControllerClass} {
|
||||
#else
|
||||
public class ${table.controllerName} {
|
||||
#end
|
||||
|
||||
@Autowired
|
||||
private ${table.serviceName} ${cfg.serviceObjectName};
|
||||
|
||||
#if(${cfg.generatorStrategy})
|
||||
/**
|
||||
* 添加$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加${entity}对象",notes = "添加$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> add${entity}(@Valid @RequestBody ${entity} ${cfg.entityObjectName}) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.save(${cfg.entityObjectName});
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改${entity}对象",notes = "修改$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> update${entity}(@Valid @RequestBody ${entity} ${cfg.entityObjectName}) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.updateById(${cfg.entityObjectName});
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除${entity}对象",notes = "删除$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> delete${entity}(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取${entity}对象详情",notes = "查看$!{table.comment}",response = ${entity}QueryVo.class)
|
||||
public ApiResult<${entity}QueryVo> get${entity}(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
${entity}QueryVo ${cfg.entityObjectName}QueryVo = ${cfg.serviceObjectName}.get${entity}ById(idParam.getId());
|
||||
return ApiResult.ok(${cfg.entityObjectName}QueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* $!{table.comment}分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取${entity}分页列表",notes = "$!{table.comment}分页列表",response = ${entity}QueryVo.class)
|
||||
public ApiResult<Paging<${entity}QueryVo>> get${entity}PageList(@Valid @RequestBody(required = false) ${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception{
|
||||
Paging<${entity}QueryVo> paging = ${cfg.entityObjectName}Service.get${entity}PageList(${cfg.entityObjectName}QueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
#end
|
||||
@@ -0,0 +1,161 @@
|
||||
package ${package.Entity};
|
||||
|
||||
#foreach($pkg in ${table.importPackages})
|
||||
import ${pkg};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
## import lombok.experimental.Accessors;
|
||||
#end
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment}
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
#if(${superEntityClass})
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
#else
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
#end
|
||||
## @Accessors(chain = true)
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
#if(${swagger2})
|
||||
@ApiModel(value="${entity}对象", description="$!{table.comment}")
|
||||
#end
|
||||
#if(${superEntityClass})
|
||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||
#elseif(${activeRecord})
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
#else
|
||||
public class ${entity} implements Serializable {
|
||||
#end
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
## 自定义属性,是否是主键
|
||||
#set($custom_is_pk=false)
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
@TableId(value = "${field.name}", type = IdType.AUTO)
|
||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
||||
## 设置主键注解
|
||||
@TableId(value = "${field.name}", type = IdType.${idType})
|
||||
## 是主键类型
|
||||
#set($custom_is_pk=true)
|
||||
#elseif(${field.convert})
|
||||
@TableId("${field.name}")
|
||||
#end
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.name}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
#if(${custom_is_pk})
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#else
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
#if(${entityBuilderModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${entityBuilderModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import ${superMapperClassPackage};
|
||||
import ${package.Entity}.${entity};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${kotlin})
|
||||
interface ${table.mapperName} : ${superMapperClass}<${entity}>
|
||||
#else
|
||||
@Repository
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
${entity}QueryVo get${entity}ById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param ${cfg.entityObjectName}QueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<${entity}QueryVo> get${entity}PageList(@Param("page") Page page, @Param("param") ${entity}QueryParam ${cfg.entityObjectName}QueryParam);
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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="${package.Mapper}.${table.mapperName}">
|
||||
|
||||
#if(${enableCache})
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
|
||||
#end
|
||||
#if(${baseResultMap})
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.keyFlag})##生成主键排在第一位
|
||||
<id column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
#foreach($field in ${table.commonFields})##生成公共字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyFlag})##生成普通字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
#end
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
#foreach($field in ${table.commonFields})
|
||||
${field.name},
|
||||
#end
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
<select id="get${entity}ById" resultType="${cfg.queryVoPath}">
|
||||
select <include refid="Base_Column_List"/> from ${table.name} where ${cfg.pkIdColumnName} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="get${entity}PageList" resultType="${cfg.queryVoPath}">
|
||||
select <include refid="Base_Column_List"/> from ${table.name}
|
||||
</select>
|
||||
|
||||
#end
|
||||
</mapper>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.app.${package.ModuleName}.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
#if(${cfg.pageListOrder})
|
||||
import ${cfg.orderQueryParamPath};
|
||||
#else
|
||||
import ${cfg.queryParamCommonPath};
|
||||
#end
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="${entity}QueryParam对象", description="$!{table.comment}查询参数")
|
||||
#if(${cfg.pageListOrder})
|
||||
public class ${entity}QueryParam extends OrderQueryParam {
|
||||
#else
|
||||
public class ${entity}QueryParam extends QueryParam {
|
||||
#end
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ruoyi.app.${package.ModuleName}.web.vo;
|
||||
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
@ApiModel(value="${entity}QueryVo对象", description="$!{table.comment}查询参数")
|
||||
public class ${entity}QueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.name}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
#if(${entityBuilderModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${entityBuilderModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package ${package.Service};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superServiceClassPackage};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import ${cfg.paging};
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${kotlin})
|
||||
interface ${table.serviceName} : ${superServiceClass}<${entity}>
|
||||
#else
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
${entity}QueryVo get${entity}ById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param ${cfg.entityObjectName}QueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<${entity}QueryVo> get${entity}PageList(${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception;
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
@@ -0,0 +1,57 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import ${superServiceImplClassPackage};
|
||||
import ${cfg.paging};
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
#if(${kotlin})
|
||||
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {
|
||||
|
||||
}
|
||||
#else
|
||||
public class ${table.serviceImplName} extends BaseServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
||||
|
||||
@Autowired
|
||||
private ${table.mapperName} ${cfg.mapperObjectName};
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
@Override
|
||||
public ${entity}QueryVo get${entity}ById(Serializable id) throws Exception{
|
||||
return ${cfg.mapperObjectName}.get${entity}ById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<${entity}QueryVo> get${entity}PageList(${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception{
|
||||
Page page = setPageParam(${cfg.entityObjectName}QueryParam,OrderItem.desc("create_time"));
|
||||
IPage<${entity}QueryVo> iPage = ${cfg.mapperObjectName}.get${entity}PageList(page,${cfg.entityObjectName}QueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
Reference in new issue
Block a user