登录
This commit is contained in:
		@ -0,0 +1,94 @@
 | 
			
		||||
package com.ruoyi.bgt.bo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.core.domain.BaseEntity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * APP包工头分页查询对象 bgt_user
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ApiModel("APP包工头分页查询对象")
 | 
			
		||||
public class BgtUserQueryBo extends BaseEntity {
 | 
			
		||||
 | 
			
		||||
	/** 分页大小 */
 | 
			
		||||
	@ApiModelProperty("分页大小")
 | 
			
		||||
	private Integer pageSize;
 | 
			
		||||
	/** 当前页数 */
 | 
			
		||||
	@ApiModelProperty("当前页数")
 | 
			
		||||
	private Integer pageNum;
 | 
			
		||||
	/** 排序列 */
 | 
			
		||||
	@ApiModelProperty("排序列")
 | 
			
		||||
	private String orderByColumn;
 | 
			
		||||
	/** 排序的方向desc或者asc */
 | 
			
		||||
	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
 | 
			
		||||
	private String isAsc;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/** 唯一标识 */
 | 
			
		||||
	@ApiModelProperty("唯一标识")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
	/** 姓名 */
 | 
			
		||||
	@ApiModelProperty("姓名")
 | 
			
		||||
	private String username;
 | 
			
		||||
	/** 性别(0男 1女 2未知) */
 | 
			
		||||
	@ApiModelProperty("性别(0男 1女 2未知)")
 | 
			
		||||
	private String gender;
 | 
			
		||||
	/** 民族 */
 | 
			
		||||
	@ApiModelProperty("民族")
 | 
			
		||||
	private String nation;
 | 
			
		||||
	/** 出生日期 */
 | 
			
		||||
	@ApiModelProperty("出生日期")
 | 
			
		||||
	private String birthdate;
 | 
			
		||||
	/** 身份证号码 */
 | 
			
		||||
	@ApiModelProperty("身份证号码")
 | 
			
		||||
	private String identityCard;
 | 
			
		||||
	/** 所在区域 */
 | 
			
		||||
	@ApiModelProperty("所在区域")
 | 
			
		||||
	private String area;
 | 
			
		||||
	/** 地址 */
 | 
			
		||||
	@ApiModelProperty("地址")
 | 
			
		||||
	private String site;
 | 
			
		||||
	/** 联系电话 */
 | 
			
		||||
	@ApiModelProperty("联系电话")
 | 
			
		||||
	private String phone;
 | 
			
		||||
	/** 银行 */
 | 
			
		||||
	@ApiModelProperty("银行")
 | 
			
		||||
	private String bank;
 | 
			
		||||
	/** 银行卡号 */
 | 
			
		||||
	@ApiModelProperty("银行卡号")
 | 
			
		||||
	private String cardNo;
 | 
			
		||||
	/** 头像地址 */
 | 
			
		||||
	@ApiModelProperty("头像地址")
 | 
			
		||||
	private String avatarName;
 | 
			
		||||
	/** 密码 */
 | 
			
		||||
	@ApiModelProperty("密码")
 | 
			
		||||
	private String password;
 | 
			
		||||
	/** 身份证正面图路径 */
 | 
			
		||||
	@ApiModelProperty("身份证正面图路径")
 | 
			
		||||
	private String frontPath;
 | 
			
		||||
	/** 身份证反面图路径 */
 | 
			
		||||
	@ApiModelProperty("身份证反面图路径")
 | 
			
		||||
	private String reverseSidePath;
 | 
			
		||||
	/** 银行卡图路径 */
 | 
			
		||||
	@ApiModelProperty("银行卡图路径")
 | 
			
		||||
	private String bankCardPath;
 | 
			
		||||
	/** 帐号状态(0正常 1停用) */
 | 
			
		||||
	@ApiModelProperty("帐号状态(0正常 1停用)")
 | 
			
		||||
	private String status;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,40 @@
 | 
			
		||||
package com.ruoyi.bgt.domain.dto;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户登录对象
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel("包工头实名认证对象")
 | 
			
		||||
public class LoginBodyDto
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * 手机号
 | 
			
		||||
     */
 | 
			
		||||
    private String phone;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户密码
 | 
			
		||||
     */
 | 
			
		||||
    private String password;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 验证码
 | 
			
		||||
     */
 | 
			
		||||
    private String code;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 唯一标识
 | 
			
