Compare commits
2 Commits
f75cf55cb2
...
05f6fbe88b
Author | SHA1 | Date | |
---|---|---|---|
05f6fbe88b | |||
6f023b4131 |
@ -1,6 +1,5 @@
|
||||
package com.czsj;
|
||||
|
||||
import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -15,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||
* @author czsj
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class}, scanBasePackages = {"com.czsj","cn.hutool"})
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.czsj","cn.hutool"})
|
||||
@MapperScan(basePackages = {"com.czsj.*.mapper"})
|
||||
@EnableAsync(proxyTargetClass = true)
|
||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||
|
@ -2,6 +2,10 @@ package com.czsj.web.controller.account;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -23,7 +27,7 @@ import com.czsj.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 会员信息Controller
|
||||
*
|
||||
*
|
||||
* @author czsj
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@ -41,9 +45,9 @@ public class CzsjMemberController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CzsjMember czsjMember)
|
||||
{
|
||||
startPage();
|
||||
List<CzsjMember> list = czsjMemberService.selectCzsjMemberList(czsjMember);
|
||||
return getDataTable(list);
|
||||
Page<CzsjMember> page = startPage();
|
||||
IPage<CzsjMember> paged = czsjMemberService.page(page, new QueryWrapper<>(czsjMember));
|
||||
return getDataTable(paged.getRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +58,8 @@ public class CzsjMemberController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CzsjMember czsjMember)
|
||||
{
|
||||
List<CzsjMember> list = czsjMemberService.selectCzsjMemberList(czsjMember);
|
||||
Page<CzsjMember> page = startPage();
|
||||
List<CzsjMember> list = czsjMemberService.page(page, new QueryWrapper<>(czsjMember)).getRecords();
|
||||
ExcelUtil<CzsjMember> util = new ExcelUtil<CzsjMember>(CzsjMember.class);
|
||||
util.exportExcel(response, list, "会员信息数据");
|
||||
}
|
||||
@ -96,9 +101,9 @@ public class CzsjMemberController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('account:member:remove')")
|
||||
@Log(title = "会员信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{uids}")
|
||||
@DeleteMapping("/{uids}")
|
||||
public AjaxResult remove(@PathVariable Long[] uids)
|
||||
{
|
||||
return toAjax(czsjMemberService.deleteCzsjMemberByUids(uids));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
package com.czsj.web.controller.bigdata;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.api.ApiController;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.czsj.common.constant.HttpStatus;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.core.domain.model.LoginUser;
|
||||
@ -52,9 +51,9 @@ public class BaseController extends ApiController
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage()
|
||||
protected Page startPage()
|
||||
{
|
||||
PageUtils.startPage();
|
||||
return PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +65,6 @@ public class BaseController extends ApiController
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||
{
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.orderBy(orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +86,7 @@ public class BaseController extends ApiController
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
rspData.setTotal(list.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
|
@ -173,12 +173,6 @@ mybatis-plus:
|
||||
jdbc-type-for-null: 'null'
|
||||
type-handlers-package: com.czsj.core.handler
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
# 是否开启swagger
|
||||
|
@ -40,7 +40,6 @@
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -130,12 +129,6 @@
|
||||
<artifactId>mybatisplus-spring-boot-starter</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@ -3,12 +3,12 @@ package com.czsj.common.core.controller;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.czsj.common.constant.HttpStatus;
|
||||
import com.czsj.common.core.domain.AjaxResult;
|
||||
import com.czsj.common.core.domain.model.LoginUser;
|
||||
@ -50,9 +50,9 @@ public class BaseController
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage()
|
||||
protected <T> Page startPage()
|
||||
{
|
||||
PageUtils.startPage();
|
||||
return PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +64,6 @@ public class BaseController
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||
{
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.orderBy(orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ public class BaseController
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
rspData.setTotal(list.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
package com.czsj.common.handler;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.czsj.common.core.domain.BaseEntity;
|
||||
import com.czsj.common.core.domain.model.LoginUser;
|
||||
import com.czsj.common.utils.SecurityUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 通用参数填充实现类
|
||||
*
|
||||
* 如果没有显式的对通用参数进行赋值,这里会对通用参数进行填充、赋值
|
||||
*
|
||||
* @author hexiaowu
|
||||
*/
|
||||
public class DefaultDBFieldHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
|
||||
BaseEntity BaseEntity = (BaseEntity) metaObject.getOriginalObject();
|
||||
// 创建时间为空,则以当前时间为插入时间
|
||||
if (Objects.isNull(BaseEntity.getCreateTime())) {
|
||||
BaseEntity.setCreateTime(new Date());
|
||||
}
|
||||
// 更新时间为空,则以当前时间为更新时间
|
||||
if (Objects.isNull(BaseEntity.getUpdateTime())) {
|
||||
BaseEntity.setUpdateTime(new Date());
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
// 当前登录用户不为空,创建人为空,则当前登录用户为创建人
|
||||
if (Objects.nonNull(userId) && Objects.isNull(BaseEntity.getCreateBy())) {
|
||||
BaseEntity.setCreateBy(userId.toString());
|
||||
}
|
||||
// 当前登录用户不为空,更新人为空,则当前登录用户为更新人
|
||||
if (Objects.nonNull(userId) && Objects.isNull(BaseEntity.getUpdateBy())) {
|
||||
BaseEntity.setUpdateBy(userId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// 创建时间为空,则以当前时间为创建时间
|
||||
Object creatTime = getFieldValByName("creatTime", metaObject);
|
||||
if (Objects.isNull(creatTime)) {
|
||||
setFieldValByName("creatTime", new Date(), metaObject);
|
||||
}
|
||||
// 更新时间为空,则以当前时间为更新时间
|
||||
Object modifyTime = getFieldValByName("updateTime", metaObject);
|
||||
if (Objects.isNull(modifyTime)) {
|
||||
setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
|
||||
}
|
||||
Object modifier = getFieldValByName("updateUserId", metaObject);
|
||||
Object creater = getFieldValByName("createUserId", metaObject);
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
if (Objects.nonNull(userId) && Objects.isNull(modifier)) {
|
||||
setFieldValByName("updateUserId", userId.toString(), metaObject);
|
||||
}
|
||||
if (Objects.nonNull(userId) && Objects.isNull(creater)) {
|
||||
setFieldValByName("createUserId", userId.toString(), metaObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
// 更新时间为空,则以当前时间为更新时间
|
||||
Object modifyTime = getFieldValByName("updateTime", metaObject);
|
||||
if (Objects.isNull(modifyTime)) {
|
||||
setFieldValByName("updateTime",new Date(), metaObject);
|
||||
}
|
||||
|
||||
// 当前登录用户不为空,更新人为空,则当前登录用户为更新人
|
||||
Object modifier = getFieldValByName("updateUserId", metaObject);
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long userId = loginUser.getUserId();
|
||||
if (Objects.nonNull(userId) && Objects.isNull(modifier)) {
|
||||
setFieldValByName("updateUserId", userId.toString(), metaObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.czsj.common.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.czsj.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
/**
|
||||
* 通用的字段填充,如createBy createDate这些字段的自动填充
|
||||
*
|
||||
* @author huzekang
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MybatisMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
setFieldValByName("createTime", new Date(), metaObject);
|
||||
setFieldValByName("createBy", getUsername(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
setFieldValByName("updateTime", new Date(), metaObject);
|
||||
setFieldValByName("updateBy", getUsername(), metaObject);
|
||||
}
|
||||
|
||||
private String getCurrentUser() {
|
||||
return SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
package com.czsj.common.interceptor;
|
||||
|
||||
|
||||
|
||||
import com.czsj.common.core.domain.model.LoginUser;
|
||||
import com.czsj.common.utils.SecurityUtils;
|
||||
import com.czsj.common.utils.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.SqlCommandType;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
|
||||
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* mybatis拦截器,自动注入创建人、创建时间、修改人、修改时间
|
||||
* @Author scott
|
||||
* @Date 2019-01-19
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) })
|
||||
public class MybatisInterceptor implements Interceptor {
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
||||
String sqlId = mappedStatement.getId();
|
||||
log.debug("------sqlId------" + sqlId);
|
||||
SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
|
||||
Object parameter = invocation.getArgs()[1];
|
||||
log.debug("------sqlCommandType------" + sqlCommandType);
|
||||
|
||||
if (parameter == null) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
if (SqlCommandType.INSERT == sqlCommandType && SecurityContextHolder.getContext().getAuthentication() != null) {
|
||||
LoginUser sysUser = SecurityUtils.getLoginUser();
|
||||
Field[] fields = oConvertUtils.getAllFields(parameter);
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
if ("createUserId".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateBy = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateBy == null || "".equals(localCreateBy)) {
|
||||
if (sysUser != null) {
|
||||
// 登录人账号
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, sysUser.getUserId());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 注入创建时间
|
||||
if ("createTime".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateDate = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateDate == null || "".equals(localCreateDate)) {
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, new Date());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
if ("updateUserId".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateBy = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateBy == null || "".equals(localCreateBy)) {
|
||||
if (sysUser != null) {
|
||||
// 登录人账号
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, sysUser.getUserId());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 注入更新时间
|
||||
if ("updateTime".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateDate = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateDate == null || "".equals(localCreateDate)) {
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, new Date());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SqlCommandType.UPDATE == sqlCommandType && SecurityContextHolder.getContext().getAuthentication() != null) {
|
||||
LoginUser sysUser = this.getLoginUser();
|
||||
Field[] fields = oConvertUtils.getAllFields(parameter);
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
if ("updateUserId".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateBy = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateBy == null || "".equals(localCreateBy)) {
|
||||
if (sysUser != null) {
|
||||
// 登录人账号
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, sysUser.getUserId());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 注入更新时间
|
||||
if ("updateTime".equals(field.getName())) {
|
||||
field.setAccessible(true);
|
||||
Object localCreateDate = field.get(parameter);
|
||||
field.setAccessible(false);
|
||||
if (localCreateDate == null || "".equals(localCreateDate)) {
|
||||
field.setAccessible(true);
|
||||
field.set(parameter, new Date());
|
||||
field.setAccessible(false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户
|
||||
* @return
|
||||
*/
|
||||
private LoginUser getLoginUser() {
|
||||
LoginUser sysUser ;
|
||||
try {
|
||||
sysUser = SecurityUtils.getLoginUser();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sysUser = null;
|
||||
}
|
||||
return sysUser;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.czsj.common.utils;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.czsj.common.core.page.PageDomain;
|
||||
import com.czsj.common.core.page.TableSupport;
|
||||
import com.czsj.common.utils.sql.SqlUtil;
|
||||
@ -10,19 +12,23 @@ import com.czsj.common.utils.sql.SqlUtil;
|
||||
*
|
||||
* @author czsj
|
||||
*/
|
||||
public class PageUtils extends PageHelper
|
||||
public class PageUtils
|
||||
{
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
public static void startPage()
|
||||
public static <T> Page startPage()
|
||||
{
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
Boolean reasonable = pageDomain.getReasonable();
|
||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
||||
Page<T> page = new Page<>();
|
||||
page.setCurrent(pageDomain.getPageNum());
|
||||
page.setSize(pageDomain.getPageSize());
|
||||
if ("asc".equals(pageDomain.getIsAsc())){
|
||||
page.addOrder(OrderItem.asc(pageDomain.getOrderByColumn()));
|
||||
}else {
|
||||
page.addOrder(OrderItem.desc(pageDomain.getOrderByColumn()));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,6 +36,5 @@ public class PageUtils extends PageHelper
|
||||
*/
|
||||
public static void clearPage()
|
||||
{
|
||||
PageHelper.clearPage();
|
||||
}
|
||||
}
|
||||
|
@ -96,13 +96,13 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-core</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -112,7 +112,7 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,132 +0,0 @@
|
||||
package com.czsj.framework.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.ibatis.io.VFS;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import com.czsj.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Mybatis支持*匹配扫描包
|
||||
*
|
||||
* @author czsj
|
||||
*/
|
||||
@Configuration
|
||||
public class MyBatisConfig
|
||||
{
|
||||
// @Autowired
|
||||
// private Environment env;
|
||||
//
|
||||
// static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
|
||||
//
|
||||
// public static String setTypeAliasesPackage(String typeAliasesPackage)
|
||||
// {
|
||||
// ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
|
||||
// MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
|
||||
// List<String> allResult = new ArrayList<String>();
|
||||
// try
|
||||
// {
|
||||
// for (String aliasesPackage : typeAliasesPackage.split(","))
|
||||
// {
|
||||
// List<String> result = new ArrayList<String>();
|
||||
// aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
|
||||
// + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
|
||||
// Resource[] resources = resolver.getResources(aliasesPackage);
|
||||
// if (resources != null && resources.length > 0)
|
||||
// {
|
||||
// MetadataReader metadataReader = null;
|
||||
// for (Resource resource : resources)
|
||||
// {
|
||||
// if (resource.isReadable())
|
||||
// {
|
||||
// metadataReader = metadataReaderFactory.getMetadataReader(resource);
|
||||
// try
|
||||
// {
|
||||
// result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
|
||||
// }
|
||||
// catch (ClassNotFoundException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (result.size() > 0)
|
||||
// {
|
||||
// HashSet<String> hashResult = new HashSet<String>(result);
|
||||
// allResult.addAll(hashResult);
|
||||
// }
|
||||
// }
|
||||
// if (allResult.size() > 0)
|
||||
// {
|
||||
// typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
|
||||
// }
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return typeAliasesPackage;
|
||||
// }
|
||||
//
|
||||
// public Resource[] resolveMapperLocations(String[] mapperLocations)
|
||||
// {
|
||||
// ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
|
||||
// List<Resource> resources = new ArrayList<Resource>();
|
||||
// if (mapperLocations != null)
|
||||
// {
|
||||
// for (String mapperLocation : mapperLocations)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Resource[] mappers = resourceResolver.getResources(mapperLocation);
|
||||
// resources.addAll(Arrays.asList(mappers));
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// // ignore
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return resources.toArray(new Resource[resources.size()]);
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
|
||||
// {
|
||||
// String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
|
||||
// String mapperLocations = env.getProperty("mybatis.mapperLocations");
|
||||
// String configLocation = env.getProperty("mybatis.configLocation");
|
||||
// typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
|
||||
// VFS.addImplClass(SpringBootVFS.class);
|
||||
//
|
||||
// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
// sessionFactory.setDataSource(dataSource);
|
||||
// sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
|
||||
// sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
|
||||
// sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
||||
// return sessionFactory.getObject();
|
||||
// }
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.czsj.framework.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.czsj.common.handler.DefaultDBFieldHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* Mybatis Plus 配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@Configuration
|
||||
public class MybatisPlusConfig
|
||||
{
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor()
|
||||
{
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 分页插件
|
||||
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||
// 乐观锁插件
|
||||
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
|
||||
// 阻断插件
|
||||
interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
|
||||
*/
|
||||
public PaginationInnerInterceptor paginationInnerInterceptor()
|
||||
{
|
||||
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
|
||||
// 设置数据库类型为mysql
|
||||
paginationInnerInterceptor.setDbType(DbType.MYSQL);
|
||||
// 设置最大单页限制数量,默认 500 条,-1 不受限制
|
||||
paginationInnerInterceptor.setMaxLimit(-1L);
|
||||
return paginationInnerInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html
|
||||
*/
|
||||
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor()
|
||||
{
|
||||
return new OptimisticLockerInnerInterceptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html
|
||||
*/
|
||||
public BlockAttackInnerInterceptor blockAttackInnerInterceptor()
|
||||
{
|
||||
return new BlockAttackInnerInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MetaObjectHandler defaultMetaObjectHandler() {
|
||||
return new DefaultDBFieldHandler(); // 自动填充参数类
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
<version>3.4.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@ -103,7 +103,7 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.czsj.account.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.czsj.common.annotation.Excel;
|
||||
@ -13,7 +18,11 @@ import com.czsj.common.core.domain.BaseEntity;
|
||||
* @author czsj
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public class CzsjMember extends BaseEntity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TableName("czsj_member")
|
||||
public class CzsjMember
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -88,208 +97,18 @@ public class CzsjMember extends BaseEntity
|
||||
|
||||
/** 创建人ID */
|
||||
@Excel(name = "创建人ID")
|
||||
private Long createUserId;
|
||||
private Long createBy;
|
||||
|
||||
/** 修改人ID */
|
||||
@Excel(name = "修改人ID")
|
||||
private Long updateUserId;
|
||||
private Long updateBy;
|
||||
|
||||
public void setUid(Long uid)
|
||||
{
|
||||
this.uid = uid;
|
||||
}
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
public Long getUid()
|
||||
{
|
||||
return uid;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setBirthday(String birthday)
|
||||
{
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getBirthday()
|
||||
{
|
||||
return birthday;
|
||||
}
|
||||
public void setSex(Integer sex)
|
||||
{
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public Integer getSex()
|
||||
{
|
||||
return sex;
|
||||
}
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
public void setAddress(String address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
public void setPhone(String phone)
|
||||
{
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
}
|
||||
public void setMemberId(Long memberId)
|
||||
{
|
||||
this.memberId = memberId;
|
||||
}
|
||||
|
||||
public Long getMemberId()
|
||||
{
|
||||
return memberId;
|
||||
}
|
||||
public void setMemberLevel(Long memberLevel)
|
||||
{
|
||||
this.memberLevel = memberLevel;
|
||||
}
|
||||
|
||||
public Long getMemberLevel()
|
||||
{
|
||||
return memberLevel;
|
||||
}
|
||||
public void setCity(String city)
|
||||
{
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCity()
|
||||
{
|
||||
return city;
|
||||
}
|
||||
public void setArea(String area)
|
||||
{
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public String getArea()
|
||||
{
|
||||
return area;
|
||||
}
|
||||
public void setSource(String source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
public void setLogoutTime(Date logoutTime)
|
||||
{
|
||||
this.logoutTime = logoutTime;
|
||||
}
|
||||
|
||||
public Date getLogoutTime()
|
||||
{
|
||||
return logoutTime;
|
||||
}
|
||||
public void setFreezeTime(Date freezeTime)
|
||||
{
|
||||
this.freezeTime = freezeTime;
|
||||
}
|
||||
|
||||
public Date getFreezeTime()
|
||||
{
|
||||
return freezeTime;
|
||||
}
|
||||
public void setCardTime(Date cardTime)
|
||||
{
|
||||
this.cardTime = cardTime;
|
||||
}
|
||||
|
||||
public Date getCardTime()
|
||||
{
|
||||
return cardTime;
|
||||
}
|
||||
public void setDelFlag(Integer delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setCreateUserId(Long createUserId)
|
||||
{
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Long getCreateUserId()
|
||||
{
|
||||
return createUserId;
|
||||
}
|
||||
public void setUpdateUserId(Long updateUserId)
|
||||
{
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId()
|
||||
{
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uid", getUid())
|
||||
.append("name", getName())
|
||||
.append("birthday", getBirthday())
|
||||
.append("sex", getSex())
|
||||
.append("email", getEmail())
|
||||
.append("address", getAddress())
|
||||
.append("phone", getPhone())
|
||||
.append("memberId", getMemberId())
|
||||
.append("memberLevel", getMemberLevel())
|
||||
.append("city", getCity())
|
||||
.append("area", getArea())
|
||||
.append("source", getSource())
|
||||
.append("status", getStatus())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("logoutTime", getLogoutTime())
|
||||
.append("freezeTime", getFreezeTime())
|
||||
.append("cardTime", getCardTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createUserId", getCreateUserId())
|
||||
.append("updateUserId", getUpdateUserId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.czsj.account.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.czsj.account.domain.CzsjMember;
|
||||
|
||||
/**
|
||||
@ -9,7 +11,7 @@ import com.czsj.account.domain.CzsjMember;
|
||||
* @author czsj
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface CzsjMemberMapper
|
||||
public interface CzsjMemberMapper extends BaseMapper<CzsjMember>
|
||||
{
|
||||
/**
|
||||
* 查询会员信息
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.czsj.account.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.czsj.account.domain.CzsjMember;
|
||||
|
||||
/**
|
||||
@ -9,7 +12,7 @@ import com.czsj.account.domain.CzsjMember;
|
||||
* @author czsj
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface ICzsjMemberService
|
||||
public interface ICzsjMemberService extends IService<CzsjMember>
|
||||
{
|
||||
/**
|
||||
* 查询会员信息
|
||||
@ -25,7 +28,7 @@ public interface ICzsjMemberService
|
||||
* @param czsjMember 会员信息
|
||||
* @return 会员信息集合
|
||||
*/
|
||||
public List<CzsjMember> selectCzsjMemberList(CzsjMember czsjMember);
|
||||
public List<CzsjMember> selectCzsjMemberList(Page page, CzsjMember czsjMember);
|
||||
|
||||
/**
|
||||
* 新增会员信息
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.czsj.account.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.czsj.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -15,7 +19,7 @@ import com.czsj.account.service.ICzsjMemberService;
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Service
|
||||
public class CzsjMemberServiceImpl implements ICzsjMemberService
|
||||
public class CzsjMemberServiceImpl extends ServiceImpl<CzsjMemberMapper, CzsjMember> implements ICzsjMemberService
|
||||
{
|
||||
@Autowired
|
||||
private CzsjMemberMapper czsjMemberMapper;
|
||||
@ -32,6 +36,8 @@ public class CzsjMemberServiceImpl implements ICzsjMemberService
|
||||
return czsjMemberMapper.selectCzsjMemberByUid(uid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询会员信息列表
|
||||
*
|
||||
@ -39,8 +45,10 @@ public class CzsjMemberServiceImpl implements ICzsjMemberService
|
||||
* @return 会员信息
|
||||
*/
|
||||
@Override
|
||||
public List<CzsjMember> selectCzsjMemberList(CzsjMember czsjMember)
|
||||
public List<CzsjMember> selectCzsjMemberList(Page page,CzsjMember czsjMember)
|
||||
{
|
||||
|
||||
|
||||
return czsjMemberMapper.selectCzsjMemberList(czsjMember);
|
||||
}
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
package com.czsj.bigdata.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: czsj
|
||||
* @Date: 2022/9/16 11:14
|
||||
* @Description:
|
||||
**/
|
||||
@EnableTransactionManagement
|
||||
@Configuration
|
||||
@MapperScan("com.czsj.bigdata.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
return paginationInterceptor.setOverflow(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* MyBatisPlus逻辑删除 ,需要在 yml 中配置开启
|
||||
* 3.0.7.1版本的LogicSqlInjector里面什么都没做只是 extends DefaultSqlInjector
|
||||
* 以后版本直接去的了LogicSqlInjector
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new DefaultSqlInjector();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user