登录
This commit is contained in:
@ -0,0 +1,96 @@
|
|||||||
|
package com.ruoyi.web.controller.bgt;
|
||||||
|
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.domain.model.BgtLoginBody;
|
||||||
|
import com.ruoyi.framework.web.service.BgtLoginService;
|
||||||
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录验证
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class BgtLoginController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private BgtLoginService loginService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录方法
|
||||||
|
*
|
||||||
|
* @param loginBody 登录信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/bgt/login")
|
||||||
|
public AjaxResult login(@RequestBody BgtLoginBody loginBody)
|
||||||
|
{
|
||||||
|
Map<String,Object> ajax = new HashMap<>();
|
||||||
|
// 生成令牌
|
||||||
|
String token = loginService.login(loginBody.getPhone(), loginBody.getPassword(), loginBody.getCode(),
|
||||||
|
loginBody.getUuid());
|
||||||
|
ajax.put(Constants.TOKEN, token);
|
||||||
|
return AjaxResult.success(ajax);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/test")
|
||||||
|
public AjaxResult test(){
|
||||||
|
return AjaxResult.success("test");
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 获取用户信息
|
||||||
|
// *
|
||||||
|
// * @return 用户信息
|
||||||
|
// */
|
||||||
|
// @GetMapping("getInfo")
|
||||||
|
// public AjaxResult getInfo()
|
||||||
|
// {
|
||||||
|
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
// SysUser user = loginUser.getUser();
|
||||||
|
// // 角色集合
|
||||||
|
// Set<String> roles = permissionService.getRolePermission(user);
|
||||||
|
// // 权限集合
|
||||||
|
// Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
|
// Map<String,Object> ajax = new HashMap<>();
|
||||||
|
// ajax.put("user", user);
|
||||||
|
// ajax.put("roles", roles);
|
||||||
|
// ajax.put("permissions", permissions);
|
||||||
|
// return AjaxResult.success(ajax);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 获取路由信息
|
||||||
|
// *
|
||||||
|
// * @return 路由信息
|
||||||
|
// */
|
||||||
|
// @GetMapping("getRouters")
|
||||||
|
// public AjaxResult getRouters()
|
||||||
|
// {
|
||||||
|
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
// // 用户信息
|
||||||
|
// SysUser user = loginUser.getUser();
|
||||||
|
// List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
|
||||||
|
// return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package com.ruoyi.web.controller.bgt;
|
||||||
|
|
||||||
|
import com.ruoyi.bgt.bo.BgtUserQueryBo;
|
||||||
|
import com.ruoyi.bgt.domain.dto.UserRealNameAuthenticationDTO;
|
||||||
|
import com.ruoyi.bgt.service.IBgtUserService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP包工头Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-02-14
|
||||||
|
*/
|
||||||
|
@Api(value = "APP包工头控制器", tags = {"APP包工头管理"})
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bgt/user")
|
||||||
|
public class BgtUserController extends BaseController {
|
||||||
|
|
||||||
|
private final IBgtUserService iBgtUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询APP包工头列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("查询APP包工头列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<BgtUser> list(@Validated BgtUserQueryBo bo) {
|
||||||
|
return iBgtUserService.queryPageList(bo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出APP包工头列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出APP包工头列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:export')")
|
||||||
|
@Log(title = "APP包工头", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public AjaxResult<BgtUser> export(@Validated BgtUserQueryBo bo) {
|
||||||
|
List<BgtUser> list = iBgtUserService.queryList(bo);
|
||||||
|
ExcelUtil<BgtUser> util = new ExcelUtil<BgtUser>(BgtUser.class);
|
||||||
|
return util.exportExcel(list, "APP包工头");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取APP包工头详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取APP包工头详细信息")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:query')")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public AjaxResult<BgtUser> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable("id") String id) {
|
||||||
|
return AjaxResult.success(iBgtUserService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增APP包工头
|
||||||
|
*/
|
||||||
|
@ApiOperation("新增APP包工头")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:add')")
|
||||||
|
@Log(title = "APP包工头", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit
|
||||||
|
@PostMapping()
|
||||||
|
public AjaxResult<Void> add(@Validated @RequestBody BgtUser bo) {
|
||||||
|
return toAjax(iBgtUserService.insert(bo) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改APP包工头
|
||||||
|
*/
|
||||||
|
@ApiOperation("修改APP包工头")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:edit')")
|
||||||
|
@Log(title = "APP包工头", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit
|
||||||
|
@PutMapping()
|
||||||
|
public AjaxResult<Void> edit(@Validated @RequestBody BgtUser bo) {
|
||||||
|
return toAjax(iBgtUserService.update(bo) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除APP包工头
|
||||||
|
*/
|
||||||
|
@ApiOperation("删除APP包工头")
|
||||||
|
@PreAuthorize("@ss.hasPermi('bgt:user:remove')")
|
||||||
|
@Log(title = "APP包工头" , businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable String[] ids) {
|
||||||
|
return toAjax(iBgtUserService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证
|
||||||
|
*/
|
||||||
|
@ApiOperation("实名认证")
|
||||||
|
@Log(title = "APP包工头", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit
|
||||||
|
@PutMapping("/realNameAuthentication")
|
||||||
|
public AjaxResult<Void> realNameAuthentication(@Validated @RequestBody UserRealNameAuthenticationDTO dto) {
|
||||||
|
return toAjax(iBgtUserService.realNameAuthentication(dto));
|
||||||
|
}
|
||||||
|
}
|
@ -136,4 +136,9 @@ public class Constants
|
|||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
public static final String REDIS_LOCK_KEY = "redis_lock:";
|
public static final String REDIS_LOCK_KEY = "redis_lock:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 包工头用户标志 前缀
|
||||||
|
*/
|
||||||
|
public static final String BGT = "bgt_:";
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,157 @@
|
|||||||
|
package com.ruoyi.common.core.domain.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP包工头对象 bgt_user
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-02-14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("bgt_user")
|
||||||
|
@ApiModel("APP包工头视图对象")
|
||||||
|
public class BgtUser 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 username;
|
||||||
|
|
||||||
|
/** 性别(0男 1女 2未知) */
|
||||||
|
@Excel(name = "性别" , readConverterExp = "0=男,1=女,2=未知")
|
||||||
|
@ApiModelProperty("性别(0男 1女 2未知)")
|
||||||
|
private String gender;
|
||||||
|
|
||||||
|
/** 民族 */
|
||||||
|
@Excel(name = "民族")
|
||||||
|
@ApiModelProperty("民族")
|
||||||
|
private String nation;
|
||||||
|
|
||||||
|
/** 出生日期 */
|
||||||
|
@Excel(name = "出生日期")
|
||||||
|
@ApiModelProperty("出生日期")
|
||||||
|
private String birthdate;
|
||||||
|
|
||||||
|
/** 身份证号码 */
|
||||||
|
@Excel(name = "身份证号码")
|
||||||
|
@ApiModelProperty("身份证号码")
|
||||||
|
private String identityCard;
|
||||||
|
|
||||||
|
/** 所在区域 */
|
||||||
|
@Excel(name = "所在区域")
|
||||||
|
@ApiModelProperty("所在区域")
|
||||||
|
private String area;
|
||||||
|
|
||||||
|
/** 地址 */
|
||||||
|
@Excel(name = "地址")
|
||||||
|
@ApiModelProperty("地址")
|
||||||
|
private String site;
|
||||||
|
|
||||||
|
/** 联系电话 */
|
||||||
|
@Excel(name = "联系电话")
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/** 银行 */
|
||||||
|
@Excel(name = "银行")
|
||||||
|
@ApiModelProperty("银行")
|
||||||
|
private String bank;
|
||||||
|
|
||||||
|
/** 银行卡号 */
|
||||||
|
@Excel(name = "银行卡号")
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
/** 头像地址 */
|
||||||
|
@Excel(name = "头像地址")
|
||||||
|
@ApiModelProperty("头像地址")
|
||||||
|
private String avatarName;
|
||||||
|
|
||||||
|
/** 密码 */
|
||||||
|
@Excel(name = "密码")
|
||||||
|
@ApiModelProperty("密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/** 身份证正面图路径 */
|
||||||
|
@Excel(name = "身份证正面图路径")
|
||||||
|
@ApiModelProperty("身份证正面图路径")
|
||||||
|
private String frontPath;
|
||||||
|
|
||||||
|
/** 身份证反面图路径 */
|
||||||
|
@Excel(name = "身份证反面图路径")
|
||||||
|
@ApiModelProperty("身份证反面图路径")
|
||||||
|
private String reverseSidePath;
|
||||||
|
|
||||||
|
/** 银行卡图路径 */
|
||||||
|
@Excel(name = "银行卡图路径")
|
||||||
|
@ApiModelProperty("银行卡图路径")
|
||||||
|
private String bankCardPath;
|
||||||
|
|
||||||
|
/** 帐号状态(0正常 1停用) */
|
||||||
|
@Excel(name = "帐号状态" , readConverterExp = "0=正常,1=停用")
|
||||||
|
@ApiModelProperty("帐号状态(0正常 1停用)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
@Excel(name = "删除标志" , readConverterExp = "0=代表存在,2=代表删除")
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
// @TableLogic
|
||||||
|
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,38 @@
|
|||||||
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class BgtLoginBody
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一标识
|
||||||
|
*/
|
||||||
|
private String uuid = "";
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,9 @@ package com.ruoyi.framework.config;
|
|||||||
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
|
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
|
||||||
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
|
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
|
||||||
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
|
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
|
||||||
|
import com.ruoyi.framework.web.service.AllUserDetailsServiceImpl;
|
||||||
|
import com.ruoyi.framework.web.service.BgtUserDetailsServiceImpl;
|
||||||
|
import com.ruoyi.framework.web.service.UserDetailsServiceImpl;
|
||||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -31,7 +34,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
* 自定义用户认证逻辑
|
* 自定义用户认证逻辑
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserDetailsService userDetailsService;
|
private AllUserDetailsServiceImpl userDetailsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证失败处理类
|
* 认证失败处理类
|
||||||
@ -101,7 +104,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
// 过滤请求
|
// 过滤请求
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录login 验证码captchaImage 允许匿名访问
|
// 对于登录login 验证码captchaImage 允许匿名访问
|
||||||
.antMatchers("/login", "/captchaImage","/demo/tress/all").anonymous()
|
.antMatchers("/login", "/bgt/login", "/captchaImage","/demo/tress/all").anonymous()
|
||||||
.antMatchers(
|
.antMatchers(
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
"/*.html",
|
"/*.html",
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.ruoyi.framework.web.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.enums.UserStatus;
|
||||||
|
import com.ruoyi.common.exception.BaseException;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户验证处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AllUserDetailsServiceImpl implements UserDetailsService
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AllUserDetailsServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserDetailsServiceImpl userDetailsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BgtUserDetailsServiceImpl bgtUserDetailsService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDetails loadUserByUsername(String var) throws UsernameNotFoundException
|
||||||
|
{
|
||||||
|
if(var.contains(Constants.BGT)){
|
||||||
|
var = var.replace(Constants.BGT, "");
|
||||||
|
return bgtUserDetailsService.loadUserByUsername(var);
|
||||||
|
}else {
|
||||||
|
return userDetailsService.loadUserByUsername(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.ruoyi.framework.web.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
|
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||||
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录校验方法
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class BgtLoginService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AuthenticationManager authenticationManager;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private RedisCache redisCache;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsyncService asyncService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录验证
|
||||||
|
*
|
||||||
|
* @param phone 电话
|
||||||
|
* @param password 密码
|
||||||
|
* @param code 验证码
|
||||||
|
* @param uuid 唯一标识
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public String login(String phone, String password, String code, String uuid)
|
||||||
|
{
|
||||||
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
|
// 用户验证
|
||||||
|
Authentication authentication = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||||
|
authentication = authenticationManager
|
||||||
|
.authenticate(new UsernamePasswordAuthenticationToken(Constants.BGT+phone, password));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (e instanceof BadCredentialsException)
|
||||||
|
{
|
||||||
|
asyncService.recordLogininfor(phone, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"), request);
|
||||||
|
throw new UserPasswordNotMatchException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
asyncService.recordLogininfor(phone, Constants.LOGIN_FAIL, e.getMessage(), request);
|
||||||
|
throw new CustomException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asyncService.recordLogininfor(phone, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||||
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
|
// recordLoginInfo(loginUser.getUser());
|
||||||
|
// 生成token
|
||||||
|
return tokenService.createToken(loginUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录登录信息
|
||||||
|
*/
|
||||||
|
public void recordLoginInfo(BgtUser user)
|
||||||
|
{
|
||||||
|
// user.(ServletUtils.getClientIP());
|
||||||
|
// user.setLoginDate(DateUtils.getNowDate());
|
||||||
|
// user.setUpdateBy(user.getUserName());
|
||||||
|
// userService.updateUserProfile(user);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.ruoyi.framework.web.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
|
||||||
|
import com.ruoyi.bgt.service.IBgtUserService;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.enums.UserStatus;
|
||||||
|
import com.ruoyi.common.exception.BaseException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户验证处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BgtUserDetailsServiceImpl implements UserDetailsService
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BgtUserDetailsServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBgtUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDetails loadUserByUsername(String phone) throws UsernameNotFoundException
|
||||||
|
{
|
||||||
|
BgtUser user = userService.selectUserByPhone(phone);
|
||||||
|
if (Validator.isNull(user))
|
||||||
|
{
|
||||||
|
log.info("登录用户:{} 不存在.", phone);
|
||||||
|
throw new UsernameNotFoundException("登录用户:" + phone + " 不存在");
|
||||||
|
}
|
||||||
|
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||||
|
{
|
||||||
|
log.info("登录用户:{} 已被删除.", phone);
|
||||||
|
throw new BaseException("对不起,您的账号:" + phone + " 已被删除");
|
||||||
|
}
|
||||||
|
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||||
|
{
|
||||||
|
log.info("登录用户:{} 已被停用.", phone);
|
||||||
|
throw new BaseException("对不起,您的账号:" + phone + " 已停用");
|
||||||
|
}
|
||||||
|
|
||||||
|
return createLoginUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDetails createLoginUser(BgtUser user)
|
||||||
|
{
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setPhonenumber(user.getPhone());
|
||||||
|
sysUser.setUserId(user.getUserId());
|
||||||
|
sysUser.setUserName(user.getUsername());
|
||||||
|
sysUser.setPassword(user.getPassword());
|
||||||
|
return new LoginUser(sysUser, null);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
36
ruoyi-system/src/main/resources/mapper/bgt/BgtUserMapper.xml
Normal file
36
ruoyi-system/src/main/resources/mapper/bgt/BgtUserMapper.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?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.ruoyi.bgt.mapper.BgtUserMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.common.core.domain.entity.BgtUser" id="BgtUserResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="username" column="username"/>
|
||||||
|
<result property="gender" column="gender"/>
|
||||||
|
<result property="nation" column="nation"/>
|
||||||
|
<result property="birthdate" column="birthdate"/>
|
||||||
|
<result property="identityCard" column="identity_card"/>
|
||||||
|
<result property="area" column="area"/>
|
||||||
|
<result property="site" column="site"/>
|
||||||
|
<result property="phone" column="phone"/>
|
||||||
|
<result property="bank" column="bank"/>
|
||||||
|
<result property="cardNo" column="card_no"/>
|
||||||
|
<result property="avatarName" column="avatar_name"/>
|
||||||
|
<result property="password" column="password"/>
|
||||||
|
<result property="frontPath" column="front_path"/>
|
||||||
|
<result property="reverseSidePath" column="reverse_side_path"/>
|
||||||
|
<result property="bankCardPath" column="bank_card_path"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?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.ruoyi.common.mapper.AnnexMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.common.domain.Annex" id="AnnexResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="annexType" column="annex_type"/>
|
||||||
|
<result property="annexName" column="annex_name"/>
|
||||||
|
<result property="annexUrl" column="annex_url"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user