		||||
     */
 | 
			
		||||
    private String uuid = "";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,72 @@
 | 
			
		||||
package com.ruoyi.bgt.domain.dto;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.domain.dto.AnnexDTO;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotBlank;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用户实名认证对象
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel("包工头实名认证对象")
 | 
			
		||||
public class UserRealNameAuthenticationDTO {
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty("主键")
 | 
			
		||||
	@NotBlank(message = "主键不能为空")
 | 
			
		||||
	private String id;
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty("姓名")
 | 
			
		||||
	@NotBlank(message = "姓名不能为空")
 | 
			
		||||
	private String username;
 | 
			
		||||
	/** 性别(0男 1女 2未知) */
 | 
			
		||||
	@ApiModelProperty("性别(0男 1女 2未知)")
 | 
			
		||||
	@NotBlank(message = "性别不能为空")
 | 
			
		||||
	private String gender;
 | 
			
		||||
	/** 民族 */
 | 
			
		||||
	@ApiModelProperty("民族")
 | 
			
		||||
	@NotBlank(message = "民族不能为空")
 | 
			
		||||
	private String nation;
 | 
			
		||||
	/** 出生日期 */
 | 
			
		||||
	@ApiModelProperty("出生日期")
 | 
			
		||||
	@NotBlank(message = "出生日期不能为空")
 | 
			
		||||
	private String birthdate;
 | 
			
		||||
	/** 身份证号码 */
 | 
			
		||||
	@ApiModelProperty("身份证号码")
 | 
			
		||||
	@NotBlank(message = "身份证号码不能为空")
 | 
			
		||||
	private String identityCard;
 | 
			
		||||
	/** 所在区域 */
 | 
			
		||||
	@ApiModelProperty("所在区域")
 | 
			
		||||
	@NotBlank(message = "所在区域不能为空")
 | 
			
		||||
	private String area;
 | 
			
		||||
	/** 地址 */
 | 
			
		||||
	@ApiModelProperty("地址")
 | 
			
		||||
	@NotBlank(message = "地址不能为空")
 | 
			
		||||
	private String site;
 | 
			
		||||
	/** 联系电话 */
 | 
			
		||||
	@ApiModelProperty("联系电话")
 | 
			
		||||
	@NotBlank(message = "联系电话不能为空")
 | 
			
		||||
	private String phone;
 | 
			
		||||
	/** 银行 */
 | 
			
		||||
	@ApiModelProperty("银行")
 | 
			
		||||
	@NotBlank(message = "银行不能为空")
 | 
			
		||||
	private String bank;
 | 
			
		||||
	/** 银行卡号 */
 | 
			
		||||
	@ApiModelProperty("银行卡号")
 | 
			
		||||
	@NotBlank(message = "银行卡号不能为空")
 | 
			
		||||
	private String cardNo;
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty("资格证书")
 | 
			
		||||
	List<AnnexDTO> annexList;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,18 @@
 | 
			
		||||
package com.ruoyi.bgt.mapper;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.BgtUser;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
 | 
			
		||||
import org.apache.ibatis.annotations.CacheNamespace;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * APP包工头Mapper接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
// 如使需切换数据源 请勿使用缓存 会造成数据不一致现象
 | 
			
		||||
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
 | 
			
		||||
public interface BgtUserMapper extends BaseMapperPlus<BgtUser> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,74 @@
 | 
			
		||||
package com.ruoyi.bgt.service;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.bgt.bo.BgtUserQueryBo;
 | 
			
