mirror of https://gitee.com/xiaonuobase/snowy
增加菜品的定义
parent
3a9b4d6ead
commit
21e96200d4
|
@ -0,0 +1,19 @@
|
|||
package vip.xiaonuo.common.annotation;
|
||||
|
||||
import vip.xiaonuo.common.enums.ListQueryType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* List查询字段
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ListQueryMethod {
|
||||
|
||||
/**
|
||||
* 日志的名称,例如:"修改菜单"
|
||||
*/
|
||||
ListQueryType value() default ListQueryType.eq;
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package vip.xiaonuo.common.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public enum ListQueryType {
|
||||
eq("eq","=","等于"),
|
||||
ne("ne","<>","不等于"),
|
||||
gt("gt",">","大于"),
|
||||
ge("gt",">=","大于等于"),
|
||||
lt("lt","<","小于"),
|
||||
le("le","<=","小于等于"),
|
||||
between("between","between","在。。。之间"),
|
||||
notBetween("notBetween","cloum between ? and ?","notBetween(“age”,21)"),
|
||||
like("like","cloum like ‘% 王 %’","like(“real_name”,“王”)"),
|
||||
notLike("notLike","not like ‘% 王 %’","notLike(“real_name”,“王”)"),
|
||||
likeLeft("likeLeft","like ‘% 王’","likeLeft(“real_name”,“昭”)"),
|
||||
likeRight("likeRight","like ‘王 %’","likeRight(“real_name”,“昭”)"),
|
||||
isNull("isNull","is null","isNull(“gender”)"),
|
||||
isNotNull("isNotNull","is not null","isNotNull(“gender”)"),
|
||||
in("in","in (1,2,3)","in(“nick_name”,lists)"),
|
||||
notin("notin","notin (1,2,3)","notin(“nick_name”,lists)");
|
||||
|
||||
|
||||
private String code;
|
||||
private String sql;
|
||||
private String describe;
|
||||
ListQueryType(String code,String sql,String describe){
|
||||
this.code = code;
|
||||
this.sql = sql;
|
||||
this.describe = describe;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public void setSql(String sql) {
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
public String getDescribe() {
|
||||
return describe;
|
||||
}
|
||||
|
||||
public void setDescribe(String describe) {
|
||||
this.describe = describe;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package vip.xiaonuo.common.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import vip.xiaonuo.common.annotation.ListQueryMethod;
|
||||
import vip.xiaonuo.common.enums.ListQueryType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Slf4j
|
||||
public class QueryWrapperHelp {
|
||||
|
||||
public static void createQueryCondition(QueryWrapper queryWrapper, Object obj) {
|
||||
try {
|
||||
Method[] methods = obj.getClass().getMethods();
|
||||
for (Method method : methods) {
|
||||
String name = method.getName();
|
||||
if (!name.startsWith("get")) {
|
||||
continue;
|
||||
}
|
||||
Object result = method.invoke(obj, null);
|
||||
if (result == null) {
|
||||
continue;
|
||||
}
|
||||
name = name.replace("get", "");
|
||||
String fildName = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
|
||||
|
||||
Field field = QueryWrapperHelp.getField(obj.getClass(), fildName);
|
||||
if (field == null) {
|
||||
continue;
|
||||
}
|
||||
ListQueryMethod listQueryMethod = field.getAnnotation(ListQueryMethod.class);
|
||||
if (listQueryMethod == null) {
|
||||
continue;
|
||||
}
|
||||
String colName = StrUtil.toUnderlineCase(name);
|
||||
QueryWrapperHelp.setQueryWrapper(queryWrapper, listQueryMethod, colName, result);
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException exception) {
|
||||
log.error(exception.getMessage(), exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得字段
|
||||
*
|
||||
* @param cls
|
||||
* @param fildName
|
||||
* @return
|
||||
*/
|
||||
private static Field getField(Class cls, String fildName) {
|
||||
try {
|
||||
return cls.getDeclaredField(fildName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
}
|
||||
if(cls.getSuperclass()==null){
|
||||
return null;
|
||||
}
|
||||
return QueryWrapperHelp.getField(cls.getSuperclass(),fildName);
|
||||
}
|
||||
|
||||
private static void setQueryWrapper(QueryWrapper queryWrapper, ListQueryMethod listQueryMethod, String colName, Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
Method method = queryWrapper.getClass().getMethod(listQueryMethod.value().getCode(), Object.class, Object.class);
|
||||
method.invoke(queryWrapper, colName, value);
|
||||
}
|
||||
}
|
|
@ -29,38 +29,6 @@ import java.util.Date;
|
|||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WuMerchantInfoAddParam {
|
||||
|
||||
/** 商家名称 */
|
||||
@ApiModelProperty(value = "商家名称", position = 2)
|
||||
private String merchantName;
|
||||
|
||||
/** 商家介绍 */
|
||||
@ApiModelProperty(value = "商家介绍", position = 3)
|
||||
private String introduction;
|
||||
|
||||
/** 联系电话 */
|
||||
@ApiModelProperty(value = "联系电话", position = 4)
|
||||
private String phone;
|
||||
|
||||
/** 开店时间 */
|
||||
@ApiModelProperty(value = "开店时间", position = 5)
|
||||
private Date beginTime;
|
||||
|
||||
/** 下班时间 */
|
||||
@ApiModelProperty(value = "下班时间", position = 6)
|
||||
private Date endTime;
|
||||
|
||||
/** 状态(0正常 1 停用) */
|
||||
@ApiModelProperty(value = "状态(0正常 1 停用)", position = 7)
|
||||
private String status;
|
||||
|
||||
/** 店面地址 */
|
||||
@ApiModelProperty(value = "店面地址", position = 8)
|
||||
private String address;
|
||||
|
||||
/** 更新IP */
|
||||
@ApiModelProperty(value = "更新IP", position = 13)
|
||||
private String updateIp;
|
||||
public class WuMerchantInfoAddParam extends WuMerchantInfoParam{
|
||||
|
||||
}
|
||||
|
|
|
@ -29,42 +29,7 @@ import java.util.Date;
|
|||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WuMerchantInfoEditParam {
|
||||
public class WuMerchantInfoEditParam extends WuMerchantInfoParam{
|
||||
|
||||
/** 商家编号 */
|
||||
@ApiModelProperty(value = "商家编号", required = true, position = 1)
|
||||
private String merchantId;
|
||||
|
||||
/** 商家名称 */
|
||||
@ApiModelProperty(value = "商家名称", position = 2)
|
||||
private String merchantName;
|
||||
|
||||
/** 商家介绍 */
|
||||
@ApiModelProperty(value = "商家介绍", position = 3)
|
||||
private String introduction;
|
||||
|
||||
/** 联系电话 */
|
||||
@ApiModelProperty(value = "联系电话", position = 4)
|
||||
private String phone;
|
||||
|
||||
/** 开店时间 */
|
||||
@ApiModelProperty(value = "开店时间", position = 5)
|
||||
private Date beginTime;
|
||||
|
||||
/** 下班时间 */
|
||||
@ApiModelProperty(value = "下班时间", position = 6)
|
||||
private Date endTime;
|
||||
|
||||
/** 状态(0正常 1 停用) */
|
||||
@ApiModelProperty(value = "状态(0正常 1 停用)", position = 7)
|
||||
private String status;
|
||||
|
||||
/** 店面地址 */
|
||||
@ApiModelProperty(value = "店面地址", position = 8)
|
||||
private String address;
|
||||
|
||||
/** 更新IP */
|
||||
@ApiModelProperty(value = "更新IP", position = 13)
|
||||
private String updateIp;
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Date;
|
|||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WuMerchantInfoPageParam {
|
||||
public class WuMerchantInfoPageParam extends WuMerchantInfoEditParam{
|
||||
|
||||
/** 当前页 */
|
||||
@ApiModelProperty(value = "当前页码")
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.shop.modular.merchant.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import vip.xiaonuo.common.annotation.ListQueryMethod;
|
||||
import vip.xiaonuo.common.enums.ListQueryType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商家信息表编辑参数
|
||||
*
|
||||
* @author cjyu
|
||||
* @date 2023/04/25 11:35
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WuMerchantInfoParam {
|
||||
|
||||
/** 商家编号 */
|
||||
@ApiModelProperty(value = "商家编号", required = true, position = 1)
|
||||
@ListQueryMethod(value = ListQueryType.eq )
|
||||
private String merchantId;
|
||||
|
||||
/** 商家名称 */
|
||||
@ApiModelProperty(value = "商家名称", position = 2)
|
||||
@ListQueryMethod(value = ListQueryType.likeRight )
|
||||
private String merchantName;
|
||||
|
||||
/** 商家介绍 */
|
||||
@ApiModelProperty(value = "商家介绍", position = 3)
|
||||
@ListQueryMethod(value = ListQueryType.like )
|
||||
private String introduction;
|
||||
|
||||
/** 联系电话 */
|
||||
@ApiModelProperty(value = "联系电话", position = 4)
|
||||
@ListQueryMethod(value = ListQueryType.likeRight )
|
||||
private String phone;
|
||||
|
||||
/** 开店时间 */
|
||||
@ApiModelProperty(value = "开店时间", position = 5)
|
||||
@ListQueryMethod(value = ListQueryType.likeRight )
|
||||
private Date beginTime;
|
||||
|
||||
/** 下班时间 */
|
||||
@ApiModelProperty(value = "下班时间", position = 6)
|
||||
private Date endTime;
|
||||
|
||||
/** 状态(0正常 1 停用) */
|
||||
@ApiModelProperty(value = "状态(0正常 1 停用)", position = 7)
|
||||
private String status;
|
||||
|
||||
/** 店面地址 */
|
||||
@ApiModelProperty(value = "店面地址", position = 8)
|
||||
@ListQueryMethod(value = ListQueryType.likeRight )
|
||||
private String address;
|
||||
|
||||
/** 更新IP */
|
||||
@ApiModelProperty(value = "更新IP", position = 13)
|
||||
private String updateIp;
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|||
import vip.xiaonuo.common.enums.CommonSortOrderEnum;
|
||||
import vip.xiaonuo.common.exception.CommonException;
|
||||
import vip.xiaonuo.common.page.CommonPageRequest;
|
||||
import vip.xiaonuo.common.util.QueryWrapperHelp;
|
||||
import vip.xiaonuo.shop.modular.merchant.entity.WuMerchantInfo;
|
||||
import vip.xiaonuo.shop.modular.merchant.mapper.WuMerchantInfoMapper;
|
||||
import vip.xiaonuo.shop.modular.merchant.param.WuMerchantInfoAddParam;
|
||||
|
@ -55,6 +56,9 @@ public class WuMerchantInfoServiceImpl extends ServiceImpl<WuMerchantInfoMapper,
|
|||
} else {
|
||||
queryWrapper.lambda().orderByAsc(WuMerchantInfo::getMerchantId);
|
||||
}
|
||||
log.error("xxxxxxxx");
|
||||
System.out.println("xzzzzzzzzzz");
|
||||
QueryWrapperHelp.createQueryCondition(queryWrapper,wuMerchantInfoPageParam);
|
||||
return this.page(CommonPageRequest.defaultPage(), queryWrapper);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue