增加对表qs_user_supplier的支持
This commit is contained in:
parent
4fec612e35
commit
8d7ad44e25
@ -1,34 +1,35 @@
|
||||
package net.ferrum.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import net.ferrum.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 用户-供应商关系表
|
||||
* userSupplier对象 qs_user_supplier
|
||||
*
|
||||
* @author 26554
|
||||
* @version 1.0.0
|
||||
* @since 2025-03-05
|
||||
* @author tzx
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
@Data
|
||||
@TableName("qs_user_supplier")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QsUserSupplier {
|
||||
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@TableField
|
||||
private Long userId;
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 供应商主键
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
@TableField
|
||||
private Long supplierId;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
package net.ferrum.business.domain.bo;
|
||||
|
||||
import net.ferrum.common.core.validate.AddGroup;
|
||||
import net.ferrum.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import net.ferrum.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* userSupplier业务对象 qs_user_supplier
|
||||
*
|
||||
* @author tzx
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QsUserSupplierBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@NotNull(message = "ID不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@NotNull(message = "用户ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
@NotNull(message = "供应商ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long supplierId;
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +1,39 @@
|
||||
package net.ferrum.business.mapper;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.ferrum.business.domain.QsSupplier;
|
||||
import net.ferrum.business.domain.QsUserSupplier;
|
||||
import net.ferrum.business.domain.bo.QsSupplierBo;
|
||||
import net.ferrum.business.domain.vo.QsSupplierVo;
|
||||
import net.ferrum.business.domain.vo.QsUserSupplierVo;
|
||||
import net.ferrum.common.core.domain.entity.SysUser;
|
||||
import net.ferrum.common.core.mapper.BaseMapperPlus;
|
||||
import net.ferrum.common.core.page.TableDataInfo;
|
||||
import net.ferrum.common.utils.BeanCopyUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户-供应商关联表 数据层
|
||||
* userSupplierMapper接口
|
||||
*
|
||||
* @author 26554
|
||||
* @version 1.0.0
|
||||
* @since 2025-03-05
|
||||
* @author tzx
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
public interface QsUserSupplierMapper extends BaseMapperPlus<QsUserSupplierMapper, QsUserSupplier, QsUserSupplier> {
|
||||
|
||||
public interface QsUserSupplierMapper extends BaseMapperPlus<QsUserSupplierMapper, QsUserSupplier, QsUserSupplierVo> {
|
||||
|
||||
Page<QsSupplierVo> selectSuppliersByUsersPages(@Param("page") Page<QsSupplierVo> page,@Param("bo")QsSupplierBo bo);
|
||||
//Page<QsSupplierVo> selectSuppliersByUsersPages(@Param("page") Page<QsSupplierVo> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
List<QsUserSupplierVo> selectUsersbySupplierId(@Param("supplierId")Long supplierId);
|
||||
|
||||
@Override
|
||||
default Class<QsUserSupplierMapper> currentMapperClass() {
|
||||
return BaseMapperPlus.super.currentMapperClass();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package net.ferrum.business.service;
|
||||
|
||||
import net.ferrum.business.domain.QsUserSupplier;
|
||||
import net.ferrum.business.domain.bo.QsSupplierBo;
|
||||
import net.ferrum.business.domain.vo.QsSupplierVo;
|
||||
import net.ferrum.business.domain.vo.QsUserSupplierVo;
|
||||
import net.ferrum.business.domain.bo.QsUserSupplierBo;
|
||||
import net.ferrum.common.core.page.TableDataInfo;
|
||||
import net.ferrum.common.core.domain.PageQuery;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* userSupplierService接口
|
||||
*
|
||||
* @author tzx
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
public interface IQsUserSupplierService {
|
||||
|
||||
/**
|
||||
* 查询userSupplier
|
||||
*/
|
||||
QsUserSupplierVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询userSupplier列表
|
||||
*/
|
||||
TableDataInfo<QsUserSupplierVo> queryPageList(QsUserSupplierBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询userSupplier列表
|
||||
*/
|
||||
List<QsUserSupplierVo> queryList(QsUserSupplierBo bo);
|
||||
|
||||
/**
|
||||
* 新增userSupplier
|
||||
*/
|
||||
Boolean insertByBo(QsUserSupplierBo bo);
|
||||
|
||||
/**
|
||||
* 修改userSupplier
|
||||
*/
|
||||
Boolean updateByBo(QsUserSupplierBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除userSupplier信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 查询userSupplier
|
||||
*/
|
||||
TableDataInfo<QsSupplierVo> selectSuppliersByUsersPages(QsSupplierBo bo,PageQuery pageQuery);
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
package net.ferrum.business.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import net.ferrum.business.domain.bo.QsSupplierBo;
|
||||
import net.ferrum.business.domain.vo.QsSupplierVo;
|
||||
import net.ferrum.common.core.page.TableDataInfo;
|
||||
import net.ferrum.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.ferrum.business.domain.bo.QsUserSupplierBo;
|
||||
import net.ferrum.business.domain.vo.QsUserSupplierVo;
|
||||
import net.ferrum.business.domain.QsUserSupplier;
|
||||
import net.ferrum.business.mapper.QsUserSupplierMapper;
|
||||
import net.ferrum.business.service.IQsUserSupplierService;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* userSupplierService业务层处理
|
||||
*
|
||||
* @author tzx
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class QsUserSupplierServiceImpl implements IQsUserSupplierService {
|
||||
|
||||
private final QsUserSupplierMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询userSupplier
|
||||
*/
|
||||
@Override
|
||||
public QsUserSupplierVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询userSupplier列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<QsUserSupplierVo> queryPageList(QsUserSupplierBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<QsUserSupplier> lqw = buildQueryWrapper(bo);
|
||||
Page<QsUserSupplierVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询userSupplier列表
|
||||
*/
|
||||
@Override
|
||||
public List<QsUserSupplierVo> queryList(QsUserSupplierBo bo) {
|
||||
LambdaQueryWrapper<QsUserSupplier> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<QsUserSupplier> buildQueryWrapper(QsUserSupplierBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<QsUserSupplier> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getId() != null, QsUserSupplier::getId, bo.getId());
|
||||
lqw.eq(bo.getUserId() != null, QsUserSupplier::getUserId, bo.getUserId());
|
||||
lqw.eq(bo.getSupplierId() != null, QsUserSupplier::getSupplierId, bo.getSupplierId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增userSupplier
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(QsUserSupplierBo bo) {
|
||||
QsUserSupplier add = BeanUtil.toBean(bo, QsUserSupplier.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改userSupplier
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(QsUserSupplierBo bo) {
|
||||
QsUserSupplier update = BeanUtil.toBean(bo, QsUserSupplier.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(QsUserSupplier entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除userSupplier
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
public TableDataInfo<QsSupplierVo> selectSuppliersByUsersPages(QsSupplierBo bo,PageQuery pageQuery){
|
||||
//return baseMapper.selectSuppliersByUsersPages(bo.getSupplierManager());
|
||||
Page<QsSupplierVo> result = baseMapper.selectSuppliersByUsersPages(pageQuery.build(),bo);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
public List<QsUserSupplierVo> selectUsersbySupplierId(@Param("supplierId")Long supplierId){
|
||||
//return baseMapper.selectSuppliersByUsersPages(bo.getSupplierManager());
|
||||
List<QsUserSupplierVo> result = baseMapper.selectUsersbySupplierId(supplierId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -5,8 +5,51 @@
|
||||
<mapper namespace="net.ferrum.business.mapper.QsUserSupplierMapper">
|
||||
|
||||
<resultMap type="net.ferrum.business.domain.QsUserSupplier" id="QsUserSupplierResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="supplierId" column="supplier_id"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectSuppliersByUsersPages" resultType="net.ferrum.business.domain.vo.QsSupplierVo">
|
||||
<if test="bo.supplierManagers != null and bo.supplierManagers.size() > 0">
|
||||
select distinct qs.supplier_id, qs.supplier_name,qs.supplier_address,qs.supplier_contact,qs.supplier_contact_num,qs.remark
|
||||
from qs_supplier qs, sys_user su,qs_user_supplier qus
|
||||
where qs.supplier_id = qus.supplier_id
|
||||
and su.user_id = qus.user_id
|
||||
and qs.del_flag != '2'
|
||||
and su.del_flag != '2'
|
||||
and(
|
||||
<foreach collection="bo.supplierManagers" item="name" separator=" OR ">su.nick_name LIKE CONCAT('%', #{name}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="bo.supplierManagers == null or bo.supplierManagers.size() == 0">
|
||||
select distinct qs.supplier_id, qs.supplier_name,qs.supplier_address,qs.supplier_contact,qs.supplier_contact_num,qs.remark
|
||||
from qs_supplier qs
|
||||
where qs.del_flag != '2'
|
||||
</if>
|
||||
<if test="bo.supplierName != null and bo.supplierName != ''">
|
||||
AND qs.supplier_name LIKE CONCAT('%', #{bo.supplierName}, '%')
|
||||
</if>
|
||||
<if test="bo.supplierAddress != null and bo.supplierAddress != ''">
|
||||
AND qs.supplier_address LIKE CONCAT('%', #{bo.supplierAddress}, '%')
|
||||
</if>
|
||||
<if test="bo.supplierContact != null and bo.supplierContact != ''">
|
||||
AND qs.supplier_contact LIKE CONCAT('%', #{bo.supplierContact}, '%')
|
||||
</if>
|
||||
<if test="bo.supplierContactNum != null and bo.supplierContactNum != ''">
|
||||
AND qs.supplier_contact_num LIKE CONCAT('%', #{bo.supplierContactNum}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectUsersbySupplierId" resultType="net.ferrum.business.domain.vo.QsUserSupplierVo">
|
||||
select qus.id,qus.user_id,qus.supplier_id,qs.supplier_id, qs.supplier_name,su.user_name,su.nick_name
|
||||
from qs_supplier qs, sys_user su,qs_user_supplier qus
|
||||
where qs.supplier_id = qus.supplier_id
|
||||
and su.user_id = qus.user_id
|
||||
and qs.del_flag != '2'
|
||||
and su.del_flag != '2'
|
||||
and qs.supplier_id = #{supplierId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user