修改代码,mybatis->mybatis-plus
parent
a0ed4ee252
commit
8770d9f5f0
|
@ -18,6 +18,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.13</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.firmmanage.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
|
@ -19,97 +20,26 @@ import java.util.Date;
|
|||
* @name:Firm
|
||||
* @Date:2024/9/27 12:29
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class Firm extends BaseEntity {
|
||||
/**
|
||||
* 用户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;
|
||||
public class Firm {
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@TableId(value = "firm_id")
|
||||
private Long firmId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
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.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.firmmanage.domain.SysUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
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()
|
||||
.userId(firm.getUserId())
|
||||
.deptId(firm.getDeptId())
|
||||
.userName(firm.getUserName())
|
||||
.nickName(firm.getNickName())
|
||||
.userType((firm.getUserType()))
|
||||
.email(firm.getEmail())
|
||||
.phonenumber(firm.getPhonenumber())
|
||||
.sex(firm.getSex())
|
||||
.avatar(firm.getAvatar())
|
||||
.password(firm.getPassword())
|
||||
.status(firm.getStatus())
|
||||
.delFlag(firm.getDelFlag())
|
||||
.loginDate(firm.getLoginDate())
|
||||
.databaseName(firm.getDatabaseName())
|
||||
.firmId(firm.getFirmId())
|
||||
.userId(sysUser.getUserId())
|
||||
.deptId(sysUser.getDeptId())
|
||||
.userName(sysUser.getUserName())
|
||||
.nickName(sysUser.getNickName())
|
||||
.userType((sysUser.getUserType()))
|
||||
.email(sysUser.getEmail())
|
||||
.phonenumber(sysUser.getPhonenumber())
|
||||
.sex(sysUser.getSex())
|
||||
.avatar(sysUser.getAvatar())
|
||||
.password(sysUser.getPassword())
|
||||
.status(sysUser.getStatus())
|
||||
.delFlag(sysUser.getDelFlag())
|
||||
.loginDate(sysUser.getLoginDate())
|
||||
.databaseName(sysUser.getDatabaseName())
|
||||
.firmId(sysUser.getFirmId())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.firmmanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.firmmanage.domain.SysUser;
|
||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
@ -15,7 +17,7 @@ import java.util.List;
|
|||
* @Date:2024/9/27 12:28
|
||||
*/
|
||||
@Mapper
|
||||
public interface FirmManageMapper extends BaseMapper<Firm> {
|
||||
public interface FirmManageMapper extends MPJBaseMapper<SysUser> {
|
||||
|
||||
List<Firm> firmmessageList(FirmListReq firmListReq);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.muyu.firmmanage.service;
|
||||
|
||||
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.resp.firmlist.FirmTotalListResp;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
* @name:FirmManageService
|
||||
* @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;
|
||||
|
||||
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.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.firmmanage.domain.SysUser;
|
||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmListResp;
|
||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
||||
|
@ -22,7 +25,7 @@ import java.util.List;
|
|||
* @Date:2024/9/27 12:28
|
||||
*/
|
||||
@Service
|
||||
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper,Firm> implements FirmManageService {
|
||||
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper, SysUser> implements FirmManageService {
|
||||
@Autowired
|
||||
private FirmManageMapper firmManageMapper;
|
||||
|
||||
|
@ -33,15 +36,14 @@ public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper,Firm> im
|
|||
*/
|
||||
@Override
|
||||
public FirmTotalListResp firmmessageList(FirmListReq firmListReq) {
|
||||
LambdaQueryWrapper<Firm> queryWrapper = new LambdaQueryWrapper<>();
|
||||
long count = this.count(queryWrapper);
|
||||
int offset=(firmListReq.getPageNum()-1)*firmListReq.getPageSize();
|
||||
firmListReq.setPageNum(offset);
|
||||
List<Firm> list = firmManageMapper.firmmessageList(firmListReq);
|
||||
List<FirmListResp> firmListRespList = list.stream()
|
||||
.map(FirmListResp::firmListResp)
|
||||
.toList();
|
||||
return FirmTotalListResp.firmTotalListResp(firmListRespList, count);
|
||||
MPJLambdaWrapper<SysUser> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(SysUser.class)
|
||||
.selectAll(Firm.class)
|
||||
.leftJoin(Firm.class,Firm::getFirmId,SysUser::getFirmId)
|
||||
.eq(StringUtils.isNotEmpty(firmListReq.getFirmName()),
|
||||
Firm::getFirmName, firmListReq.getFirmName());
|
||||
Page<FirmListResp> page = firmManageMapper.selectJoinPage(new Page<>(), FirmListResp.class, wrapper);
|
||||
return FirmTotalListResp.firmTotalListResp(page.getRecords(), page.getTotal());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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