修改代码,mybatis->mybatis-plus
parent
a0ed4ee252
commit
8770d9f5f0
|
@ -18,6 +18,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.yulichang</groupId>
|
||||||
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
|
<version>1.4.13</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.firmmanage.domain;
|
package com.muyu.firmmanage.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
@ -19,97 +20,26 @@ import java.util.Date;
|
||||||
* @name:Firm
|
* @name:Firm
|
||||||
* @Date:2024/9/27 12:29
|
* @Date:2024/9/27 12:29
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class Firm extends BaseEntity {
|
public class Firm {
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(00系统用户)
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别(0男 1女 2未知)
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标志(0代表存在 2代表删除)
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业ID
|
* 企业ID
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "firm_id")
|
||||||
private Long firmId;
|
private Long firmId;
|
||||||
/**
|
/**
|
||||||
* 企业名称
|
* 企业名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String firmName;
|
private String firmName;
|
||||||
|
/**
|
||||||
|
* 数据库名称
|
||||||
|
*/
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.muyu.firmmanage.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.muyu.firmmanage.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:SysUser
|
||||||
|
* @Date:2024/9/28 22:37
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@Tag(name = "用户信息")
|
||||||
|
@TableName("sys_user")
|
||||||
|
public class SysUser extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型(00系统用户)
|
||||||
|
*/
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
private String phonenumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户性别(0男 1女 2未知)
|
||||||
|
*/
|
||||||
|
private Integer sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像地址
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帐号状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志(0代表存在 2代表删除)
|
||||||
|
*/
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录IP
|
||||||
|
*/
|
||||||
|
private String loginIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date loginDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库名称
|
||||||
|
*/
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业ID
|
||||||
|
*/
|
||||||
|
private Long firmId;
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String firmName;
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.muyu.firmmanage.domain.resp.firmlist;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.muyu.firmmanage.domain.Firm;
|
import com.muyu.firmmanage.domain.Firm;
|
||||||
|
import com.muyu.firmmanage.domain.SysUser;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -111,23 +112,23 @@ public class FirmListResp {
|
||||||
/**
|
/**
|
||||||
* 数据库对象构建为返回结果对象
|
* 数据库对象构建为返回结果对象
|
||||||
*/
|
*/
|
||||||
public static FirmListResp firmListResp(Firm firm){
|
public static FirmListResp firmListResp(SysUser sysUser){
|
||||||
return FirmListResp.builder()
|
return FirmListResp.builder()
|
||||||
.userId(firm.getUserId())
|
.userId(sysUser.getUserId())
|
||||||
.deptId(firm.getDeptId())
|
.deptId(sysUser.getDeptId())
|
||||||
.userName(firm.getUserName())
|
.userName(sysUser.getUserName())
|
||||||
.nickName(firm.getNickName())
|
.nickName(sysUser.getNickName())
|
||||||
.userType((firm.getUserType()))
|
.userType((sysUser.getUserType()))
|
||||||
.email(firm.getEmail())
|
.email(sysUser.getEmail())
|
||||||
.phonenumber(firm.getPhonenumber())
|
.phonenumber(sysUser.getPhonenumber())
|
||||||
.sex(firm.getSex())
|
.sex(sysUser.getSex())
|
||||||
.avatar(firm.getAvatar())
|
.avatar(sysUser.getAvatar())
|
||||||
.password(firm.getPassword())
|
.password(sysUser.getPassword())
|
||||||
.status(firm.getStatus())
|
.status(sysUser.getStatus())
|
||||||
.delFlag(firm.getDelFlag())
|
.delFlag(sysUser.getDelFlag())
|
||||||
.loginDate(firm.getLoginDate())
|
.loginDate(sysUser.getLoginDate())
|
||||||
.databaseName(firm.getDatabaseName())
|
.databaseName(sysUser.getDatabaseName())
|
||||||
.firmId(firm.getFirmId())
|
.firmId(sysUser.getFirmId())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.muyu.firmmanage.mapper;
|
package com.muyu.firmmanage.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.muyu.firmmanage.domain.Firm;
|
import com.muyu.firmmanage.domain.Firm;
|
||||||
|
import com.muyu.firmmanage.domain.SysUser;
|
||||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ import java.util.List;
|
||||||
* @Date:2024/9/27 12:28
|
* @Date:2024/9/27 12:28
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FirmManageMapper extends BaseMapper<Firm> {
|
public interface FirmManageMapper extends MPJBaseMapper<SysUser> {
|
||||||
|
|
||||||
List<Firm> firmmessageList(FirmListReq firmListReq);
|
List<Firm> firmmessageList(FirmListReq firmListReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.muyu.firmmanage.service;
|
package com.muyu.firmmanage.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.firmmanage.domain.Firm;
|
import com.muyu.firmmanage.domain.SysUser;
|
||||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||||
* @name:FirmManageService
|
* @name:FirmManageService
|
||||||
* @Date:2024/9/27 12:28
|
* @Date:2024/9/27 12:28
|
||||||
*/
|
*/
|
||||||
public interface FirmManageService extends IService<Firm> {
|
public interface FirmManageService extends IService<SysUser> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公司列表信息展示
|
* 公司列表信息展示
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.muyu.firmmanage.service.impl;
|
package com.muyu.firmmanage.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.firmmanage.domain.Firm;
|
import com.muyu.firmmanage.domain.Firm;
|
||||||
|
import com.muyu.firmmanage.domain.SysUser;
|
||||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmListResp;
|
import com.muyu.firmmanage.domain.resp.firmlist.FirmListResp;
|
||||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
||||||
|
@ -22,7 +25,7 @@ import java.util.List;
|
||||||
* @Date:2024/9/27 12:28
|
* @Date:2024/9/27 12:28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper,Firm> implements FirmManageService {
|
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper, SysUser> implements FirmManageService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FirmManageMapper firmManageMapper;
|
private FirmManageMapper firmManageMapper;
|
||||||
|
|
||||||
|
@ -33,15 +36,14 @@ public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper,Firm> im
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FirmTotalListResp firmmessageList(FirmListReq firmListReq) {
|
public FirmTotalListResp firmmessageList(FirmListReq firmListReq) {
|
||||||
LambdaQueryWrapper<Firm> queryWrapper = new LambdaQueryWrapper<>();
|
MPJLambdaWrapper<SysUser> wrapper = new MPJLambdaWrapper<>();
|
||||||
long count = this.count(queryWrapper);
|
wrapper.selectAll(SysUser.class)
|
||||||
int offset=(firmListReq.getPageNum()-1)*firmListReq.getPageSize();
|
.selectAll(Firm.class)
|
||||||
firmListReq.setPageNum(offset);
|
.leftJoin(Firm.class,Firm::getFirmId,SysUser::getFirmId)
|
||||||
List<Firm> list = firmManageMapper.firmmessageList(firmListReq);
|
.eq(StringUtils.isNotEmpty(firmListReq.getFirmName()),
|
||||||
List<FirmListResp> firmListRespList = list.stream()
|
Firm::getFirmName, firmListReq.getFirmName());
|
||||||
.map(FirmListResp::firmListResp)
|
Page<FirmListResp> page = firmManageMapper.selectJoinPage(new Page<>(), FirmListResp.class, wrapper);
|
||||||
.toList();
|
return FirmTotalListResp.firmTotalListResp(page.getRecords(), page.getTotal());
|
||||||
return FirmTotalListResp.firmTotalListResp(firmListRespList, count);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +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="com.muyu.firmmanage.mapper.FirmManageMapper">
|
|
||||||
<resultMap id="FirmListResult" type="com.muyu.firmmanage.domain.Firm">
|
|
||||||
<id property="userId" column="user_id"></id>
|
|
||||||
<result property="deptId" column="dept_id"></result>
|
|
||||||
<result property="userName" column="user_name"></result>
|
|
||||||
<result property="nickName" column="nick_name"></result>
|
|
||||||
<result property="userType" column="user_type"></result>
|
|
||||||
<result property="email" column="email"></result>
|
|
||||||
<result property="phonenumber" column="phonenumber"></result>
|
|
||||||
<result property="sex" column="sex"></result>
|
|
||||||
<result property="avatar" column="avatar"></result>
|
|
||||||
<result property="password" column="password"></result>
|
|
||||||
<result property="status" column="status"></result>
|
|
||||||
<result property="delFlag" column="del_flag"></result>
|
|
||||||
<result property="loginIp" column="login_ip"></result>
|
|
||||||
<result property="loginDate" column="login_date"></result>
|
|
||||||
<result property="databaseName" column="database_name"></result>
|
|
||||||
<result property="firmId" column="firm_id"></result>
|
|
||||||
<result property="firmName" column="firm_name"></result>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectFirmManage">
|
|
||||||
SELECT
|
|
||||||
sys_user.*,
|
|
||||||
firm.*
|
|
||||||
FROM
|
|
||||||
sys_user
|
|
||||||
LEFT JOIN firm ON sys_user.firm_id = firm.firm_id
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="firmmessageList" resultType="com.muyu.firmmanage.domain.Firm">
|
|
||||||
<include refid="selectFirmManage"></include>
|
|
||||||
<where>
|
|
||||||
<if test="firmName!=null and firmName!=''">
|
|
||||||
and firm.firm_name=#{firmName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
limit #{pageNum},#{pageSize}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue