diff --git a/pom.xml b/pom.xml index 1106ce0..31ad4c8 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,6 @@ - org.springframework.boot diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java new file mode 100644 index 0000000..726bdeb --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzAppController.java @@ -0,0 +1,54 @@ +package com.ruoyi.web.controller.wgz.controller; + + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wgz.bo.req.WgzAppUserLongInReq; +import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq; +import com.ruoyi.wgz.bo.res.WgzAppUserLongInRes; +import com.ruoyi.wgz.service.IWgzUserService; +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.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * APP务工者Controller + * + * @author ruoyi + * @date 2025-02-14 + */ +@Api(value = "APP务工者接口", tags = {"APP务工者接口管理"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController + +@RequestMapping("/wgz/app") +public class WgzAppController { + + private final IWgzUserService iWgzUserService; + + + /** + * 查询PC务工者列表 + */ + @ApiOperation("APP务工者注册") + @PreAuthorize("@ss.hasPermi('wgzApp:user:register')") + @PostMapping("/wgzRegister") + public AjaxResult userRegister(@Validated WgzAppUserRegisterReq bo) { + return AjaxResult.success(iWgzUserService.userRegister(bo)); + } + + /** + * 查询PC务工者列表 + */ + @ApiOperation("APP务工者登录") + @PreAuthorize("@ss.hasPermi('wgzApp:user:userLongIn')") + @PostMapping("/wgzLongIn") + public AjaxResult userLongIn(@Validated WgzAppUserLongInReq bo) { + return AjaxResult.success(iWgzUserService.userLongIn(bo)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzUserController.java new file mode 100644 index 0000000..6c7122e --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wgz/controller/WgzUserController.java @@ -0,0 +1,109 @@ +package com.ruoyi.web.controller.wgz.controller; + +import java.util.List; +import java.util.Arrays; + +import com.ruoyi.wgz.domain.WgzUser; +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.wgz.bo.WgzUserQueryBo; +import com.ruoyi.wgz.service.IWgzUserService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +/** + * PC务工者Controller + * + * @author ruoyi + * @date 2025-02-14 + */ +@Api(value = "PC务工者控制器", tags = {"PC务工者管理"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController + +@RequestMapping("/wgz/user") +public class WgzUserController extends BaseController { + + private final IWgzUserService iWgzUserService; + + /** + * 查询PC务工者列表 + */ + @ApiOperation("查询PC务工者列表") + @PreAuthorize("@ss.hasPermi('wgz:user:list')") + @GetMapping("/list") + public TableDataInfo list(@Validated WgzUserQueryBo bo) { + return iWgzUserService.queryPageList(bo); + } + + /** + * 导出PC务工者列表 + */ + @ApiOperation("导出PC务工者列表") + @PreAuthorize("@ss.hasPermi('wgz:user:export')") + @Log(title = "PC务工者", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(@Validated WgzUserQueryBo bo) { + List list = iWgzUserService.queryList(bo); + ExcelUtil util = new ExcelUtil(WgzUser.class); + return util.exportExcel(list, "PC务工者"); + } + + /** + * 获取PC务工者详细信息 + */ + @ApiOperation("获取PC务工者详细信息") + @PreAuthorize("@ss.hasPermi('wgz:user:query')") + @GetMapping("/{id}") + public AjaxResult getInfo(@NotNull(message = "主键不能为空") + @PathVariable("id") String id) { + return AjaxResult.success(iWgzUserService.queryById(id)); + } + + /** + * 新增PC务工者 + */ + @ApiOperation("新增PC务工者") + @PreAuthorize("@ss.hasPermi('wgz:user:add')") + @Log(title = "PC务工者", businessType = BusinessType.INSERT) + @RepeatSubmit + @PostMapping() + public AjaxResult add(@Validated @RequestBody WgzUser bo) { + return toAjax(iWgzUserService.insert(bo) ? 1 : 0); + } + + /** + * 修改PC务工者 + */ + @ApiOperation("修改PC务工者") + @PreAuthorize("@ss.hasPermi('wgz:user:edit')") + @Log(title = "PC务工者", businessType = BusinessType.UPDATE) + @RepeatSubmit + @PutMapping() + public AjaxResult edit(@Validated @RequestBody WgzUser bo) { + return toAjax(iWgzUserService.update(bo) ? 1 : 0); + } + + /** + * 删除PC务工者 + */ + @ApiOperation("删除PC务工者") + @PreAuthorize("@ss.hasPermi('wgz:user:remove')") + @Log(title = "PC务工者" , businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@NotEmpty(message = "主键不能为空") + @PathVariable String[] ids) { + return toAjax(iWgzUserService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); + } +} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index e2cbd39..45e7aa4 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -17,6 +17,11 @@ + + cn.hutool + hutool-all + + org.springframework @@ -88,7 +93,10 @@ javax.servlet javax.servlet-api - + + com.ruoyi + ruoyi-framework + com.baomidou mybatis-plus-boot-starter diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/WgzUserQueryBo.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/WgzUserQueryBo.java new file mode 100644 index 0000000..8382d91 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/WgzUserQueryBo.java @@ -0,0 +1,64 @@ +package com.ruoyi.wgz.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务工者分页查询对象 wgz_user + * + * @author ruoyi + * @date 2025-02-14 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("APP务工者分页查询对象") +public class WgzUserQueryBo 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; + /** 出生日期 */ + @ApiModelProperty("出生日期") + private String birthdate; + /** 身份证号码 */ + @ApiModelProperty("身份证号码") + private String identityCard; + /** 联系电话 */ + @ApiModelProperty("联系电话") + private String phone; + /** 银行卡号 */ + @ApiModelProperty("银行卡号") + private String cardNo; + /** 帐号状态(0正常 1停用) */ + @ApiModelProperty("帐号状态(0正常 1停用)") + private String status; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserLongInReq.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserLongInReq.java new file mode 100644 index 0000000..a8a6811 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserLongInReq.java @@ -0,0 +1,24 @@ +package com.ruoyi.wgz.bo.req; + +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.Pattern; + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("务工者APP注册账号对象") +public class WgzAppUserLongInReq extends BaseEntity { + @ApiModelProperty("联系电话") + @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确") + private String phone; + + @ApiModelProperty("密码") + private String password; + + @ApiModelProperty("验证码") + private String verificationCode; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserRegisterReq.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserRegisterReq.java new file mode 100644 index 0000000..a1c3480 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/req/WgzAppUserRegisterReq.java @@ -0,0 +1,22 @@ +package com.ruoyi.wgz.bo.req; + +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.Pattern; + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("务工者APP注册账号对象") +public class WgzAppUserRegisterReq extends BaseEntity { + @ApiModelProperty("联系电话") + @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确") + private String phone; + + /** 密码 */ + @ApiModelProperty("密码") + private String password; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppUserLongInRes.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppUserLongInRes.java new file mode 100644 index 0000000..94ac126 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/bo/res/WgzAppUserLongInRes.java @@ -0,0 +1,4 @@ +package com.ruoyi.wgz.bo.res; + +public class WgzAppUserLongInRes { +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/common/SnowflakeIdUtil.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/common/SnowflakeIdUtil.java new file mode 100644 index 0000000..7c45f57 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/common/SnowflakeIdUtil.java @@ -0,0 +1,27 @@ +package com.ruoyi.wgz.common; + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; + +/** + * 雪花 ID 生成工具类 + */ +public class SnowflakeIdUtil { + // 定义静态的 Snowflake 实例 + private static final Snowflake snowflake; + + // 静态代码块,在类加载时初始化 Snowflake 实例 + static { + // 这里的数据中心 ID 和机器 ID 可以根据实际情况进行配置 + // 此处假设数据中心 ID 为 1,机器 ID 为 1 + snowflake = IdUtil.createSnowflake(1, 1); + } + + /** + * 生成雪花 ID 的静态方法 + * @return 生成的雪花 ID + */ + public static long generateId() { + return snowflake.nextId(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzUser.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzUser.java new file mode 100644 index 0000000..5cf7024 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzUser.java @@ -0,0 +1,159 @@ +package com.ruoyi.wgz.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; + +/** + * APP务工者对象 wgz_user + * + * @author ruoyi + * @date 2025-02-14 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("wgz_user") +@ApiModel("APP务工者视图对象") +public class WgzUser 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; + + /** 性别 */ + @Excel(name = "性别") + @ApiModelProperty("性别") + 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; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzUserMapper.java new file mode 100644 index 0000000..37d0556 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/mapper/WgzUserMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.wgz.mapper; + +import com.ruoyi.wgz.domain.WgzUser; +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 WgzUserMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzUserService.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzUserService.java new file mode 100644 index 0000000..d3568b0 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/IWgzUserService.java @@ -0,0 +1,75 @@ +package com.ruoyi.wgz.service; + +import com.ruoyi.wgz.bo.req.WgzAppUserLongInReq; +import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq; +import com.ruoyi.wgz.bo.res.WgzAppUserLongInRes; +import com.ruoyi.wgz.domain.WgzUser; +import com.ruoyi.wgz.bo.WgzUserQueryBo; +import com.ruoyi.common.core.mybatisplus.core.IServicePlus; +import com.ruoyi.common.core.page.TableDataInfo; + +import java.util.Collection; +import java.util.List; + +/** + * APP务工者Service接口 + * + * @author ruoyi + * @date 2025-02-14 + */ +public interface IWgzUserService extends IServicePlus { + /** + * 查询单个 + * @return + */ + WgzUser queryById(String id); + + /** + * 查询列表 + */ + TableDataInfo queryPageList(WgzUserQueryBo bo); + + /** + * 查询列表 + */ + List queryList(WgzUserQueryBo bo); + + /** + * 根据新增业务对象插入APP务工者 + * @param bo APP务工者新增业务对象 + * @return + */ + Boolean insert(WgzUser bo); + + /** + * 根据编辑业务对象修改APP务工者 + * @param bo APP务工者编辑业务对象 + * @return + */ + Boolean update(WgzUser bo); + + /** + * 校验并删除数据 + * @param ids 主键集合 + * @param isValid 是否校验,true-删除前校验,false-不校验 + * @return + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + + /** + * 务工者APP相关 + * ================================================================================================================= + * ================================================================================================================= + * ================================================================================================================= + */ + + /** + * 务工者APP注册账号 + * @param bo APP务工者注册业务对象 + * @return bool + */ + Boolean userRegister(WgzAppUserRegisterReq bo); + + WgzAppUserLongInRes userLongIn(WgzAppUserLongInReq req); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java new file mode 100644 index 0000000..3f88c40 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wgz/service/impl/WgzUserServiceImpl.java @@ -0,0 +1,165 @@ +package com.ruoyi.wgz.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.wgz.bo.WgzUserQueryBo; +import com.ruoyi.wgz.bo.req.WgzAppUserLongInReq; +import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq; +import com.ruoyi.wgz.bo.res.WgzAppUserLongInRes; +import com.ruoyi.wgz.common.SnowflakeIdUtil; +import com.ruoyi.wgz.domain.WgzUser; +import com.ruoyi.wgz.mapper.WgzUserMapper; +import com.ruoyi.wgz.service.IWgzUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + +/** + * APP务工者Service业务层处理 + * + * @author ruoyi + * @date 2025-02-14 + */ +@Service +public class WgzUserServiceImpl extends ServicePlusImpl implements IWgzUserService { + + @Autowired + private TokenService tokenService; + + @Override + public WgzUser queryById(String id){ + return getById(id); + } + + @Override + public TableDataInfo queryPageList(WgzUserQueryBo bo) { + Page result = page(PageUtils.buildPage(), buildQueryWrapper(bo)); + return PageUtils.buildDataInfo(result); + } + + @Override + public List queryList(WgzUserQueryBo bo) { + return list(buildQueryWrapper(bo)); + } + + private LambdaQueryWrapper buildQueryWrapper(WgzUserQueryBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.eq(bo.getUserId() != null, WgzUser::getUserId, bo.getUserId()); + lqw.like(StrUtil.isNotBlank(bo.getUsername()), WgzUser::getUsername, bo.getUsername()); + lqw.eq(StrUtil.isNotBlank(bo.getBirthdate()), WgzUser::getBirthdate, bo.getBirthdate()); + lqw.eq(StrUtil.isNotBlank(bo.getIdentityCard()), WgzUser::getIdentityCard, bo.getIdentityCard()); + lqw.eq(StrUtil.isNotBlank(bo.getPhone()), WgzUser::getPhone, bo.getPhone()); + lqw.eq(StrUtil.isNotBlank(bo.getCardNo()), WgzUser::getCardNo, bo.getCardNo()); + lqw.eq(StrUtil.isNotBlank(bo.getStatus()), WgzUser::getStatus, bo.getStatus()); + return lqw; + } + + @Override + public Boolean insert(WgzUser bo) { + WgzUser add = BeanUtil.toBean(bo, WgzUser.class); + validEntityBeforeSave(add); + return save(add); + } + + @Override + public Boolean update(WgzUser bo) { + WgzUser update = BeanUtil.toBean(bo, WgzUser.class); + validEntityBeforeSave(update); + return updateById(update); + } + + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(WgzUser entity){ + //TODO 做一些数据校验,如唯一约束 + } + + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + } + return removeByIds(ids); + } + + /** + * 务工者APP相关 + * ================================================================================================================= + * ================================================================================================================= + * ================================================================================================================= + */ + + + + @Override + public Boolean userRegister(WgzAppUserRegisterReq bo) { + WgzUser wgzUser = new WgzUser(); + //1、查询手机号是否存在 + Integer count = baseMapper.selectCount( + new LambdaQueryWrapper(). + eq(WgzUser::getPhone, wgzUser.getPhone()) + ); + if (count>0){ + throw new RuntimeException("当前手机号已存在!"); + } + //2、组装数据 BeanUtils.copyProperties(bo,wgzUser); + wgzUser.setPhone(bo.getPhone()); + wgzUser.setUserId(SnowflakeIdUtil.generateId()); + wgzUser.setPassword(SecurityUtils.encryptPassword(wgzUser.getPassword())); + //3、保存数据 + return baseMapper.insert(wgzUser) > 0; + } + + @Override + public WgzAppUserLongInRes userLongIn(WgzAppUserLongInReq req) { + //1、验证验证码是否正确(展示忽略) + //2、验证账号是否存在 + WgzUser wgzUser = baseMapper.selectOne(new LambdaQueryWrapper().eq(WgzUser::getPhone, req.getPhone())); + if (wgzUser == null){ + throw new RuntimeException("账号不存在!"); + } + //3、验证密码是否正确 + if (!SecurityUtils.matchesPassword(req.getPassword(),wgzUser.getPassword())){ + throw new RuntimeException("密码错误!"); + } + //4、创建token返回wgzUser + String token = tokenService.createToken(wgzUser); + WgzAppUserLongInRes res = new WgzAppUserLongInRes(); + res.setToken(token); + return null; + } + + + + public String createToken(WgzUser wu) { + String token = IdUtil.fastUUID(); + loginUser.setToken(token); + setUserAgent(loginUser); + refreshToken(loginUser); + + Map claims = new HashMap<>(); + claims.put(Constants.LOGIN_USER_KEY, token); + return createToken(claims); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/wgz/WgzUserMapper.xml b/ruoyi-system/src/main/resources/mapper/wgz/WgzUserMapper.xml new file mode 100644 index 0000000..7e26a72 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wgz/WgzUserMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-ui/src/api/wgz/user.js b/ruoyi-ui/src/api/wgz/user.js new file mode 100644 index 0000000..999aa4c --- /dev/null +++ b/ruoyi-ui/src/api/wgz/user.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询包工头用户列表 +export function listUser(query) { + return request({ + url: '/wgz/user/list', + method: 'get', + params: query + }) +} + +// 查询包工头用户详细 +export function getUser(userId) { + return request({ + url: '/wgz/user/' + userId, + method: 'get' + }) +} + +// 新增包工头用户 +export function addUser(data) { + return request({ + url: '/wgz/user', + method: 'post', + data: data + }) +} + +// 修改包工头用户 +export function updateUser(data) { + return request({ + url: '/wgz/user', + method: 'put', + data: data + }) +} + +// 删除包工头用户 +export function delUser(userId) { + return request({ + url: '/wgz/user/' + userId, + method: 'delete' + }) +} + +// 导出包工头用户 +export function exportUser(query) { + return request({ + url: '/wgz/user/export', + method: 'get', + params: query + }) +} diff --git a/ruoyi-ui/src/views/wgz/user/index.vue b/ruoyi-ui/src/views/wgz/user/index.vue new file mode 100644 index 0000000..b2977ab --- /dev/null +++ b/ruoyi-ui/src/views/wgz/user/index.vue @@ -0,0 +1,500 @@ + + +