feat: 一些调整
This commit is contained in:
parent
40a19e2e23
commit
51eefc8e9d
|
|
@ -1,9 +1,12 @@
|
||||||
package com.nflg.mobilebroken.admin.config;
|
package com.nflg.mobilebroken.admin.config;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
|
|
@ -16,24 +19,22 @@ import java.time.format.DateTimeFormatter;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class JacksonConfig {
|
public class JacksonConfig {
|
||||||
|
|
||||||
// 定义全局日期时间格式
|
|
||||||
private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper objectMapper() {
|
public ObjectMapper objectMapper() {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
// 创建并注册 JavaTimeModule,设置日期格式化
|
// 创建并注册 JavaTimeModule,设置日期格式化
|
||||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||||
javaTimeModule.addSerializer(
|
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
java.time.LocalDateTime.class,
|
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT))
|
|
||||||
);
|
|
||||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)));
|
|
||||||
|
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
// 注册模块到 ObjectMapper
|
|
||||||
objectMapper.registerModule(javaTimeModule);
|
SimpleModule simpleModule = new SimpleModule();
|
||||||
|
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||||
|
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||||
|
|
||||||
|
objectMapper.registerModules(javaTimeModule, simpleModule);
|
||||||
|
|
||||||
// 禁用时间戳(默认是 true,会序列化为数组)
|
// 禁用时间戳(默认是 true,会序列化为数组)
|
||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
package com.nflg.mobilebroken.admin.config;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @decription
|
|
||||||
* @Author 大米
|
|
||||||
* @Date 2022/7/20 17:57
|
|
||||||
**/
|
|
||||||
@Configuration
|
|
||||||
public class JacksonMapper {
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ObjectMapper serializingObjectMapper() {
|
|
||||||
JavaTimeModule module = new JavaTimeModule();
|
|
||||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
|
||||||
// module.addDeserializer(LocalDateTime.class, MyLocalDateTimeDeserializer.INSTANCE);
|
|
||||||
|
|
||||||
SimpleModule simpleModule = new SimpleModule();
|
|
||||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
|
||||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
|
||||||
// simpleModule.addSerializer(BigDecimal.class, new BigDecimalSerializer());
|
|
||||||
return Jackson2ObjectMapperBuilder.json()
|
|
||||||
.modules(module, simpleModule)
|
|
||||||
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -6,10 +6,7 @@ import com.nflg.mobilebroken.common.constant.AppUserApplyforType;
|
||||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.AppUserApplyforVO;
|
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.AppUserForAdminVO;
|
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.AreaSimpleVO;
|
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.CompanySimpleVO;
|
|
||||||
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
||||||
import com.nflg.mobilebroken.repository.service.IAppUserApplyforService;
|
import com.nflg.mobilebroken.repository.service.IAppUserApplyforService;
|
||||||
import com.nflg.mobilebroken.repository.service.IAppUserService;
|
import com.nflg.mobilebroken.repository.service.IAppUserService;
|
||||||
|
|
@ -143,6 +140,17 @@ public class AppUserController extends ControllerBase {
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索代理商子账号列表(根据公司名称或主账号)
|
||||||
|
*
|
||||||
|
* @param request 请求参数
|
||||||
|
*/
|
||||||
|
@PostMapping("searchSimpleUsers")
|
||||||
|
@ApiMark(moduleName = "代理商管理", apiName = "搜索代理商子账号列表(根据公司名称或主账号)")
|
||||||
|
public ApiResult<List<CompanyVO>> searchSimpleUsers(@Valid @RequestBody SimpleUsersSearchRequest request) {
|
||||||
|
return ApiResult.success(appUserService.searchSimpleUsers(request));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代理商迁移
|
* 代理商迁移
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@ public class TiketController extends ControllerBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索设备
|
* 搜索设备
|
||||||
*
|
|
||||||
* @param request 搜索条件
|
* @param request 搜索条件
|
||||||
* @return 设备列表
|
* @return 设备列表
|
||||||
**/
|
**/
|
||||||
|
|
@ -160,7 +159,6 @@ public class TiketController extends ControllerBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取工单详情
|
* 获取工单详情
|
||||||
*
|
|
||||||
* @param id 工单编号
|
* @param id 工单编号
|
||||||
* @return 工单详情
|
* @return 工单详情
|
||||||
**/
|
**/
|
||||||
|
|
@ -185,8 +183,8 @@ public class TiketController extends ControllerBase {
|
||||||
.setUseTime(ticket.getUseTime())
|
.setUseTime(ticket.getUseTime())
|
||||||
.setDescription(ticket.getDescription())
|
.setDescription(ticket.getDescription())
|
||||||
.setState(ticket.getState())
|
.setState(ticket.getState())
|
||||||
.setImages(StrUtil.isNotBlank(ticket.getImages()) ? StrUtil.split(",", ticket.getImages()) : Collections.emptyList())
|
.setImages(StrUtil.isNotBlank(ticket.getImages()) ? StrUtil.split(ticket.getImages(), ",") : Collections.emptyList())
|
||||||
.setAttachments(StrUtil.isNotBlank(ticket.getAttachments()) ? StrUtil.split(",", ticket.getAttachments()) : Collections.emptyList())
|
.setAttachments(StrUtil.isNotBlank(ticket.getAttachments()) ? StrUtil.split(ticket.getAttachments(), ",") : Collections.emptyList())
|
||||||
.setCreateUserId(ticket.getUserId())
|
.setCreateUserId(ticket.getUserId())
|
||||||
.setCreateUserName(user.getName())
|
.setCreateUserName(user.getName())
|
||||||
.setCreateUserAvatar(user.getAvatar())
|
.setCreateUserAvatar(user.getAvatar())
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class UserController extends ControllerBase {
|
||||||
@GetMapping("getCompanys")
|
@GetMapping("getCompanys")
|
||||||
//@SaUserCheckRole("primary")
|
//@SaUserCheckRole("primary")
|
||||||
public ApiResult<List<CompanySimpleVO>> getCompanys() {
|
public ApiResult<List<CompanySimpleVO>> getCompanys() {
|
||||||
return ApiResult.success(customerService.getSimpleCompanys());
|
return ApiResult.success(customerService.getSimpleCompanys(AppUserUtil.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ package com.nflg.mobilebroken.common.pojo.request;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class MigrateAppUserRequest {
|
public class MigrateAppUserRequest {
|
||||||
|
|
||||||
// 旧公司id
|
|
||||||
private Integer oldCompanyId;
|
|
||||||
|
|
||||||
// 新公司id
|
// 新公司id
|
||||||
private Integer newCompanyId;
|
private Integer companyId;
|
||||||
|
|
||||||
|
// 用户id集合
|
||||||
|
private List<Integer> userIds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SimpleUsersSearchRequest {
|
||||||
|
|
||||||
|
//公司名称或者代理商主账号
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
|
@ -60,4 +60,7 @@ public class AdminUserVO {
|
||||||
|
|
||||||
//职位id
|
//职位id
|
||||||
private Integer titleId;
|
private Integer titleId;
|
||||||
|
|
||||||
|
//微信openid
|
||||||
|
private String openId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,15 @@ public class AppUserForAdminVO {
|
||||||
//是否主账号
|
//是否主账号
|
||||||
private boolean isPrimary;
|
private boolean isPrimary;
|
||||||
|
|
||||||
|
//公司id列表
|
||||||
|
private List<Integer> companyIds;
|
||||||
|
|
||||||
|
//手机号
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
//区域id
|
||||||
|
private Integer areaId;
|
||||||
|
|
||||||
//下级账号
|
//下级账号
|
||||||
private List<AppUserForAdminVO> children;
|
private List<AppUserForAdminVO> children;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
package com.nflg.mobilebroken.common.pojo.vo;
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
|
@ -63,4 +68,29 @@ public class AppUserVO {
|
||||||
|
|
||||||
//区域id
|
//区域id
|
||||||
private Integer areaId;
|
private Integer areaId;
|
||||||
|
|
||||||
|
//公司id列表
|
||||||
|
public List<Integer> companyIds;
|
||||||
|
//手机号
|
||||||
|
private String phone;
|
||||||
|
//职位
|
||||||
|
private String title;
|
||||||
|
//职位id
|
||||||
|
private Integer titleId;
|
||||||
|
//公司id
|
||||||
|
@JsonIgnore
|
||||||
|
private String companyId;
|
||||||
|
//公司id
|
||||||
|
private Integer companyId1;
|
||||||
|
|
||||||
|
public List<Integer> getCompanyIds() {
|
||||||
|
return StrUtil.split(companyId, ",").stream().map(Integer::parseInt).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCompanyId1() {
|
||||||
|
if (CollectionUtil.isEmpty(getCompanyIds())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getCompanyIds().get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ public class DeviceVO {
|
||||||
// 设备型号
|
// 设备型号
|
||||||
private String modelNo;
|
private String modelNo;
|
||||||
|
|
||||||
|
// 设备类型
|
||||||
|
private String deviceType;
|
||||||
|
|
||||||
// 销售日期
|
// 销售日期
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDateTime shipmentDate;
|
private LocalDateTime shipmentDate;
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,6 @@ public interface IAppUserService extends IService<AppUser> {
|
||||||
List<AppUserForAdminVO> getChildrenOfAppUser(Integer id);
|
List<AppUserForAdminVO> getChildrenOfAppUser(Integer id);
|
||||||
|
|
||||||
void renewal(RenewalAppUserRequest request);
|
void renewal(RenewalAppUserRequest request);
|
||||||
|
|
||||||
|
List<CompanyVO> searchSimpleUsers(SimpleUsersSearchRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,7 @@ public interface ITBaseCustomerService extends IService<TBaseCustomer> {
|
||||||
|
|
||||||
void delByIds(@Param("ids") List<Long> ids ,@Param("userNo")String userNo , @Param("userName") String userName);
|
void delByIds(@Param("ids") List<Long> ids ,@Param("userNo")String userNo , @Param("userName") String userName);
|
||||||
|
|
||||||
|
List<CompanySimpleVO> getSimpleCompanys(Integer userId);
|
||||||
|
|
||||||
List<CompanySimpleVO> getSimpleCompanys();
|
List<CompanySimpleVO> getSimpleCompanys();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.setEnabled(u.getEnable())
|
.setEnabled(u.getEnable())
|
||||||
.setPhone(u.getPhone())
|
.setPhone(u.getPhone())
|
||||||
.setEmail(u.getEmail())
|
.setEmail(u.getEmail())
|
||||||
|
.setOpenId(u.getOpenid())
|
||||||
.setAvatar(u.getAvatar())
|
.setAvatar(u.getAvatar())
|
||||||
.setDepartmentId(u.getDepartmentId())
|
.setDepartmentId(u.getDepartmentId())
|
||||||
.setTitleId(u.getTitleId())
|
.setTitleId(u.getTitleId())
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,13 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(AddUserRequest request) {
|
public void add(AddUserRequest request) {
|
||||||
|
VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists())
|
||||||
|
.throwMessage("用户已存在");
|
||||||
|
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||||
|
.eq(AppUserApplyfor::getType, AppUserApplyforType.ADD.getState().byteValue())
|
||||||
|
.eq(AppUserApplyfor::getUserEmail, request.getEmail())
|
||||||
|
.exists())
|
||||||
|
.throwMessage("正在审批中,请勿重复申请");
|
||||||
AppUserApplyfor applyfor = new AppUserApplyfor()
|
AppUserApplyfor applyfor = new AppUserApplyfor()
|
||||||
.setUserName(request.getName())
|
.setUserName(request.getName())
|
||||||
.setUserEmail(request.getEmail())
|
.setUserEmail(request.getEmail())
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service.impl;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -33,10 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.chrono.ChronoLocalDate;
|
import java.time.chrono.ChronoLocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -193,18 +191,17 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void migrate(MigrateAppUserRequest request) {
|
public void migrate(MigrateAppUserRequest request) {
|
||||||
AppUser appUser = lambdaQuery()
|
QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
|
||||||
.eq(AppUser::getCompanyId, "'" + request.getOldCompanyId() + "'")
|
queryWrapper.apply("FIND_IN_SET({0}, company_id)", request.getCompanyId());
|
||||||
.eq(AppUser::getIsPrimary, true)
|
AppUser appUser = appUserService.getBaseMapper().selectOne(queryWrapper);
|
||||||
.one();
|
VUtils.trueThrowBusinessError(Objects.isNull(appUser)).throwMessage("该公司还未设置主账号");
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(appUser)).throwMessage("代理商主账号不存在");
|
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.set(AppUser::getCompanyId, "'" + request.getNewCompanyId() + "'")
|
.set(AppUser::getCompanyId, request.getCompanyId())
|
||||||
.set(AppUser::getExpireTime, appUser.getExpireTime())
|
.set(AppUser::getExpireTime, appUser.getExpireTime())
|
||||||
.set(AppUser::getUpdateBy, AdminUserUtil.getUserId())
|
.set(AppUser::getUpdateBy, AdminUserUtil.getUserId())
|
||||||
.set(AppUser::getUpdateTime, LocalDateTime.now())
|
.set(AppUser::getUpdateTime, LocalDateTime.now())
|
||||||
.eq(AppUser::getCompanyId, request.getOldCompanyId().toString())
|
|
||||||
.eq(AppUser::getIsPrimary, false)
|
.eq(AppUser::getIsPrimary, false)
|
||||||
|
.in(AppUser::getId, request.getUserIds())
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,8 +227,11 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.setLoginName(d.getLoginName())
|
.setLoginName(d.getLoginName())
|
||||||
.setUserName(d.getName())
|
.setUserName(d.getName())
|
||||||
.setCompanyName(StrUtil.join(",", customers))
|
.setCompanyName(StrUtil.join(",", customers))
|
||||||
.setName(d.getSalesUserName())
|
.setCompanyIds(companyIds)
|
||||||
|
.setName(d.getName())
|
||||||
.setEmail(d.getEmail())
|
.setEmail(d.getEmail())
|
||||||
|
.setPhone(d.getPhone())
|
||||||
|
.setAreaId(d.getAreaId())
|
||||||
.setSalesUserName(d.getSalesUserName())
|
.setSalesUserName(d.getSalesUserName())
|
||||||
.setAreaName(area.getName())
|
.setAreaName(area.getName())
|
||||||
.setEnable(d.getEnable())
|
.setEnable(d.getEnable())
|
||||||
|
|
@ -350,4 +350,51 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CompanyVO> searchSimpleUsers(SimpleUsersSearchRequest request) {
|
||||||
|
List<CompanyVO> datas = new ArrayList<>();
|
||||||
|
Set<Long> companyIds = customerService.lambdaQuery()
|
||||||
|
.select(TBaseCustomer::getId)
|
||||||
|
.eq(TBaseCustomer::getEnableState, 1)
|
||||||
|
.eq(TBaseCustomer::getDelIs, 0)
|
||||||
|
.like(StrUtil.isNotBlank(request.getName()), TBaseCustomer::getAgencyCompanyName, request.getName())
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(TBaseCustomer::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (StrUtil.isNotBlank(request.getName())) {
|
||||||
|
Set<Long> userCompanyIds = lambdaQuery()
|
||||||
|
.select(AppUser::getCompanyId)
|
||||||
|
.eq(AppUser::getEnable, true)
|
||||||
|
.eq(AppUser::getIsPrimary, true)
|
||||||
|
.like(AppUser::getLoginName, request.getName())
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.flatMap(s -> Arrays.stream(s.getCompanyId().split(",")))
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
companyIds.addAll(userCompanyIds);
|
||||||
|
}
|
||||||
|
companyIds.forEach(id -> {
|
||||||
|
TBaseCustomer customer = customerService.getById(id);
|
||||||
|
CompanyVO companyVO = new CompanyVO()
|
||||||
|
.setId(customer.getId())
|
||||||
|
.setName(customer.getAgencyCompanyName())
|
||||||
|
.setUsers(getByCompanyId(id));
|
||||||
|
datas.add(companyVO);
|
||||||
|
});
|
||||||
|
return datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AppUserVO> getByCompanyId(Long companyId) {
|
||||||
|
return lambdaQuery()
|
||||||
|
.eq(AppUser::getCompanyId, companyId.toString())
|
||||||
|
.eq(AppUser::getEnable, true)
|
||||||
|
.eq(AppUser::getIsPrimary, false)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(u -> new AppUserVO().setId(u.getId()).setName(u.getName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.CompanySimpleVO;
|
import com.nflg.mobilebroken.common.pojo.vo.CompanySimpleVO;
|
||||||
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||||
import com.nflg.mobilebroken.repository.mapper.TBaseCustomerMapper;
|
import com.nflg.mobilebroken.repository.mapper.TBaseCustomerMapper;
|
||||||
|
import com.nflg.mobilebroken.repository.service.IAppUserService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,6 +30,9 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, TBaseCustomer> implements ITBaseCustomerService {
|
public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, TBaseCustomer> implements ITBaseCustomerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAppUserService appUserService;
|
||||||
|
|
||||||
public Page<TBaseCustomer> getList(@Param("page")Page<PageBaseQuery> page, @Param("query") PageBaseQuery query){
|
public Page<TBaseCustomer> getList(@Param("page")Page<PageBaseQuery> page, @Param("query") PageBaseQuery query){
|
||||||
return this.getBaseMapper().getList(page, query);
|
return this.getBaseMapper().getList(page, query);
|
||||||
}
|
}
|
||||||
|
|
@ -32,9 +41,24 @@ public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, T
|
||||||
this.getBaseMapper().delByIds(ids,userNo,userName);
|
this.getBaseMapper().delByIds(ids,userNo,userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CompanySimpleVO> getSimpleCompanys(Integer userId) {
|
||||||
|
AppUser appUser = appUserService.getById(userId);
|
||||||
|
VUtils.trueThrowBusinessError(Objects.isNull(appUser)).throwMessage("用户不存在");
|
||||||
|
List<TBaseCustomer> datas = lambdaQuery()
|
||||||
|
.eq(TBaseCustomer::getEnableState, 1)
|
||||||
|
.eq(TBaseCustomer::getDelIs, 0)
|
||||||
|
.in(TBaseCustomer::getId, StrUtil.split(appUser.getCompanyId(), ",").stream().map(Integer::parseInt).collect(Collectors.toList()))
|
||||||
|
.list();
|
||||||
|
return datas.stream().map(d -> new CompanySimpleVO().setId(d.getId()).setName(d.getAgencyCompanyName())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CompanySimpleVO> getSimpleCompanys() {
|
public List<CompanySimpleVO> getSimpleCompanys() {
|
||||||
List<TBaseCustomer> datas = lambdaQuery().eq(TBaseCustomer::getEnableState, 1).eq(TBaseCustomer::getDelIs, 0).list();
|
List<TBaseCustomer> datas = lambdaQuery()
|
||||||
|
.eq(TBaseCustomer::getEnableState, 1)
|
||||||
|
.eq(TBaseCustomer::getDelIs, 0)
|
||||||
|
.list();
|
||||||
return datas.stream().map(d -> new CompanySimpleVO().setId(d.getId()).setName(d.getAgencyCompanyName())).collect(Collectors.toList());
|
return datas.stream().map(d -> new CompanySimpleVO().setId(d.getId()).setName(d.getAgencyCompanyName())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,13 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="searchByCompany" parameterType="com.nflg.mobilebroken.common.pojo.request.UserSearchRequest" resultType="com.nflg.mobilebroken.common.pojo.vo.AppUserVO">
|
<select id="searchByCompany" parameterType="com.nflg.mobilebroken.common.pojo.request.UserSearchRequest" resultType="com.nflg.mobilebroken.common.pojo.vo.AppUserVO">
|
||||||
SELECT u.id,c.agency_company_name AS 'companyName',u.login_name AS 'loginName',u.`name`,u.email,u.avatar,a.`name` AS 'areaName',u.`enable`,uc.`name` AS 'createBy',u.create_time AS 'createTime',uu.`name` AS 'updateBy',u.update_time AS 'updateTime',u.last_login_time AS 'lastLoginTime',u.expire_time AS 'expireTime',u.is_primary AS 'isPrimary',IF(u.expire_time>now(),1,2) AS 'state'
|
SELECT u.id,u.phone,u.title_id AS 'titleId',u.area_id AS 'areaId',u.company_id AS 'companyId',p.position_name AS 'title',u.expire_time AS 'expireTime',c.agency_company_name AS 'companyName',u.login_name AS 'loginName',u.`name`,u.email,u.avatar,a.`name` AS 'areaName',u.`enable`,uc.`name` AS 'createBy',u.create_time AS 'createTime',uu.`name` AS 'updateBy',u.update_time AS 'updateTime',u.last_login_time AS 'lastLoginTime',u.expire_time AS 'expireTime',u.is_primary AS 'isPrimary',IF(u.expire_time>now(),1,2) AS 'state'
|
||||||
FROM app_user u
|
FROM app_user u
|
||||||
INNER JOIN t_base_customer c ON u.company_id=c.id
|
INNER JOIN t_base_customer c ON u.company_id=c.id
|
||||||
INNER JOIN app_area a ON u.area_id=a.id
|
INNER JOIN app_area a ON u.area_id=a.id
|
||||||
LEFT JOIN app_user uc ON u.create_by=uc.id
|
LEFT JOIN app_user uc ON u.create_by=uc.id
|
||||||
LEFT JOIN app_user uu ON u.update_by=uu.id
|
LEFT JOIN app_user uu ON u.update_by=uu.id
|
||||||
|
LEFT JOIN t_base_position p ON u.title_id=p.id
|
||||||
WHERE u.is_primary=false AND u.company_id=#{companyId}
|
WHERE u.is_primary=false AND u.company_id=#{companyId}
|
||||||
<where>
|
<where>
|
||||||
<if test="enabled != null">
|
<if test="enabled != null">
|
||||||
|
|
@ -69,11 +70,12 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
UNION
|
UNION
|
||||||
SELECT u.id,c.agency_company_name AS 'companyName',u.user_email AS 'loginName',u.user_name AS 'name',u.user_email AS 'email',u.user_avatar AS 'avatar',a.`name` AS 'areaName',false AS `enable`,uc.`name` AS 'createBy',u.create_time AS 'createTime',null AS 'updateBy',null AS 'updateTime',null AS 'lastLoginTime',null AS 'expireTime',false AS 'isPrimary',0 AS 'state'
|
SELECT u.id,u.user_phone AS 'phone',u.title_id AS 'titleId',u.area_id AS 'areaId',u.company_id AS 'companyId',p.position_name AS 'title',null AS 'expireTime',c.agency_company_name AS 'companyName',u.user_email AS 'loginName',u.user_name AS 'name',u.user_email AS 'email',u.user_avatar AS 'avatar',a.`name` AS 'areaName',false AS `enable`,uc.`name` AS 'createBy',u.create_time AS 'createTime',null AS 'updateBy',null AS 'updateTime',null AS 'lastLoginTime',null AS 'expireTime',false AS 'isPrimary',0 AS 'state'
|
||||||
FROM app_user_applyfor u
|
FROM app_user_applyfor u
|
||||||
INNER JOIN t_base_customer c ON u.company_id=c.id
|
INNER JOIN t_base_customer c ON u.company_id=c.id
|
||||||
INNER JOIN app_area a ON u.area_id=a.id
|
INNER JOIN app_area a ON u.area_id=a.id
|
||||||
LEFT JOIN app_user uc ON u.create_by=uc.id
|
LEFT JOIN app_user uc ON u.create_by=uc.id
|
||||||
|
LEFT JOIN t_base_position p ON u.title_id=p.id
|
||||||
WHERE u.company_id=#{companyId}
|
WHERE u.company_id=#{companyId}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue