修改代码生成
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package org.nl.common;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 6:33 下午
|
||||
*/
|
||||
@Data
|
||||
public class BaseQuery<T> {
|
||||
|
||||
|
||||
private String blurry;
|
||||
|
||||
private String isUsed;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
private String sort;
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer size;
|
||||
|
||||
public QueryWrapper<T> convertQ(){
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
||||
json.forEach(new BiConsumer<String, Object>() {
|
||||
@Override
|
||||
public void accept(String s, Object o) {
|
||||
if (o instanceof Collection){
|
||||
wrapper.in(s,(Collection)o);
|
||||
}else {
|
||||
wrapper.eq(s,o);
|
||||
}
|
||||
wrapper.orderByAsc(true, String.valueOf(o));
|
||||
|
||||
}
|
||||
});
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.nl.common;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:40 下午
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LConsumer<X,Y,Z> {
|
||||
|
||||
void accept(X x,Y y,Z z);
|
||||
|
||||
default LConsumer<X,Y,Z> andThen(LConsumer<? super X, ? super Y, ? super Z> after) {
|
||||
Objects.requireNonNull(after);
|
||||
|
||||
return (x, y, z) -> {
|
||||
accept(x, y, z);
|
||||
after.accept(x, y, z);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.common;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:26 下午
|
||||
*/
|
||||
public enum QueryType {
|
||||
EQ((q, k, v) -> { q.eq(k,v); }),
|
||||
IN((q, k, v) -> { q.in(k,v); }),
|
||||
LK((q, k, v) -> { q.eq(k,v); });
|
||||
private LConsumer<QueryWrapper,String, Object[]> doP;
|
||||
|
||||
QueryType(LConsumer<QueryWrapper,String, Object[]> doP) {
|
||||
this.doP = doP;
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,8 @@ public class CodeGenerator {
|
||||
gc.setOpen(false);
|
||||
// gc.setSwagger2(true);
|
||||
gc.setEntityName("%s");
|
||||
gc.setServiceName("%sService");
|
||||
gc.setServiceImplName("%sServiceImpl");
|
||||
gc.setServiceName("I%sService");
|
||||
gc.setServiceImplName("I%sServiceImpl");
|
||||
mpg.setGlobalConfig(gc);
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
@@ -91,7 +91,7 @@ public class CodeGenerator {
|
||||
// strategy.setSuperEntityColumns("id");
|
||||
strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
|
||||
strategy.setControllerMappingHyphenStyle(false);
|
||||
strategy.setTablePrefix("sys_");
|
||||
// strategy.setTablePrefix("sys_");
|
||||
mpg.setStrategy(strategy);
|
||||
// mpg.setTemplateEngine(new FreemarkerTemplateEngine());
|
||||
mpg.execute();
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.Properties;
|
||||
* @Description: redis---Spring Boot 对象转换 MapStruct
|
||||
* @Date: 2022-08-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface RedisConvert {
|
||||
|
||||
RedisConvert INSTANCE = Mappers.getMapper(RedisConvert.class);
|
||||
|
||||
@@ -30,12 +30,6 @@ import java.util.Set;
|
||||
@Data
|
||||
public class UserQueryCriteria implements Serializable {
|
||||
|
||||
@Query
|
||||
private Long id;
|
||||
|
||||
@Query(propName = "id", type = Query.Type.IN, joinName = "dept")
|
||||
private Set<Long> deptIds = new HashSet<>();
|
||||
|
||||
@Query(blurry = "email,username,nickName")
|
||||
private String blurry;
|
||||
|
||||
@@ -43,7 +37,7 @@ public class UserQueryCriteria implements Serializable {
|
||||
|
||||
private String is_used;
|
||||
|
||||
private Long deptId;
|
||||
|
||||
|
||||
private Date startTime;
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.DictDetail;
|
||||
import org.nl.modules.system.service.dto.DictDetailDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = {DictSmallMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface DictDetailMapper extends BaseMapper<DictDetailDto, DictDetail> {
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.service.dto.DictDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface DictMapper extends BaseMapper<DictDto, Dict> {
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.service.dto.DictSmallDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface DictSmallMapper extends BaseMapper<DictSmallDto, Dict> {
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.Menu;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-17
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface MenuMapper extends BaseMapper<MenuDto, Menu> {
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.service.dto.RoleDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
*/
|
||||
@Mapper(componentModel = "spring", uses = {MenuMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface RoleMapper extends BaseMapper<RoleDto, Role> {
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* 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 org.nl.modules.system.service.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.service.dto.RoleSmallDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-5-23
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface RoleSmallMapper extends BaseMapper<RoleSmallDto, Role> {
|
||||
|
||||
}
|
||||
@@ -18,8 +18,10 @@ package org.nl.system.controller.user;
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -33,6 +35,7 @@ import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.nl.system.service.user.UserService;
|
||||
import org.nl.system.service.user.dao.User;
|
||||
import org.nl.system.service.user.dto.UserQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -41,7 +44,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -56,12 +61,30 @@ public class UserController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
public static void main(String[] args) {
|
||||
UserQuery query = new UserQuery();
|
||||
query.setDeptId(123L);
|
||||
query.setBlurry("zzddfd");
|
||||
QueryWrapper<User> userQueryWrapper = query.convertQ();
|
||||
|
||||
System.out.println(userQueryWrapper);
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@GetMapping
|
||||
// @SaCheckPermission("user:list")
|
||||
public ResponseEntity<Object> query(UserQueryCriteria criteria, Page pageable){
|
||||
Page page = userService.page(pageable);
|
||||
return new ResponseEntity<>(page,HttpStatus.OK);
|
||||
public ResponseEntity<Object> query(UserQuery query){
|
||||
QueryWrapper<User> query1 = new QueryWrapper<User>();
|
||||
UpdateWrapper<User> wrapper = new UpdateWrapper<>();
|
||||
|
||||
// query1.allEq(new BiPredicate<String, Object>() {
|
||||
// @Override
|
||||
// public boolean test(String s, Object o) {
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
// Page page = userService.page(new Page<>(query.getPage(),query.getSize()),)
|
||||
return new ResponseEntity<>(null,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增用户")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.system.service.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.nl.common.BaseQuery;
|
||||
import org.nl.system.service.user.dao.User;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 6:35 下午
|
||||
*/
|
||||
@Data
|
||||
public class UserQuery extends BaseQuery<User> {
|
||||
|
||||
private Set<Long> deptIds;
|
||||
|
||||
private Long deptId;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.nl.system.controller.dept;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
public class DeptController {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.nl.system.service.dept;
|
||||
|
||||
import org.nl.system.service.dept.dao.Dept;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
public interface DeptService extends IService<Dept> {
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.nl.system.service.dept.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_dept")
|
||||
public class Dept implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "dept_id", type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 上级部门
|
||||
*/
|
||||
private Long pid;
|
||||
|
||||
/**
|
||||
* 子部门数目
|
||||
*/
|
||||
private Integer subCount;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer deptSort;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String isUsed;
|
||||
|
||||
private Long createId;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
private Long updateOptid;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateOptname;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 部门编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
private String extId;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.nl.system.service.dept.dao.mapper;
|
||||
|
||||
import org.nl.system.service.dept.dao.Dept;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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="org.nl.system.service.dept.dao.mapper.DeptMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,20 +0,0 @@
|
||||
package org.nl.system.service.dept.impl;
|
||||
|
||||
import org.nl.system.service.dept.dao.Dept;
|
||||
import org.nl.system.service.dept.dao.mapper.DeptMapper;
|
||||
import org.nl.system.service.dept.DeptService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Service
|
||||
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements DeptService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user