10 changed files with 303 additions and 44 deletions
@ -0,0 +1,106 @@ |
|||
package com.qs.serve.modules.exl.entity; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import javax.validation.constraints.NotNull; |
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* 实体类 |
|||
* @author YenHex |
|||
* @since 2023-09-25 |
|||
*/ |
|||
@Data |
|||
@TableName("exl_table_user") |
|||
public class ExlTableUser implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** id */ |
|||
@TableId(type = IdType.AUTO) |
|||
private Long id; |
|||
|
|||
/** 表配置id */ |
|||
@NotNull(message = "表配置id不能为空") |
|||
private Long tableConfId; |
|||
|
|||
/** 用户id */ |
|||
@NotBlank(message = "用户id不能为空") |
|||
@Length(max = 255,message = "用户id长度不能超过255字") |
|||
private String userId; |
|||
|
|||
/** 用户编码 */ |
|||
@NotBlank(message = "用户编码不能为空") |
|||
@Length(max = 255,message = "用户编码长度不能超过255字") |
|||
private String userCode; |
|||
|
|||
/** 用户名称 */ |
|||
@NotBlank(message = "用户名称不能为空") |
|||
@Length(max = 255,message = "用户名称长度不能超过255字") |
|||
private String userName; |
|||
|
|||
/** 备注 */ |
|||
@Length(max = 255,message = "备注长度不能超过255字") |
|||
private String remark; |
|||
|
|||
/** 创建时间 */ |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private LocalDateTime createTime; |
|||
|
|||
/** 最后更新时间 */ |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
|||
@TableField(fill = FieldFill.UPDATE) |
|||
private LocalDateTime updateTime; |
|||
|
|||
/** 所属租户 */ |
|||
@JsonIgnore |
|||
@JsonProperty |
|||
private String tenantId; |
|||
|
|||
/** 创建人 */ |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private String createBy; |
|||
|
|||
/** 更新人 */ |
|||
@TableField(fill = FieldFill.UPDATE) |
|||
private String updateBy; |
|||
|
|||
/** 逻辑删除标记(0:显示;1:隐藏) */ |
|||
@JsonIgnore |
|||
@JsonProperty |
|||
private String delFlag; |
|||
|
|||
|
|||
public static ExlTableUser toNewObject(ExlTableUser source){ |
|||
ExlTableUser tableUser = new ExlTableUser(); |
|||
tableUser.setId(source.getId()); |
|||
tableUser.setTableConfId(source.getTableConfId()); |
|||
tableUser.setUserId(source.getUserId()); |
|||
tableUser.setUserCode(source.getUserCode()); |
|||
tableUser.setUserName(source.getUserName()); |
|||
tableUser.setRemark(source.getRemark()); |
|||
tableUser.setCreateTime(source.getCreateTime()); |
|||
tableUser.setUpdateTime(source.getUpdateTime()); |
|||
tableUser.setTenantId(source.getTenantId()); |
|||
tableUser.setCreateBy(source.getCreateBy()); |
|||
tableUser.setUpdateBy(source.getUpdateBy()); |
|||
tableUser.setDelFlag(source.getDelFlag()); |
|||
return tableUser; |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,18 @@ |
|||
package com.qs.serve.modules.exl.entity.bo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2023/9/25 |
|||
*/ |
|||
@Data |
|||
public class ExlTableUserBo { |
|||
|
|||
private Long tableConfId; |
|||
|
|||
private List<String> userIds; |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.qs.serve.modules.exl.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.qs.serve.modules.exl.entity.ExlTableUser; |
|||
|
|||
/** |
|||
* Mapper |
|||
* @author YenHex |
|||
* @date 2023-09-25 |
|||
*/ |
|||
public interface ExlTableUserMapper extends BaseMapper<ExlTableUser> { |
|||
|
|||
} |
|||
|
@ -0,0 +1,19 @@ |
|||
package com.qs.serve.modules.exl.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.qs.serve.modules.exl.entity.ExlTableUser; |
|||
import com.qs.serve.modules.exl.entity.bo.ExlTableUserBo; |
|||
|
|||
/** |
|||
* 服务接口 |
|||
* @author YenHex |
|||
* @date 2023-09-25 |
|||
*/ |
|||
public interface ExlTableUserService extends IService<ExlTableUser> { |
|||
|
|||
void confAdmins(ExlTableUserBo param); |
|||
|
|||
Integer checkAdmin(Long tableConfId,String userId); |
|||
|
|||
} |
|||
|
@ -0,0 +1,57 @@ |
|||
package com.qs.serve.modules.exl.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.qs.serve.common.util.CollectionUtil; |
|||
import com.qs.serve.modules.exl.entity.bo.ExlTableUserBo; |
|||
import com.qs.serve.modules.sys.entity.SysUser; |
|||
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
import com.qs.serve.modules.exl.entity.ExlTableUser; |
|||
import com.qs.serve.modules.exl.service.ExlTableUserService; |
|||
import com.qs.serve.modules.exl.mapper.ExlTableUserMapper; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
/** |
|||
* 服务实现类 |
|||
* @author YenHex |
|||
* @since 2023-09-25 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@AllArgsConstructor |
|||
public class ExlTableUserServiceImpl extends ServiceImpl<ExlTableUserMapper,ExlTableUser> implements ExlTableUserService { |
|||
|
|||
private SysUserMapper sysUserMapper; |
|||
|
|||
@Override |
|||
public void confAdmins(ExlTableUserBo param) { |
|||
LambdaQueryWrapper<ExlTableUser> rmlqw = new LambdaQueryWrapper<>(); |
|||
rmlqw.eq(ExlTableUser::getTableConfId,param.getTableConfId()); |
|||
super.remove(rmlqw); |
|||
if(CollectionUtil.isNotEmpty(param.getUserIds())){ |
|||
List<ExlTableUser> list = new ArrayList<>(); |
|||
for (String userId : param.getUserIds()) { |
|||
SysUser sysUser = sysUserMapper.selectById(userId); |
|||
ExlTableUser tableUser = new ExlTableUser(); |
|||
tableUser.setTableConfId(param.getTableConfId()); |
|||
tableUser.setUserId(sysUser.getId()); |
|||
tableUser.setUserCode(sysUser.getCode()); |
|||
tableUser.setUserName(sysUser.getName()); |
|||
} |
|||
super.saveBatch(list); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public Integer checkAdmin(Long tableConfId, String userId) { |
|||
LambdaQueryWrapper<ExlTableUser> lqw = new LambdaQueryWrapper<>(); |
|||
lqw.eq(ExlTableUser::getTableConfId,tableConfId); |
|||
lqw.eq(ExlTableUser::getUserId,userId); |
|||
return super.count(lqw)>0?1:0; |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue