Browse Source

1 赠送用户管理

main
xbw 1 year ago
parent
commit
9495c58cfa
  1. 15
      jnpf-library/jnpf-library-biz/src/main/java/jnpf/mapper/TUserForLibraryMapper.java
  2. 21
      jnpf-library/jnpf-library-biz/src/main/java/jnpf/service/TUserForLibraryService.java
  3. 79
      jnpf-library/jnpf-library-biz/src/main/java/jnpf/service/impl/TUserForLibraryServiceImpl.java
  4. 44
      jnpf-library/jnpf-library-biz/src/main/resources/mapper/TUserForLibraryMapper.xml
  5. 105
      jnpf-library/jnpf-library-entity/src/main/java/jnpf/entity/TUserForLibrary.java
  6. 35
      jnpf-library/jnpf-library-entity/src/main/java/jnpf/enump/TUserForLibraryEnum.java
  7. 66
      jnpf-library/jnpf-library-entity/src/main/java/jnpf/model/dto/TUserForLibraryDto.java

15
jnpf-library/jnpf-library-biz/src/main/java/jnpf/mapper/TUserForLibraryMapper.java

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
package jnpf.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jnpf.entity.TUserForLibrary;
import jnpf.model.dto.TUserForLibraryDto;
/**
* @author xbw
*/
public interface TUserForLibraryMapper extends BaseMapper<TUserForLibrary> {
IPage<TUserForLibrary> selectList(IPage<TUserForLibrary> page, TUserForLibraryDto.TUserForLibraryDtoParam param);
}

21
jnpf-library/jnpf-library-biz/src/main/java/jnpf/service/TUserForLibraryService.java

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
package jnpf.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.entity.TUserForLibrary;
import jnpf.model.dto.TUserForLibraryDto;
/**
* @author xbw
*/
public interface TUserForLibraryService extends IService<TUserForLibrary>{
void addOrUpdateUser(TUserForLibraryDto.TUserForLibraryDtoAdd tUserForLibraryDtoAdd);
void delUser(TUserForLibraryDto.TUserForLibraryDtoDel userForLibraryDtoDel);
IPage<TUserForLibrary> getUserLibraryList(TUserForLibraryDto.TUserForLibraryDtoParam param);
}

79
jnpf-library/jnpf-library-biz/src/main/java/jnpf/service/impl/TUserForLibraryServiceImpl.java

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
package jnpf.service.impl;
import cn.hutool.core.util.PhoneUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.entity.TUserForLibrary;
import jnpf.enump.TUserForLibraryEnum;
import jnpf.exception.DataException;
import jnpf.mapper.TUserForLibraryMapper;
import jnpf.model.dto.TUserForLibraryDto;
import jnpf.service.TUserForLibraryService;
import jnpf.util.UserProvider;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* @author xbw
*/
@Service("iUserForLibraryService")
@DS("userForLibrary")
public class TUserForLibraryServiceImpl extends ServiceImpl<TUserForLibraryMapper, TUserForLibrary> implements TUserForLibraryService {
@Override
public void addOrUpdateUser(TUserForLibraryDto.TUserForLibraryDtoAdd tUserForLibraryDtoAdd) {
if (StringUtils.isBlank(tUserForLibraryDtoAdd.getUserName())) {
throw new DataException("用户姓名不正确");
}
if (StringUtils.isBlank(tUserForLibraryDtoAdd.getUserPhone()) || PhoneUtil.isMobile(tUserForLibraryDtoAdd.getUserPhone())) {
throw new DataException("用户号码不正确");
}
if (tUserForLibraryDtoAdd.getSex() == null) {
throw new DataException("用户性别不正确");
}
if (TUserForLibraryEnum.InsideEnum.getEnumByCode(tUserForLibraryDtoAdd.getInside()) == null) {
throw new DataException("用户类型不正确");
}
TUserForLibrary tUserForLibrary = new TUserForLibrary();
if (tUserForLibraryDtoAdd.getId() == null) {
// 外部用户
BeanUtils.copyProperties(tUserForLibraryDtoAdd, tUserForLibrary);
tUserForLibrary.setCreateTime(LocalDateTime.now());
tUserForLibrary.setUpdateTime(LocalDateTime.now());
tUserForLibrary.setCreateName(UserProvider.getUser().getUserName());
tUserForLibrary.setCreateBy(UserProvider.getUser().getUserId());
this.save(tUserForLibrary);
return;
}
BeanUtils.copyProperties(tUserForLibraryDtoAdd, tUserForLibrary);
tUserForLibrary.setUpdateTime(LocalDateTime.now());
tUserForLibrary.setUpdateBy(UserProvider.getUser().getUserName());
tUserForLibrary.setUpdateName(UserProvider.getUser().getUserId());
this.updateById(tUserForLibrary);
}
@Override
public void delUser(TUserForLibraryDto.TUserForLibraryDtoDel userForLibraryDtoDel) {
if (userForLibraryDtoDel.getId() == null) {
throw new DataException("请传入用户id");
}
TUserForLibrary byId = this.getById(userForLibraryDtoDel.getId());
byId.setDelFlag(1);
this.updateById(byId);
}
@Override
public IPage<TUserForLibrary> getUserLibraryList(TUserForLibraryDto.TUserForLibraryDtoParam param) {
return this.baseMapper.selectList(new Page<>(param.getCurrent(), param.getSize()), param);
}
}