		||||
import com.ruoyi.bgt.domain.dto.UserRealNameAuthenticationDTO;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.BgtUser;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * APP包工头Service接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
public interface IBgtUserService extends IServicePlus<BgtUser> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询单个
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    BgtUser queryById(String id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    TableDataInfo<BgtUser> queryPageList(BgtUserQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    List<BgtUser> queryList(BgtUserQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据新增业务对象插入APP包工头
 | 
			
		||||
     * @param bo APP包工头新增业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean insert(BgtUser bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据编辑业务对象修改APP包工头
 | 
			
		||||
     * @param bo APP包工头编辑业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean update(BgtUser bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验并删除数据
 | 
			
		||||
     * @param ids 主键集合
 | 
			
		||||
     * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 通过电话查询用户
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param phone 电话
 | 
			
		||||
	 * @return 用户对象信息
 | 
			
		||||
	 */
 | 
			
		||||
	BgtUser selectUserByPhone(String phone);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 实名认证
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean realNameAuthentication(@Validated @RequestBody UserRealNameAuthenticationDTO dto);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,111 @@
 | 
			
		||||
package com.ruoyi.bgt.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.ruoyi.bgt.domain.dto.UserRealNameAuthenticationDTO;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.BgtUser;
 | 
			
		||||
import com.ruoyi.common.utils.PageUtils;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
			
		||||
import com.ruoyi.bgt.bo.BgtUserQueryBo;
 | 
			
		||||
import com.ruoyi.bgt.mapper.BgtUserMapper;
 | 
			
		||||
import com.ruoyi.bgt.service.IBgtUserService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * APP包工头Service业务层处理
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class BgtUserServiceImpl extends ServicePlusImpl<BgtUserMapper, BgtUser> implements IBgtUserService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public BgtUser queryById(String id){
 | 
			
		||||
        return getById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TableDataInfo<BgtUser> queryPageList(BgtUserQueryBo bo) {
 | 
			
		||||
        Page<BgtUser> result = page(PageUtils.buildPage(), buildQueryWrapper(bo));
 | 
			
		||||
        return PageUtils.buildDataInfo(result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<BgtUser> queryList(BgtUserQueryBo bo) {
 | 
			
		||||
        return list(buildQueryWrapper(bo));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private LambdaQueryWrapper<BgtUser> buildQueryWrapper(BgtUserQueryBo bo) {
 | 
			
		||||
        Map<String, Object> params = bo.getParams();
 | 
			
		||||
        LambdaQueryWrapper<BgtUser> lqw = Wrappers.lambdaQuery();
 | 
			
		||||
        lqw.eq(bo.getUserId() != null, BgtUser::getUserId, bo.getUserId());
 | 
			
		||||
        lqw.like(StrUtil.isNotBlank(bo.getUsername()), BgtUser::getUsername, bo.getUsername());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getGender()), BgtUser::getGender, bo.getGender());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getNation()), BgtUser::getNation, bo.getNation());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getBirthdate()), BgtUser::getBirthdate, bo.getBirthdate());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getIdentityCard()), BgtUser::getIdentityCard, bo.getIdentityCard());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getArea()), BgtUser::getArea, bo.getArea());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getSite()), BgtUser::getSite, bo.getSite());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getPhone()), BgtUser::getPhone, bo.getPhone());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getBank()), BgtUser::getBank, bo.getBank());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getCardNo()), BgtUser::getCardNo, bo.getCardNo());
 | 
			
		||||
        lqw.like(StrUtil.isNotBlank(bo.getAvatarName()), BgtUser::getAvatarName, bo.getAvatarName());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getPassword()), BgtUser::getPassword, bo.getPassword());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getFrontPath()), BgtUser::getFrontPath, bo.getFrontPath());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getReverseSidePath()), BgtUser::getReverseSidePath, bo.getReverseSidePath());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getBankCardPath()), BgtUser::getBankCardPath, bo.getBankCardPath());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getStatus()), BgtUser::getStatus, bo.getStatus());
 | 
			
		||||
        return lqw;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean insert(BgtUser bo) {
 | 
			
		||||
        BgtUser add = BeanUtil.toBean(bo, BgtUser.class);
 | 
			
		||||
        validEntityBeforeSave(add);
 | 
			
		||||
        return save(add);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean update(BgtUser bo) {
 | 
			
		||||
        BgtUser update = BeanUtil.toBean(bo, BgtUser.class);
 | 
			
		||||
        validEntityBeforeSave(update);
 | 
			
		||||
        return updateById(update);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 保存前的数据校验
 | 
			
		||||
     *
 | 
			
		||||
     * @param entity 实体类数据
 | 
			
		||||
     */
 | 
			
		||||
    private void validEntityBeforeSave(BgtUser entity){
 | 
			
		||||
        //TODO 做一些数据校验,如唯一约束
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
 | 
			
		||||
        if(isValid){
 | 
			
		||||
            //TODO 做一些业务上的校验,判断是否需要校验
 | 
			
		||||
        }
 | 
			
		||||
        return removeByIds(ids);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public BgtUser selectUserByPhone(String phone) {
 | 
			
		||||
		return baseMapper.selectOne(new LambdaQueryWrapper<BgtUser>().eq(BgtUser::getPhone, phone));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Boolean realNameAuthentication(UserRealNameAuthenticationDTO dto) {
 | 
			
		||||
		BgtUser bgtUser = BeanUtil.copyProperties(dto, BgtUser.class);
 | 
			
		||||
		return baseMapper.updateById(bgtUser)>0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,55 @@
 | 
			
		||||
package com.ruoyi.common.bo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.core.domain.BaseEntity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件分页查询对象 common_annex
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ApiModel("附件分页查询对象")
 | 
			
		||||
public class AnnexQueryBo extends BaseEntity {
 | 
			
		||||
 | 
			
		||||
	/** 分页大小 */
 | 
			
		||||
	@ApiModelProperty("分页大小")
 | 
			
		||||
	private Integer pageSize;
 | 
			
		||||
	/** 当前页数 */
 | 
			
		||||
	@ApiModelProperty("当前页数")
 | 
			
		||||
	private Integer pageNum;
 | 
			
		||||
	/** 排序列 */
 | 
			
		||||
	@ApiModelProperty("排序列")
 | 
			
		||||
	private String orderByColumn;
 | 
			
		||||
	/** 排序的方向desc或者asc */
 | 
			
		||||
	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
 | 
			
		||||
	private String isAsc;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/** 唯一标识 */
 | 
			
		||||
	@ApiModelProperty("唯一标识")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
	/** 附件类型 */
 | 
			
		||||
	@ApiModelProperty("附件类型")
 | 
			
		||||
	private String annexType;
 | 
			
		||||
	/** 附件名 */
 | 
			
		||||
	@ApiModelProperty("附件名")
 | 
			
		||||
	private String annexName;
 | 
			
		||||
	/** 附件地址 */
 | 
			
		||||
	@ApiModelProperty("附件地址")
 | 
			
		||||
	private String annexUrl;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,108 @@
 | 
			
		||||
package com.ruoyi.common.controller;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.domain.Annex;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import javax.validation.constraints.*;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import com.ruoyi.common.annotation.RepeatSubmit;
 | 
			
		||||
import com.ruoyi.common.annotation.Log;
 | 
			
		||||
import com.ruoyi.common.core.controller.BaseController;
 | 
			
		||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
			
		||||
import com.ruoyi.common.enums.BusinessType;
 | 
			
		||||
import com.ruoyi.common.bo.AnnexQueryBo;
 | 
			
		||||
import com.ruoyi.common.service.IAnnexService;
 | 
			
		||||
import com.ruoyi.common.utils.poi.ExcelUtil;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件Controller
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
@Api(value = "附件控制器", tags = {"附件管理"})
 | 
			
		||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/common/annex")
 | 
			
		||||
public class AnnexController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    private final IAnnexService iAnnexService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询附件列表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("查询附件列表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:list')")
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    public TableDataInfo<Annex> list(@Validated AnnexQueryBo bo) {
 | 
			
		||||
        return iAnnexService.queryPageList(bo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 导出附件列表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("导出附件列表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:export')")
 | 
			
		||||
    @Log(title = "附件", businessType = BusinessType.EXPORT)
 | 
			
		||||
    @GetMapping("/export")
 | 
			
		||||
    public AjaxResult<Annex> export(@Validated AnnexQueryBo bo) {
 | 
			
		||||
        List<Annex> list = iAnnexService.queryList(bo);
 | 
			
		||||
        ExcelUtil<Annex> util = new ExcelUtil<Annex>(Annex.class);
 | 
			
		||||
        return util.exportExcel(list, "附件");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取附件详细信息
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("获取附件详细信息")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:query')")
 | 
			
		||||
    @GetMapping("/{id}")
 | 
			
		||||
    public AjaxResult<Annex> getInfo(@NotNull(message = "主键不能为空")
 | 
			
		||||
                                                  @PathVariable("id") String id) {
 | 
			
		||||
        return AjaxResult.success(iAnnexService.queryById(id));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增附件
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("新增附件")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:add')")
 | 
			
		||||
    @Log(title = "附件", businessType = BusinessType.INSERT)
 | 
			
		||||
    @RepeatSubmit
 | 
			
		||||
    @PostMapping()
 | 
			
		||||
    public AjaxResult<Void> add(@Validated @RequestBody Annex bo) {
 | 
			
		||||
        return toAjax(iAnnexService.insert(bo) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改附件
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("修改附件")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:edit')")
 | 
			
		||||
    @Log(title = "附件", businessType = BusinessType.UPDATE)
 | 
			
		||||
    @RepeatSubmit
 | 
			
		||||
    @PutMapping()
 | 
			
		||||
    public AjaxResult<Void> edit(@Validated @RequestBody Annex bo) {
 | 
			
		||||
        return toAjax(iAnnexService.update(bo) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除附件
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("删除附件")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('common:annex:remove')")
 | 
			
		||||
    @Log(title = "附件" , businessType = BusinessType.DELETE)
 | 
			
		||||
    @DeleteMapping("/{ids}")
 | 
			
		||||
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
 | 
			
		||||
                                       @PathVariable String[] ids) {
 | 
			
		||||
        return toAjax(iAnnexService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,93 @@
 | 
			
		||||
package com.ruoyi.common.domain;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.annotation.Excel;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.*;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件对象 common_annex
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@TableName("common_annex")
 | 
			
		||||
@ApiModel("附件视图对象")
 | 
			
		||||
public class Annex implements Serializable {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID=1L;
 | 
			
		||||
 | 
			
		||||
    /** 主键ID */
 | 
			
		||||
    @ApiModelProperty("主键ID")
 | 
			
		||||
    @TableId(value = "id")
 | 
			
		||||
    private String id;
 | 
			
		||||
 | 
			
		||||
    /** 唯一标识 */
 | 
			
		||||
    @Excel(name = "唯一标识")
 | 
			
		||||
    @ApiModelProperty("唯一标识")
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
    /** 附件类型 */
 | 
			
		||||
    @Excel(name = "附件类型")
 | 
			
		||||
    @ApiModelProperty("附件类型")
 | 
			
		||||
    private String annexType;
 | 
			
		||||
 | 
			
		||||
    /** 附件名 */
 | 
			
		||||
    @Excel(name = "附件名")
 | 
			
		||||
    @ApiModelProperty("附件名")
 | 
			
		||||
    private String annexName;
 | 
			
		||||
 | 
			
		||||
    /** 附件地址 */
 | 
			
		||||
    @Excel(name = "附件地址")
 | 
			
		||||
    @ApiModelProperty("附件地址")
 | 
			
		||||
    private String annexUrl;
 | 
			
		||||
 | 
			
		||||
    /** 删除标志(0代表存在 2代表删除) */
 | 
			
		||||
    @Excel(name = "删除标志" , readConverterExp = "0=代表存在,2=代表删除")
 | 
			
		||||
    @ApiModelProperty("删除标志(0代表存在 2代表删除)")
 | 
			
		||||
    private String delFlag;
 | 
			
		||||
 | 
			
		||||
    /** 创建者 */
 | 
			
		||||
    @Excel(name = "创建者")
 | 
			
		||||
    @ApiModelProperty("创建者")
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT)
 | 
			
		||||
    private String createBy;
 | 
			
		||||
 | 
			
		||||
    /** 创建时间 */
 | 
			
		||||
    @Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
    @ApiModelProperty("创建时间")
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT)
 | 
			
		||||
    private LocalDateTime createTime;
 | 
			
		||||
 | 
			
		||||
    /** 更新者 */
 | 
			
		||||
    @Excel(name = "更新者")
 | 
			
		||||
    @ApiModelProperty("更新者")
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT_UPDATE)
 | 
			
		||||
    private String updateBy;
 | 
			
		||||
 | 
			
		||||
    /** 更新时间 */
 | 
			
		||||
    @Excel(name = "更新时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
    @ApiModelProperty("更新时间")
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT_UPDATE)
 | 
			
		||||
    private LocalDateTime updateTime;
 | 
			
		||||
 | 
			
		||||
    /** 备注 */
 | 
			
		||||
    @Excel(name = "备注")
 | 
			
		||||
    @ApiModelProperty("备注")
 | 
			
		||||
    private String remark;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,33 @@
 | 
			
		||||
package com.ruoyi.common.domain.dto;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件对象
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel("附件对象")
 | 
			
		||||
public class AnnexDTO {
 | 
			
		||||
 | 
			
		||||
	/** 唯一标识 */
 | 
			
		||||
	@ApiModelProperty("唯一标识")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
	/** 附件类型 */
 | 
			
		||||
	@ApiModelProperty("附件类型")
 | 
			
		||||
	private String annexType;
 | 
			
		||||
	/** 附件名 */
 | 
			
		||||
	@ApiModelProperty("附件名")
 | 
			
		||||
	private String annexName;
 | 
			
		||||
	/** 附件地址 */
 | 
			
		||||
	@ApiModelProperty("附件地址")
 | 
			
		||||
	private String annexUrl;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,18 @@
 | 
			
		||||
package com.ruoyi.common.mapper;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.domain.Annex;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
 | 
			
		||||
import org.apache.ibatis.annotations.CacheNamespace;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件Mapper接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
// 如使需切换数据源 请勿使用缓存 会造成数据不一致现象
 | 
			
		||||
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
 | 
			
		||||
public interface AnnexMapper extends BaseMapperPlus<Annex> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,55 @@
 | 
			
		||||
package com.ruoyi.common.service;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.domain.Annex;
 | 
			
		||||
import com.ruoyi.common.bo.AnnexQueryBo;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件Service接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
public interface IAnnexService extends IServicePlus<Annex> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询单个
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Annex queryById(String id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    TableDataInfo<Annex> queryPageList(AnnexQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    List<Annex> queryList(AnnexQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据新增业务对象插入附件
 | 
			
		||||
     * @param bo 附件新增业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean insert(Annex bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据编辑业务对象修改附件
 | 
			
		||||
     * @param bo 附件编辑业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean update(Annex bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验并删除数据
 | 
			
		||||
     * @param ids 主键集合
 | 
			
		||||
     * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,87 @@
 | 
			
		||||
package com.ruoyi.common.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.ruoyi.common.utils.PageUtils;
 | 
			
		||||
import com.ruoyi.common.core.page.PagePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
			
		||||
import com.ruoyi.common.bo.AnnexQueryBo;
 | 
			
		||||
import com.ruoyi.common.domain.Annex;
 | 
			
		||||
import com.ruoyi.common.mapper.AnnexMapper;
 | 
			
		||||
import com.ruoyi.common.service.IAnnexService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 附件Service业务层处理
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-02-14
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class AnnexServiceImpl extends ServicePlusImpl<AnnexMapper, Annex> implements IAnnexService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Annex queryById(String id){
 | 
			
		||||
        return getById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TableDataInfo<Annex> queryPageList(AnnexQueryBo bo) {
 | 
			
		||||
        Page<Annex> result = page(PageUtils.buildPage(), buildQueryWrapper(bo));
 | 
			
		||||
        return PageUtils.buildDataInfo(result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Annex> queryList(AnnexQueryBo bo) {
 | 
			
		||||
        return list(buildQueryWrapper(bo));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private LambdaQueryWrapper<Annex> buildQueryWrapper(AnnexQueryBo bo) {
 | 
			
		||||
        Map<String, Object> params = bo.getParams();
 | 
			
		||||
        LambdaQueryWrapper<Annex> lqw = Wrappers.lambdaQuery();
 | 
			
		||||
        lqw.eq(bo.getUserId() != null, Annex::getUserId, bo.getUserId());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getAnnexType()), Annex::getAnnexType, bo.getAnnexType());
 | 
			
		||||
        lqw.like(StrUtil.isNotBlank(bo.getAnnexName()), Annex::getAnnexName, bo.getAnnexName());
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(bo.getAnnexUrl()), Annex::getAnnexUrl, bo.getAnnexUrl());
 | 
			
		||||
        return lqw;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean insert(Annex bo) {
 | 
			
		||||
        Annex add = BeanUtil.toBean(bo, Annex.class);
 | 
			
		||||
        validEntityBeforeSave(add);
 | 
			
		||||
        return save(add);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean update(Annex bo) {
 | 
			
		||||
        Annex update = BeanUtil.toBean(bo, Annex.class);
 | 
			
		||||
        validEntityBeforeSave(update);
 | 
			
		||||
        return updateById(update);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 保存前的数据校验
 | 
			
		||||
     *
 | 
			
		||||
     * @param entity 实体类数据
 | 
			
		||||
     */
 | 
			
		||||
    private void validEntityBeforeSave(Annex entity){
 | 
			
		||||
        //TODO 做一些数据校验,如唯一约束
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
 | 
			
		||||
        if(isValid){
 | 
			
		||||
            //TODO 做一些业务上的校验,判断是否需要校验
 | 
			
		||||
        }
 | 
			
		||||
        return removeByIds(ids);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user