44
jnpf-library/jnpf-library-biz/src/main/resources/mapper/TUserForLibraryMapper.xml

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
<?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="jnpf.mapper.TUserForLibraryMapper">
<resultMap type="jnpf.entity.TUserForLibrary" id="TSelectionOrderingBooksMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="userName" column="user_name"/>
<result property="idNumber" column="id_number"/>
<result property="userPhone" column="user_phone"/>
<result property="sex" column="sex"/>
<result property="inside" column="inside"/>
<result property="job" column="job"/>
<result property="address" column="address"/>
<result property="section" column="section"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="updateName" column="update_name"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createName" column="create_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,user_name,id_number,user_phone,sex,inside,job,address,section,
create_by,update_by,update_name,update_time,del_flag,
create_time,create_name
</sql>
<select id="selectList" resultMap="TSelectionOrderingBooksMap">
select
<include refid="Base_Column_List"/>
from t_user_for_library
<where>
<if test="userPhone!='' and userPhone != null">
and user_phone like concat('%',#{userPhone},'%')
</if>
<if test="userName!='' and userName != null">
and user_name like concat('%',#{userName},'%')
</if>
and del_flag = 0
</where>
</select>
</mapper>

105
jnpf-library/jnpf-library-entity/src/main/java/jnpf/entity/TUserForLibrary.java

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author xbw
*/
@Data
@TableName("t_user_for_library")
public class TUserForLibrary implements Serializable {
private static final long serialVersionUID = -65167281438767901L;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
@ApiModelProperty(value = "用户姓名")
@TableField(value = "user_name")
private String userName;
@ApiModelProperty(value = "身份证号码")
@TableField(value = "id_number")
private String idNumber;
@ApiModelProperty(value = "用户手机号")
@TableField(value = "user_phone")
private String userPhone;
@ApiModelProperty(value = "0-女 1-男")
@TableField(value = "sex")
private Integer sex;
@ApiModelProperty(value = "0-内部 1-外部用户")
@TableField(value = "inside")
private Integer inside;
@ApiModelProperty(value = "职务")
@TableField(value = "job")
private String job;
@ApiModelProperty(value = "地址")
@TableField(value = "address")
private String address;
@ApiModelProperty(value = "部门")
@TableField(value = "section")
private String section;
@ApiModelProperty(value = "删除标记0-正常 1-删除")
@TableField(value = "del_flag")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建者id")
@TableField(value = "create_by")
private String createBy;
@ApiModelProperty(value = "创建者名称")
@TableField(value = "create_name")
private String createName;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time",fill = FieldFill.INSERT)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新者id")
@TableField(value = "update_by")
private String updateBy;
@ApiModelProperty(value = "更新者名称")
@TableField(value = "update_name")
private String updateName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@ApiModelProperty(value = "创建人单位名称")
@TableField(value = "create_corp_name")
private String createCorpName;
@ApiModelProperty(value = "创建人单位id")
@TableField(value = "create_corp_id")
private String createCorpId;
@ApiModelProperty(value = "创建人部门名称")
@TableField(value = "create_dept_name")
private String createDeptName;
@ApiModelProperty(value = "创建人部门id")
@TableField(value = "create_dept_id")
private String createDeptId;
}

35
jnpf-library/jnpf-library-entity/src/main/java/jnpf/enump/TUserForLibraryEnum.java

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
package jnpf.enump;
import lombok.Getter;
/**
* @author xbw
*/
public class TUserForLibraryEnum {
@Getter
public enum InsideEnum {
INSIDE(0, "内部用户"),
OUTSIDE(1, "外部用户");
;
private final Integer code;
private final String describe;
InsideEnum(Integer code, String describe) {
this.code = code;
this.describe = describe;
}
public static InsideEnum getEnumByCode(Integer type) {
for (InsideEnum enm : InsideEnum.values()) {
if (enm.getCode().equals(type)) {
return enm;
}
}
return null;
}
}
}

66
jnpf-library/jnpf-library-entity/src/main/java/jnpf/model/dto/TUserForLibraryDto.java

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
package jnpf.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author xbw
*/
public class TUserForLibraryDto {
private TUserForLibraryDto(){}
@Data
public static class TUserForLibraryDtoParam extends BasePageParam{
@ApiModelProperty(value = "用户手机号")
private String userPhone;
@ApiModelProperty(value = "用户姓名")
private String userName;
}
@Data
public static class BasePageParam {
@ApiModelProperty("当前页")
private Integer current = 1;
@ApiModelProperty("页大小")
private Integer size = 10;
}
@Data
public static class TUserForLibraryDtoDel {
@ApiModelProperty(value = "用户id")
private Long id;
}
@Data
public static class TUserForLibraryDtoAdd {
@ApiModelProperty(value = "用户id 新增不传")
private Long id;
@ApiModelProperty(value = "用户姓名")
private String userName;
@ApiModelProperty(value = "身份证号码")
private String idNumber;
@ApiModelProperty(value = "用户手机号")
private String userPhone;
@ApiModelProperty(value = "0-女 1-男")
private Integer sex;
@ApiModelProperty(value = "职务")
private String job;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "部门")
private String section;
@ApiModelProperty(value = "0-内部用户 1-外部用户")
private Integer inside;
}
}
Loading…
Cancel
Save