mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-18 15:26:54 +08:00
一基的服务与模板重新建立一个环境
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.xboe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.system.ApplicationPid;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
public class BoeServerAllApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("jasypt.encryptor.password","jasypt");
|
||||
SpringApplication.run(BoeServerAllApplication.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void handlePid() throws IOException {
|
||||
File file = new File("application.pid");
|
||||
new ApplicationPid().write(file);
|
||||
file.deleteOnExit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xboe;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
/**
|
||||
* 返回的数据中如果是null 就会转化成空字符串
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class ResultNullToEmptyConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConditionalOnMissingBean(ObjectMapper.class)
|
||||
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||||
objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
|
||||
@Override
|
||||
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
|
||||
throws IOException, JsonProcessingException {
|
||||
jsonGenerator.writeString("");
|
||||
}
|
||||
});
|
||||
return objectMapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xboe;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.xboe.core.api.authentication.ApiAuthenticateHandle;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
|
||||
/**
|
||||
* 使用实现 WebMvcConfigurer 此接口,不使用继承WebMvcConfigurationSupport的方式</br>
|
||||
* 这样原有的自动配置不会失效
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
//@EnableWebMvc
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer{
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Autowired
|
||||
private ApiAuthenticateHandle authenticateHandle;
|
||||
|
||||
// @Override
|
||||
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
//// //设置静态访问目录
|
||||
//// if(env.containsProperty(BaseConstant.CONFIG_MVC_STATIC_PATH)) {
|
||||
//// String path=env.getProperty(BaseConstant.CONFIG_MVC_STATIC_PATH);
|
||||
//// System.out.println("设置static路径:"+path);
|
||||
//// registry.addResourceHandler("/static/**").addResourceLocations(path);
|
||||
//// }else {
|
||||
//// System.out.println("config static classpath");
|
||||
//// registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
|
||||
//// }
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authenticateHandle).addPathPatterns("/api/**");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.xboe.account.dao;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 账号信息DAO
|
||||
*/
|
||||
@Repository
|
||||
public class AccountDao extends BaseDao<Account> {
|
||||
|
||||
/**
|
||||
* 按登录名查询账号
|
||||
*
|
||||
* @param loginName
|
||||
* @return
|
||||
*/
|
||||
public Account findByLoginName(String loginName) {
|
||||
return this.findOne(FieldFilters.eq("loginName", loginName), FieldFilters.eq("deleted", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查账号是否存在
|
||||
*
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
public boolean checkAccount(String sysId) {
|
||||
return this.count(FieldFilters.eq("sysId", sysId)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否有相同的账号名,不包括删除的记录
|
||||
*
|
||||
* @param loginName 被检查的账号名称
|
||||
* @param excludeId 需要排除的ID,可以是多个
|
||||
* @return 返回查询到的数据,有则表示有冲突
|
||||
*/
|
||||
public Account check(String loginName, String excludeId) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
if (StringUtil.isNotBlank(loginName)) {
|
||||
filters.add(FieldFilters.eq("loginName", loginName));
|
||||
}
|
||||
if (StringUtil.isNotBlank(excludeId)) {
|
||||
filters.add(FieldFilters.notIn("id", Arrays.asList(excludeId)));
|
||||
}
|
||||
List<Account> list = this.findList(filters.toArray(new IFieldFilter[filters.size()]));
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据旧系统ID查询数据
|
||||
*
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
public Account getBySysId(String sysId) {
|
||||
return this.findOne(FieldFilters.eq("sysId", sysId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.xboe.account.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 账号表,只是记录登录的账号信息,无任务业务实名类的信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "account")
|
||||
public class Account extends IdEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@MetaInfo("原系统中的id")
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
@MetaInfo("登录名")
|
||||
@Column(name = "login_name", nullable = true, length = 30)
|
||||
private String loginName;
|
||||
|
||||
@MetaInfo("用户头像地址")
|
||||
@Column(name = "avatar", nullable = true, length = 100)
|
||||
private String avatar;
|
||||
|
||||
@MetaInfo("手机号")
|
||||
@Column(name = "mobile", length = 11)
|
||||
private String mobile;
|
||||
|
||||
@Column(name = "email", length = 100)
|
||||
private String email;
|
||||
|
||||
@Column(name = "nick_name", length = 20)
|
||||
private String nickName;
|
||||
|
||||
@Column(name = "pass_key", length = 6)
|
||||
private String passKey;
|
||||
|
||||
@Column(name = "pass_value", length = 32)
|
||||
private String passValue;
|
||||
|
||||
@Column(name = "reg_time" )
|
||||
private LocalDateTime regTime;
|
||||
|
||||
@MetaInfo("关联的公司id")
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
// 状态1, 正常,2停用
|
||||
@Column(name = "status", length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "deleted", length = 1)
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.xboe.account.service;
|
||||
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 账号接口
|
||||
*/
|
||||
public interface IAccountService {
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Account get(String id);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Account getBySysId(String id);
|
||||
|
||||
/**
|
||||
* 按登录名查询账号
|
||||
*
|
||||
* @param loginName
|
||||
* @return
|
||||
*/
|
||||
Account findByLoginName(String loginName);
|
||||
|
||||
/**
|
||||
* 检查是否有相同的账号名,不包括删除的记录
|
||||
*
|
||||
* @param loginName 被检查的账号名称
|
||||
* @param excludeId 需要排除的ID,可以是多个
|
||||
* @return 返回查询到的数据,有则表示有冲突
|
||||
*/
|
||||
Account check(String loginName, String excludeId);
|
||||
|
||||
/**
|
||||
* 检查账号是否存在
|
||||
*
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
boolean checkAccount(String sysId);
|
||||
|
||||
/**
|
||||
* 保持
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void save(Account account);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void update(Account account);
|
||||
|
||||
/**
|
||||
* 修改头像和昵称
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void updateAvatarAndNickName(Account account);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param id
|
||||
* @param oldPass
|
||||
* @param newPass
|
||||
* @throws XaskException
|
||||
*/
|
||||
void updatePass(String id,String oldPass,String newPass)throws XaskException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 传入的参数需要有id和loginName的值用于清除缓存
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void delete(Account account);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.xboe.account.service.impl;
|
||||
|
||||
import com.xboe.account.dao.AccountDao;
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.utils.MD5Util;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class AccountServiceImpl implements IAccountService {
|
||||
|
||||
@Resource
|
||||
AccountDao dao;
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT + "'+#id", unless = "#result == null")
|
||||
public Account get(String id) {
|
||||
// 密码不能返回前端
|
||||
Account account = dao.get(id);
|
||||
if(account!=null) {
|
||||
Account result = new Account();
|
||||
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||
return result;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account getBySysId(String id){
|
||||
// 密码不能返回前端
|
||||
Account account = dao.getBySysId(id);
|
||||
if(account!=null) {
|
||||
Account result = new Account();
|
||||
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||
return result;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT_LOGINNAME + "'+#loginName", unless = "#result == null")
|
||||
public Account findByLoginName(String loginName) {
|
||||
Account account = dao.findByLoginName(loginName);
|
||||
|
||||
Account result = new Account();
|
||||
if(account == null){
|
||||
return result;
|
||||
}
|
||||
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account check(String loginName, String excludeId) {
|
||||
return dao.check(loginName, excludeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAccount(String sysId) {
|
||||
return dao.checkAccount(sysId);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT + "'+#account.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT_LOGINNAME + "'+#account.loginName")})
|
||||
@Override
|
||||
public void save(Account account) {
|
||||
// 新增账号时初始化默认密码
|
||||
String passKey = StringUtil.generateString(6);
|
||||
account.setPassKey(passKey);
|
||||
String defaultPass = "666666";
|
||||
account.setPassValue(MD5Util.MD5Encode(defaultPass + passKey));
|
||||
dao.save(account);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT + "'+#account.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT_LOGINNAME + "'+#account.loginName")})
|
||||
@Override
|
||||
public void update(Account account) {
|
||||
// 修改时不修改密码,修改密码单独操作
|
||||
Account old = dao.get(account.getId());
|
||||
BeanUtils.copyProperties(account,old,"passKey","passValue");
|
||||
dao.update(old);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT + "'+#account.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT_LOGINNAME + "'+#account.loginName")})
|
||||
@Override
|
||||
public void updateAvatarAndNickName(Account account) {
|
||||
dao.updateMultiFieldById(account.getId(),
|
||||
UpdateBuilder.create("avatar",account.getAvatar()),
|
||||
UpdateBuilder.create("nickName",account.getNickName())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePass(String id,String oldPass,String newPass)throws XaskException {
|
||||
Account old = dao.get(id);
|
||||
String passStr = MD5Util.MD5Encode(oldPass + old.getPassKey());
|
||||
if(!passStr.equals(old.getPassValue())){
|
||||
throw new XaskException("原密码错误");
|
||||
}
|
||||
String passKey = StringUtil.generateString(6);
|
||||
old.setPassKey(passKey);
|
||||
old.setPassValue(MD5Util.MD5Encode(newPass + passKey));
|
||||
dao.update(old);
|
||||
}
|
||||
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT + "'+#account.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_ACCOUNT_LOGINNAME + "'+#account.loginName")})
|
||||
@Override
|
||||
public void delete(Account account) {
|
||||
dao.setDeleted(account.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xboe.config;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
|
||||
/**
|
||||
* @author roc
|
||||
*/
|
||||
@Configuration
|
||||
public class LocalDateTimeConfiguration {
|
||||
|
||||
private String pattern="yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
return builder -> {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
|
||||
//返回时间数据序列化
|
||||
builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
|
||||
//接收时间数据反序列化
|
||||
builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.xboe.constants;
|
||||
|
||||
public interface CacheName {
|
||||
|
||||
/**
|
||||
* 认证缓存
|
||||
* 其下放和认证相关的缓存
|
||||
*/
|
||||
String NAME_AUTH= "auth";
|
||||
|
||||
/**
|
||||
* 验证码key前缀
|
||||
*/
|
||||
String CAPTCHA_KEY = "captcha:";
|
||||
|
||||
/**
|
||||
* 用户缓存
|
||||
* 其下放和用户相关的缓存,包括账户、教师等
|
||||
*/
|
||||
String NAME_USER = "user";
|
||||
|
||||
/**
|
||||
* 用户名缓存KEY前缀
|
||||
*/
|
||||
String KEY_USER_NAME = "user:name:";
|
||||
|
||||
/**
|
||||
* sysid缓存KEY前缀
|
||||
*/
|
||||
String KEY_USER_SYSID = "user:sysid:";
|
||||
|
||||
/**
|
||||
* 用户ID缓存KEY前缀
|
||||
*/
|
||||
String KEY_USER = "user:";
|
||||
|
||||
/**
|
||||
* 账号ID缓存KEY前缀
|
||||
*/
|
||||
String KEY_ACCOUNT = "account:";
|
||||
|
||||
/**
|
||||
* 账号名缓存KEY前缀
|
||||
*/
|
||||
String KEY_ACCOUNT_LOGINNAME = "account:loginName:";
|
||||
|
||||
/**
|
||||
* 机构缓存
|
||||
* 其下放和机构相关的缓存
|
||||
*/
|
||||
String NAME_ORG = "org";
|
||||
|
||||
/**
|
||||
* 机构ID缓存KEY前缀
|
||||
*/
|
||||
String KEY_ORG = "org:";
|
||||
|
||||
/**
|
||||
* 机构ID查询机构名称缓存KEY前缀
|
||||
*/
|
||||
String KEY_ORGNAME = "orgname:";
|
||||
|
||||
/**
|
||||
* 考试缓存
|
||||
* 其下放和考试相关的缓存
|
||||
*/
|
||||
String NAME_EXAM = "exam";
|
||||
|
||||
/**
|
||||
* 考试key前缀
|
||||
*/
|
||||
String EXAM_KEY = "exam:";
|
||||
|
||||
/**
|
||||
* 试卷内容key前缀
|
||||
*/
|
||||
String PAPAER_CONTENT_KEY = "papercontent:";
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.xboe.constants;
|
||||
|
||||
public interface Constants {
|
||||
|
||||
// 标签管理
|
||||
|
||||
/**
|
||||
* 标签类型 - 系统
|
||||
*/
|
||||
Integer TAG_TYPE_SYS = 1;
|
||||
|
||||
/**
|
||||
* 标签类型 - 自定义
|
||||
*/
|
||||
Integer TAG_TYPE_CUST = 2;
|
||||
|
||||
/**
|
||||
* 筛选项 - 是
|
||||
*/
|
||||
Boolean TAG_FILTER_YES = true;
|
||||
|
||||
/**
|
||||
* 筛选项 - 不是
|
||||
*/
|
||||
Boolean TAG_FILTER_NO = false;
|
||||
|
||||
// 组织机构
|
||||
/**
|
||||
* 机构状态 临时
|
||||
*/
|
||||
Integer ORGANIZATION_STATUS_TEMPORARY = 0;
|
||||
|
||||
/**
|
||||
* 机构状态 正常
|
||||
*/
|
||||
Integer ORGANIZATION_STATUS_NORMAL = 1;
|
||||
|
||||
/**
|
||||
* 机构状态 停用
|
||||
*/
|
||||
Integer ORGANIZATION_STATUS_DEACTIVATE = 2;
|
||||
|
||||
/**
|
||||
* 账号状态 正常
|
||||
*/
|
||||
Integer ACCOUNT_STATUS_NORMAL = 1;
|
||||
|
||||
/**
|
||||
* 账号状态 停用
|
||||
*/
|
||||
Integer ACCOUNT_STATUS_DEACTIVATE = 2;
|
||||
|
||||
/**
|
||||
* 体系目录 1:组织体系目录
|
||||
*/
|
||||
Integer RES_SYS_ORG = 1;
|
||||
|
||||
/**
|
||||
* 体系目录 2:培训体系目录
|
||||
*/
|
||||
Integer RES_SYS_TRAIN = 2;
|
||||
|
||||
/**
|
||||
* 性别 男
|
||||
*/
|
||||
Integer SEX_MALE = 1;
|
||||
|
||||
/**
|
||||
* 性别 女
|
||||
*/
|
||||
Integer SEX_FEMALE = 2;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,
|
||||
*/
|
||||
Integer USER_TYPE_STUDENT = 1;
|
||||
|
||||
/**
|
||||
* 用户类型,2表教师,
|
||||
*/
|
||||
Integer USER_TYPE_TEACHER = 2;
|
||||
|
||||
/**
|
||||
* 用户类型,3表管理员
|
||||
*/
|
||||
Integer USER_TYPE_ADMIN = 3;
|
||||
|
||||
/**
|
||||
* 试题类型 1单选
|
||||
*/
|
||||
Integer QUESTION_TYPE_SINGLE = 1;
|
||||
|
||||
/**
|
||||
* 试题类型 2,多选
|
||||
*/
|
||||
Integer QUESTION_TYPE_MULTIPLE = 2;
|
||||
|
||||
/**
|
||||
* 试题类型 3.判断
|
||||
*/
|
||||
Integer QUESTION_TYPE_JUDGE = 3;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.externalinterface.system.service;
|
||||
|
||||
import com.xboe.externalinterface.system.vo.FwOrganization;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.vo.OrganizationVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调用旧系统的外部接口
|
||||
*/
|
||||
public interface IFwOrganizationService {
|
||||
|
||||
/**
|
||||
* 按id查询
|
||||
*
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
Organization getById(String kid);
|
||||
|
||||
/**
|
||||
* 查询指定条数的数据
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param org
|
||||
* @return
|
||||
*/
|
||||
List<Organization> list(Integer pageIndex, Integer pageSize, FwOrganization org);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xboe.externalinterface.system.service;
|
||||
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调用旧系统的外部接口
|
||||
*/
|
||||
public interface IFwUserService {
|
||||
|
||||
/**
|
||||
* 按id查询旧系统用户并转成系统user对象
|
||||
*
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
UserVo getById(String kid);
|
||||
|
||||
/**
|
||||
* 按用户名查询旧系统用户并转成系统user对象
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
UserVo getByUserName(String userName);
|
||||
|
||||
List<UserVo> list(Integer pageIndex, Integer pageSize);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.externalinterface.system.service;
|
||||
|
||||
import com.xboe.externalinterface.system.vo.LnTeacher;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.module.teacher.vo.TeacherVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调用旧系统的外部接口
|
||||
*/
|
||||
public interface ILnTeacherService {
|
||||
|
||||
/**
|
||||
* 按id查询
|
||||
*
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
TeacherVo getById(String kid);
|
||||
|
||||
/**
|
||||
* 查询指定条数的数据
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param tes
|
||||
* @return
|
||||
*/
|
||||
List<TeacherVo> list(Integer pageIndex, Integer pageSize, LnTeacher tes);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.xboe.externalinterface.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.externalinterface.system.service.IFwOrganizationService;
|
||||
import com.xboe.externalinterface.system.vo.FwOrganization;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FwOrganizationServiceImpl implements IFwOrganizationService {
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
@Override
|
||||
public Organization getById(String kid) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/org/get";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("kid", kid);
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToEntity(responseStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Organization> list(Integer pageIndex, Integer pageSize, FwOrganization org) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/org/list";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("pageIndex", String.valueOf(pageIndex));
|
||||
params.put("pageSize", String.valueOf(pageSize));
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToEntityList(responseStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求返回值,OrganizationVo
|
||||
*
|
||||
* @param responseStr
|
||||
* @return
|
||||
*/
|
||||
private Organization responseToEntity(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<FwOrganization> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<FwOrganization>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null) {
|
||||
return this.organizationToEntity(rr.getResult());
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求返回值,List<Organization>
|
||||
*
|
||||
* @param responseStr
|
||||
* @return
|
||||
*/
|
||||
private List<Organization> responseToEntityList(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<List<FwOrganization>> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<List<FwOrganization>>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null && rr.getResult().size() > 0) {
|
||||
List<Organization> result = new ArrayList<>();
|
||||
for (FwOrganization org : rr.getResult()) {
|
||||
result.add(this.organizationToEntity(org));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转换
|
||||
*
|
||||
* @param org
|
||||
* @return
|
||||
*/
|
||||
private Organization organizationToEntity(FwOrganization org) {
|
||||
Organization ov = new Organization();
|
||||
// ov.setChildren();
|
||||
// ov.setParentName();
|
||||
ov.setCode(org.getOrgnizationCode());
|
||||
ov.setName(org.getOrgnizationName());
|
||||
ov.setSysId(org.getKid());
|
||||
ov.setSysParentId(org.getParentOrgnizationId());
|
||||
ov.setDescription(org.getDescription());
|
||||
ov.setCompanyId(org.getCompanyId());
|
||||
ov.setDomainId(org.getDomainId());
|
||||
ov.setNamePath(org.getNamePath());
|
||||
ov.setOrgnizationManagerId(org.getOrgnizationManagerId());
|
||||
ov.setOrganizationLevel(org.getOrganizationLevel());
|
||||
if(StringUtils.isNotBlank(org.getIsMakeOrg())){
|
||||
ov.setIsMakeOrg("1".equals(org.getIsMakeOrg()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getIsServiceSite())) {
|
||||
ov.setIsServiceSite("1".equals(org.getIsServiceSite()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getIsDefaultOrganization())) {
|
||||
ov.setIsDefaultOrganization("1".equals(org.getIsDefaultOrganization()));//0:否,1:是
|
||||
}
|
||||
if(StringUtils.isNotBlank(org.getStatus())) {
|
||||
ov.setStatus(Integer.parseInt(org.getStatus()));
|
||||
}else{
|
||||
ov.setStatus(1);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(org.getIsDeleted())) {
|
||||
ov.setDeleted("1".equals(org.getIsDeleted())); //0:正常,1:已删除
|
||||
}
|
||||
return ov;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.xboe.externalinterface.system.service.impl;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.constants.Constants;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.externalinterface.system.vo.FwUser;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FwUserServiceImpl implements IFwUserService {
|
||||
|
||||
@Autowired
|
||||
IOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
@Override
|
||||
public UserVo getById(String kid) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/user/get";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("kid", kid);
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToVo(responseStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVo getByUserName(String userName) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/user/get-by-username";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("userName", userName);
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToVo(responseStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVo> list(Integer pageIndex, Integer pageSize) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/user/list";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("pageIndex", String.valueOf(pageIndex));
|
||||
params.put("pageSize", String.valueOf(pageSize));
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToList(responseStr);
|
||||
}
|
||||
|
||||
private List<UserVo> responseToList(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<List<FwUser>> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<List<FwUser>>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null && rr.getResult().size() > 0) {
|
||||
List<UserVo> result = new ArrayList<>();
|
||||
for (FwUser fu : rr.getResult()) {
|
||||
result.add(this.userToEntity(fu));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求返回值,将其转换为UserVo
|
||||
*
|
||||
* @param responseStr
|
||||
* @return
|
||||
*/
|
||||
private UserVo responseToVo(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<FwUser> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<FwUser>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null) {
|
||||
return this.userToEntity(rr.getResult());
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private UserVo userToEntity(FwUser u){
|
||||
UserVo uv = new UserVo();
|
||||
Account account = new Account();
|
||||
account.setSysId(u.getKid());
|
||||
account.setLoginName(u.getUserName());
|
||||
account.setMobile(u.getMobileNo());
|
||||
account.setEmail(u.getEmail());
|
||||
account.setNickName(u.getNickName());
|
||||
if(StringUtils.isNotBlank(u.getThumb())) {
|
||||
account.setAvatar(u.getThumb().substring(7));
|
||||
}
|
||||
// account.setPassKey();
|
||||
// account.setPassValue();
|
||||
// account.setRegTime();
|
||||
account.setCompanyId(u.getCompanyId());
|
||||
Integer status = 1;//1:正常,2:停用
|
||||
if (StringUtils.isNotBlank(u.getStatus()) && "2".equals(u.getStatus())) {
|
||||
status = 2;
|
||||
}
|
||||
account.setStatus(status);//系统中只有正常和停用,同步时非停用状态都设置为正常
|
||||
if(StringUtils.isNotBlank(u.getIsDeleted())) {
|
||||
account.setDeleted("1".equals(u.getIsDeleted())); //0:正常,1:已删除
|
||||
}
|
||||
|
||||
uv.setAccount(account);
|
||||
if(StringUtils.isBlank(u.getOrgnizationId())) {
|
||||
log.error("用户无机构信息:"+u.getUserName());
|
||||
}else {
|
||||
Organization org = organizationService.getBySysId(u.getOrgnizationId());
|
||||
if(org != null) {
|
||||
uv.setDepartId(org.getId()); //此处不设置,使用的地方再查询
|
||||
uv.setDepartName(org.getName());
|
||||
}
|
||||
}
|
||||
uv.setSysId(u.getKid());
|
||||
uv.setSysDepartId(u.getOrgnizationId());
|
||||
uv.setName(u.getRealName());
|
||||
uv.setUserNo(u.getUserNo());
|
||||
if (StringUtils.isNotBlank(u.getGender())) {
|
||||
uv.setGender(u.getGender().equals("male") ? Constants.SEX_MALE : u.getGender().equals("female") ? Constants.SEX_FEMALE : null);
|
||||
}
|
||||
if(u.getBirthday() != null) {
|
||||
uv.setBirthday(u.getBirthday().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||
}
|
||||
uv.setIdNumber(u.getIdNumber());
|
||||
uv.setMobileNo(u.getMobileNo());
|
||||
uv.setHomePhoneNo(u.getHomePhoneNo());
|
||||
uv.setNationality(u.getNationality());
|
||||
uv.setGraduatedFrom(u.getGraduatedFrom());
|
||||
uv.setGraduatedMajor(u.getGraduatedMajor());
|
||||
uv.setHighestEducation(u.getHighestEducation());
|
||||
uv.setTelephoneNo(u.getTelephoneNo());
|
||||
uv.setDuty(u.getDuty());
|
||||
uv.setRank(u.getRank());
|
||||
uv.setDescription(u.getDescription());
|
||||
uv.setCompanyId(u.getCompanyId());
|
||||
uv.setDomainId(u.getDomainId());
|
||||
// uv.setSassId("");
|
||||
// uv.setUserType();
|
||||
if(u.getLearningDuration()!=null) {
|
||||
uv.setLearningDuration(u.getLearningDuration().intValue());
|
||||
}else {
|
||||
uv.setLearningDuration(0);
|
||||
}
|
||||
// uv.setLastLoginAt(LocalDateTime.ofInstant(u.getLastLoginAt().toInstant(),ZoneId.systemDefault()));
|
||||
// uv.setLastLoginIp(u.getLastLoginIp());
|
||||
// uv.setLastLoginMac(u.getLastLoginMac());
|
||||
// uv.setLastActionAt(LocalDateTime.ofInstant(u.getLastActionAt().toInstant(),ZoneId.systemDefault()));
|
||||
// uv.setLastActionIp(u.getLastActionIp());
|
||||
// uv.setLastActionMac(u.getLastActionMac());
|
||||
// uv.setOnline();
|
||||
return uv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.xboe.externalinterface.system.service.impl;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.externalinterface.system.service.ILnTeacherService;
|
||||
import com.xboe.externalinterface.system.vo.LnTeacher;
|
||||
import com.xboe.module.teacher.vo.TeacherVo;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LnTeacherServiceImpl implements ILnTeacherService {
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
@Autowired
|
||||
private IFwUserService fwUserService;
|
||||
|
||||
@Override
|
||||
public TeacherVo getById(String kid) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/teacher/get";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("kid", kid);
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToEntity(responseStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TeacherVo> list(Integer pageIndex, Integer pageSize, LnTeacher tea) {
|
||||
String url = SysConstant.getConfigValue(BaseConstant.CONFIG_EXTERNALINTERFACE_URL_SYSTEM) + "/xboe-org/teacher/list";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("pageIndex", String.valueOf(pageIndex));
|
||||
params.put("pageSize", String.valueOf(pageSize));
|
||||
String responseStr = okHttpUtil.doGet(url, params);
|
||||
return this.responseToEntityList(responseStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求返回值,LnTeacher
|
||||
*
|
||||
* @param responseStr
|
||||
* @return
|
||||
*/
|
||||
private TeacherVo responseToEntity(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<LnTeacher> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<LnTeacher>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null) {
|
||||
return this.teacherToEntity(rr.getResult());
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求返回值,List<LnTeacher>
|
||||
*
|
||||
* @param responseStr
|
||||
* @return
|
||||
*/
|
||||
private List<TeacherVo> responseToEntityList(String responseStr) {
|
||||
if (StringUtils.isNotBlank(responseStr)) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
JsonResponse<List<LnTeacher>> rr = objectMapper.readValue(responseStr, new TypeReference<JsonResponse<List<LnTeacher>>>() {
|
||||
});
|
||||
if (rr.getStatus() == HttpStatus.OK.value() && rr.getResult() != null && rr.getResult().size() > 0) {
|
||||
List<TeacherVo> result = new ArrayList<>();
|
||||
for (LnTeacher tea : rr.getResult()) {
|
||||
result.add(this.teacherToEntity(tea));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("调用远程接口失败" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转换
|
||||
*
|
||||
* @param lnTea
|
||||
* @return
|
||||
*/
|
||||
private TeacherVo teacherToEntity(LnTeacher lnTea) {
|
||||
TeacherVo tea = new TeacherVo();
|
||||
tea.setSysId(lnTea.getKid());
|
||||
tea.setName(lnTea.getTeacherName());
|
||||
if(lnTea.getBirthday()!=null) {
|
||||
Instant instant = lnTea.getBirthday().toInstant();
|
||||
LocalDate ld = instant.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
tea.setBirthday(ld);
|
||||
}
|
||||
tea.setCompanyId(lnTea.getCompanyId());
|
||||
//tea.setCourses(lnTe);
|
||||
|
||||
// tea.setPersonalLabel();
|
||||
|
||||
// tea.setSuperiorManager();
|
||||
// tea.setAddress();
|
||||
tea.setDescription(lnTea.getDescription());
|
||||
tea.setTeaching(lnTea.getTeachingTime() != null ?lnTea.getTeachingTime().toString() : "");
|
||||
//tea.setWaitStatus(lnTea.getStatus());
|
||||
|
||||
//只取有工号的教师
|
||||
if(StringUtil.isNotBlank(lnTea.getUserNo())) {
|
||||
UserVo userVo = fwUserService.getById(lnTea.getUserId());
|
||||
if (userVo != null) {
|
||||
tea.setOperatingPost(userVo.getDuty());
|
||||
tea.setAccount(userVo.getAccount());
|
||||
tea.setUser(new User());
|
||||
BeanUtils.copyProperties(userVo, tea.getUser());
|
||||
}
|
||||
}
|
||||
|
||||
return tea;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.xboe.externalinterface.system.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 接口返回对象
|
||||
*/
|
||||
@Data
|
||||
public class FwOrganization {
|
||||
|
||||
/**
|
||||
* 组织部门ID
|
||||
*/
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 树节点ID
|
||||
*/
|
||||
private String treeNodeId;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
private String parentOrgnizationId;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 域ID
|
||||
*/
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
private String orgnizationCode;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
private String orgnizationName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别
|
||||
*/
|
||||
private String organizationLevel;
|
||||
|
||||
/**
|
||||
* 是否制造组织
|
||||
*/
|
||||
private String isMakeOrg;
|
||||
|
||||
/**
|
||||
* 是否服务现地
|
||||
*/
|
||||
private String isServiceSite;
|
||||
|
||||
/**
|
||||
* 是否默认注册组织
|
||||
*/
|
||||
private String isDefaultOrganization;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0:临时,1:正常,2:停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 组织全路径
|
||||
*/
|
||||
private String namePath;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建来源
|
||||
*/
|
||||
private String createdFrom;
|
||||
|
||||
/**
|
||||
* 创建IP
|
||||
*/
|
||||
private String createdIp;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新来源
|
||||
*/
|
||||
private String updatedFrom;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
private String updatedIp;
|
||||
|
||||
/**
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
private String isDeleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,525 @@
|
||||
package com.xboe.externalinterface.system.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 接口返回对象
|
||||
*/
|
||||
@Data
|
||||
public class FwUser {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 系统用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
* male 男 female 女
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 主题
|
||||
*/
|
||||
private String theme;
|
||||
|
||||
/**
|
||||
* 授权密钥
|
||||
*/
|
||||
private String authKey;
|
||||
|
||||
/**
|
||||
* 密码Hash值
|
||||
*/
|
||||
private String passwordHash;
|
||||
|
||||
/**
|
||||
* 授权令牌
|
||||
*/
|
||||
private String authToken;
|
||||
|
||||
/**
|
||||
* Email地址
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 状态;0:临时,1:正常,2:停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 用户类型;0:初始化人员;1:超级管理员;2:普通用户
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobileNo;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 直线经理ID
|
||||
*/
|
||||
private String reportingManagerId;
|
||||
|
||||
/**
|
||||
* 语言信息
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* 时区信息
|
||||
*/
|
||||
private String timezone;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
private String nationality;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String thumb;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
private String graduatedFrom;
|
||||
|
||||
/**
|
||||
* 毕业专业
|
||||
*/
|
||||
private String graduatedMajor;
|
||||
|
||||
/**
|
||||
* 最高学历
|
||||
*/
|
||||
private String highestEducation;
|
||||
|
||||
/**
|
||||
* 招聘渠道
|
||||
*/
|
||||
private String recruitmentChannel;
|
||||
|
||||
/**
|
||||
* 招聘类型
|
||||
*/
|
||||
private String recruitmentType;
|
||||
|
||||
/**
|
||||
* 备用字段1
|
||||
*/
|
||||
private String memo1;
|
||||
|
||||
/**
|
||||
* 备用字段2
|
||||
*/
|
||||
private String memo2;
|
||||
|
||||
/**
|
||||
* 备用字段3
|
||||
*/
|
||||
private String memo3;
|
||||
|
||||
/**
|
||||
* 备用字段4
|
||||
*/
|
||||
private String memo4;
|
||||
|
||||
/**
|
||||
* 备用字段5
|
||||
*/
|
||||
private String memo5;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 代理用户信息
|
||||
*/
|
||||
private String additionalAccounts;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
private String telephoneNo;
|
||||
|
||||
/**
|
||||
* 员工状态
|
||||
*/
|
||||
private String employeeStatus;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date startWorkDay;
|
||||
|
||||
/**
|
||||
* 入企时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date onboardDay;
|
||||
|
||||
/**
|
||||
* 职务
|
||||
*/
|
||||
private String duty;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
private String rank;
|
||||
|
||||
/**
|
||||
* 工作地
|
||||
*/
|
||||
private String workPlace;
|
||||
|
||||
/**
|
||||
* 发薪地
|
||||
*/
|
||||
private String payrollPlace;
|
||||
|
||||
/**
|
||||
* 管理序列职级
|
||||
*/
|
||||
private String positionMgrLevel;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 组织部门ID
|
||||
*/
|
||||
private String orgnizationId;
|
||||
|
||||
/**
|
||||
* 计费中心ID
|
||||
*/
|
||||
private String costCenterId;
|
||||
|
||||
/**
|
||||
* 是否强制更新到email,1代表强制更新,0代表不强制更新
|
||||
*/
|
||||
private String toEmail;
|
||||
|
||||
/**
|
||||
* 备用邮箱
|
||||
*/
|
||||
private String email2;
|
||||
|
||||
/**
|
||||
* 是否强制更新到手机,1代表强制更新,0代表不强制更新
|
||||
*/
|
||||
private String toMobileNo;
|
||||
|
||||
/**
|
||||
* 备用手机号码
|
||||
*/
|
||||
private String mobileNo2;
|
||||
|
||||
/**
|
||||
* 是否有更新备用信息,1代表有更新,0代表没有更新
|
||||
*/
|
||||
private String isSpare;
|
||||
|
||||
/**
|
||||
* 所在域
|
||||
*/
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 经理标志;0:否;1:是
|
||||
*/
|
||||
private String managerFlag;
|
||||
|
||||
/**
|
||||
* 停用理由
|
||||
*/
|
||||
private String frozenReason;
|
||||
|
||||
/**
|
||||
* 账号激活令牌
|
||||
*/
|
||||
private String accountActiveToken;
|
||||
|
||||
/**
|
||||
* 登录失败次数
|
||||
*/
|
||||
private Integer failedLoginTimes;
|
||||
|
||||
/**
|
||||
* 登录失败开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date failedLoginStartAt;
|
||||
|
||||
/**
|
||||
* 最近一次登录失败时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date failedLoginLastAt;
|
||||
|
||||
/**
|
||||
* 登录失败原因
|
||||
*/
|
||||
private String failedLoginReason;
|
||||
|
||||
/**
|
||||
* 索回密码请求时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date findPwdReqAt;
|
||||
|
||||
/**
|
||||
* 临时密码
|
||||
*/
|
||||
private String findPwdTmpKey;
|
||||
|
||||
/**
|
||||
* 临时密码过期时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date findPwdExpAt;
|
||||
|
||||
/**
|
||||
* 密码重置令牌
|
||||
*/
|
||||
private String passwordResetToken;
|
||||
|
||||
/**
|
||||
* 登陆时是否强制需要修改密码;0:否;1:是
|
||||
*/
|
||||
private String needPwdChange;
|
||||
|
||||
/**
|
||||
* 最近一次修改密码时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastPwdChangeAt;
|
||||
|
||||
/**
|
||||
* 最近一次修改密码原因
|
||||
*/
|
||||
private String lastPwdChangeReason;
|
||||
|
||||
/**
|
||||
* 最近一次登录时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastLoginAt;
|
||||
|
||||
/**
|
||||
* 最近一次登录IP
|
||||
*/
|
||||
private String lastLoginIp;
|
||||
|
||||
/**
|
||||
* 最近一次登录MAC地址
|
||||
*/
|
||||
private String lastLoginMac;
|
||||
|
||||
/**
|
||||
* 最近一次操作时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastActionAt;
|
||||
|
||||
/**
|
||||
* 最近一次操作IP
|
||||
*/
|
||||
private String lastActionIp;
|
||||
|
||||
/**
|
||||
* 最近一次操作MAC地址
|
||||
*/
|
||||
private String lastActionMac;
|
||||
|
||||
/**
|
||||
* 在线状态;0:离线,1:在线
|
||||
*/
|
||||
private String onlineStatus;
|
||||
|
||||
/**
|
||||
* 有效期开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date validStartAt;
|
||||
|
||||
/**
|
||||
* 有效期结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date validEndAt;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 登录次数
|
||||
*/
|
||||
private Integer loginNumber;
|
||||
|
||||
/**
|
||||
* 在线时长
|
||||
*/
|
||||
private Float onlineDuration;
|
||||
|
||||
/**
|
||||
* 学习时长
|
||||
*/
|
||||
private Float learningDuration;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer sequenceNumber;
|
||||
|
||||
/**
|
||||
* 离职类型
|
||||
*/
|
||||
private String dimissionType;
|
||||
|
||||
/**
|
||||
* 离职日期
|
||||
*/
|
||||
private String dimissionTime;
|
||||
|
||||
/**
|
||||
* band
|
||||
*/
|
||||
private String bandCode;
|
||||
|
||||
/**
|
||||
* band描述
|
||||
*/
|
||||
private String bandDesc;
|
||||
|
||||
/**
|
||||
* band方向
|
||||
*/
|
||||
private String bandDirection;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建来源
|
||||
*/
|
||||
private String createdFrom;
|
||||
|
||||
/**
|
||||
* 创建IP
|
||||
*/
|
||||
private String createdIp;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新来源
|
||||
*/
|
||||
private String updatedFrom;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
private String updatedIp;
|
||||
|
||||
/**
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
private String isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
package com.xboe.externalinterface.system.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 教师信息表
|
||||
*/
|
||||
@Data
|
||||
public class LnTeacher {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 企业
|
||||
*/
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 教师编码
|
||||
*/
|
||||
private String teacherCode;
|
||||
|
||||
/**
|
||||
* 教师姓名
|
||||
*/
|
||||
private String teacherName;
|
||||
|
||||
/**
|
||||
* 教师昵称
|
||||
*/
|
||||
private String teacherNick;
|
||||
|
||||
/**
|
||||
* 教师类型
|
||||
*/
|
||||
private String teacherType;
|
||||
|
||||
/**
|
||||
* 教师级别
|
||||
*/
|
||||
private String teacherLevel;
|
||||
|
||||
/**
|
||||
* 教师级别ID
|
||||
*/
|
||||
private String teacherLevelId;
|
||||
|
||||
/**
|
||||
* 职称
|
||||
*/
|
||||
private String teacherTitle;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String teacherThumbUrl;
|
||||
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 学历
|
||||
*/
|
||||
private String degree;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
private String graduateSchool;
|
||||
|
||||
/**
|
||||
* 教龄
|
||||
*/
|
||||
private Float teachYear;
|
||||
|
||||
/**
|
||||
* 领域
|
||||
*/
|
||||
private String teachDomain;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobileNo;
|
||||
|
||||
/**
|
||||
* Email地址
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 语言
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* 时区
|
||||
*/
|
||||
private String timezone;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String dataFrom;
|
||||
|
||||
/**
|
||||
* 系统ID
|
||||
*/
|
||||
private String systemId;
|
||||
|
||||
/**
|
||||
* 系统名称
|
||||
*/
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 教授时间
|
||||
*/
|
||||
private Integer teachingTime;
|
||||
|
||||
/**
|
||||
* 默认教授时间
|
||||
*/
|
||||
private Integer defaultTeachingTime;
|
||||
|
||||
/**
|
||||
* 级别id
|
||||
*/
|
||||
private String levelId;
|
||||
|
||||
/**
|
||||
* 级别名称
|
||||
*/
|
||||
private String levelName;
|
||||
|
||||
/**
|
||||
* 语言
|
||||
*/
|
||||
private String isCertify;
|
||||
|
||||
private String certificatio;
|
||||
|
||||
private String certifyAt;
|
||||
|
||||
private String certifyBy;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建来源
|
||||
*/
|
||||
private String createdFrom;
|
||||
|
||||
/**
|
||||
* 创建IP
|
||||
*/
|
||||
private String createdIp;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新来源
|
||||
*/
|
||||
private String updatedFrom;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
private String updatedIp;
|
||||
|
||||
/**
|
||||
* 删除标记;0:正常,1:已删除
|
||||
*/
|
||||
private String isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xboe.module.searchterms.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.searchterms.entity.SearchTerms;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class SearchTermsDao extends BaseDao<SearchTerms> {
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xboe.module.searchterms.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.common.Pagination;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"search_terms")
|
||||
public class SearchTerms extends IdEntity {
|
||||
/**
|
||||
*搜索类型 1课程 2文章,3案例, 4问答
|
||||
* */
|
||||
@Column(name = "type",nullable = false)
|
||||
private Integer type;
|
||||
/**
|
||||
* 热门搜索关键词
|
||||
* */
|
||||
@Column(name = "keyword",nullable = false)
|
||||
private String keyword;
|
||||
/**
|
||||
* 搜索次数
|
||||
* */
|
||||
@Column(name = "counts",nullable = false)
|
||||
private Integer counts;
|
||||
|
||||
/**
|
||||
*存储时间
|
||||
* */
|
||||
@Column(name = "time",nullable = false)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xboe.module.searchterms.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public interface ISearchTermsService {
|
||||
|
||||
/**
|
||||
* 删除热门搜索词,在一定时间内的
|
||||
* */
|
||||
void delete(LocalDateTime nowTime);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xboe.module.searchterms.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.module.searchterms.dao.SearchTermsDao;
|
||||
import com.xboe.module.searchterms.service.ISearchTermsService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchTermsServiceImpl implements ISearchTermsService {
|
||||
|
||||
@Resource
|
||||
private SearchTermsDao dao;
|
||||
|
||||
/**
|
||||
* 删除热门搜索词
|
||||
* */
|
||||
@Override
|
||||
public void delete(LocalDateTime nowTime) {
|
||||
// 获取指定时间 当前时间
|
||||
LocalDateTime time = nowTime.plusDays(-15L);
|
||||
dao.deleteByFilter(FieldFilters.in("counts",1,2,3,4),
|
||||
FieldFilters.between("time",time,nowTime));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xboe.module.teacher.dao;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.LikeMatchMode;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Repository
|
||||
public class TeacherDao extends BaseDao<Teacher> {
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param teacher
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public PageList<Teacher> query(int pageIndex, int pageSize, Teacher teacher, OrderCondition order) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
if (teacher != null) {
|
||||
if (StringUtils.isNotBlank(teacher.getName())) {
|
||||
filters.add(FieldFilters.like("name", LikeMatchMode.ANYWHERE, teacher.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
return this.getGenericDao().findPage(pageIndex, pageSize, getEntityClass(), filters, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按姓名查询
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public List<Teacher> findByName(String name) {
|
||||
return this.findList(FieldFilters.like("name", name), FieldFilters.eq("deleted", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据旧系统ID查询数据
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
public Teacher getBySysId(String sysId) {
|
||||
return this.findOne(FieldFilters.eq("sysId", sysId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.xboe.module.teacher.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "teacher")
|
||||
public class Teacher extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@OneToOne(cascade = {}, fetch = FetchType.LAZY)
|
||||
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 系统id
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 所属机构
|
||||
*/
|
||||
@Column(name = "depart_id", length = 18)
|
||||
private String departId;
|
||||
|
||||
/**
|
||||
* 性别 1:男 2:女
|
||||
*/
|
||||
@Column(name = "gender", length = 1)
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@Column(name = "id_number", length = 18)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@Column(name = "birthday")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthday;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile", length = 11)
|
||||
private String mobile;
|
||||
|
||||
@Column(name = "email", length = 100)
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
@Column(name = "home_phone_no", length = 50)
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 个人标签
|
||||
*/
|
||||
@Column(name = "personal_label", length = 100)
|
||||
private String personalLabel;
|
||||
|
||||
/**
|
||||
* 所在公司
|
||||
*/
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 所在域
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@Column(name = "operating_post", length = 100)
|
||||
private String operatingPost;
|
||||
|
||||
/**
|
||||
* 直线经理
|
||||
*/
|
||||
@Column(name = "superior_manager", length = 32)
|
||||
private String superiorManager;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
@Column(name = "address", length = 200)
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 授课时长
|
||||
*/
|
||||
@Column(name = "teaching")
|
||||
private String teaching;
|
||||
|
||||
/**
|
||||
* 在职状态
|
||||
* 在职: 0 离职: 1
|
||||
*/
|
||||
@Column(name = "wait_status")
|
||||
private String waitStatus;
|
||||
|
||||
/**
|
||||
* 擅长课程
|
||||
*/
|
||||
@Column(name = "courses")
|
||||
private String courses;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.xboe.module.teacher.service;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.module.teacher.vo.TeacherVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ITeacherService {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param entity
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
PageList<Teacher> query(Integer pageIndex, Integer pageSize, Teacher entity, OrderCondition order);
|
||||
|
||||
/**
|
||||
* 按姓名查询
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<Teacher> findByName(String name);
|
||||
|
||||
/**
|
||||
* 按ID查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Teacher get(String id);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param entity
|
||||
* @throws XaskException
|
||||
*/
|
||||
void save(TeacherVo entity) throws XaskException;
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param entity
|
||||
* @throws XaskException
|
||||
*/
|
||||
void update(TeacherVo entity) throws XaskException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void delete(String id);
|
||||
|
||||
/**
|
||||
* 按系统id查询
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
Teacher getBySysId(String sysId);
|
||||
|
||||
void syncTeacher(TeacherVo tea) throws XaskException;
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.xboe.module.teacher.service.impl;
|
||||
|
||||
import static org.springframework.transaction.annotation.Propagation.REQUIRED;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.constants.Constants;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.module.teacher.dao.TeacherDao;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.module.teacher.service.ITeacherService;
|
||||
import com.xboe.module.teacher.vo.TeacherVo;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class TeacherServiceImpl implements ITeacherService {
|
||||
|
||||
@Resource
|
||||
TeacherDao dao;
|
||||
|
||||
@Resource
|
||||
IAccountService accountService;
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
@Override
|
||||
public PageList<Teacher> query(Integer pageIndex, Integer pageSize, Teacher entity, OrderCondition order) {
|
||||
return dao.query(pageIndex, pageSize, entity, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher get(String id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Teacher> findByName(String name) {
|
||||
return dao.findByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRED,rollbackFor = Exception.class)
|
||||
public void save(TeacherVo entity) throws XaskException {
|
||||
|
||||
//已存在的用户,登录的用户名是工号,但是kid已经不一样了,也就是说sysId不一样了,这种情况是特殊的,一个人离职,再入职,工号一样,但是kid不一样了
|
||||
if (accountService.check(entity.getAccount().getLoginName(), entity.getAccount().getId()) != null) {// 检查是否已创建,使用sysManager的ID
|
||||
throw new XaskException("存在相同的登录名,账户设置为启用, 请检查");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(entity.getAccount().getId())) {
|
||||
Teacher old = dao.get(entity.getAccount().getId());
|
||||
if (old != null && !old.getDeleted()) {
|
||||
throw new XaskException("该用户已添加,不能重复添加");
|
||||
}
|
||||
}
|
||||
|
||||
if (accountService.checkAccount(entity.getAccount().getSysId())) {
|
||||
// 已有 账号和用户
|
||||
userService.update(entity.getUser());
|
||||
accountService.update(entity.getAccount());
|
||||
Teacher tea = this.setTeacher(entity);
|
||||
tea.setId(entity.getAccount().getId());
|
||||
dao.save(tea);
|
||||
|
||||
// 判断用户类型,如果是学员则改为教师
|
||||
User u = userService.get(tea.getId());
|
||||
if(u.getUserType().equals(Constants.USER_TYPE_STUDENT)){
|
||||
u.setUserType(Constants.USER_TYPE_TEACHER);
|
||||
userService.updateUserType(u);
|
||||
}
|
||||
} else {
|
||||
entity.getUser().setUserType(Constants.USER_TYPE_TEACHER);
|
||||
// 没有 账号和用户
|
||||
userService.save(entity.getUser());
|
||||
entity.getAccount().setId(entity.getUser().getId());
|
||||
entity.getAccount().setRegTime(LocalDateTime.now());
|
||||
accountService.save(entity.getAccount());
|
||||
Teacher tea = this.setTeacher(entity);
|
||||
tea.setId(entity.getAccount().getId());
|
||||
dao.save(tea);
|
||||
}
|
||||
}
|
||||
|
||||
private Teacher setTeacher(TeacherVo entity){
|
||||
Teacher tea = new Teacher();
|
||||
tea.setSysId(entity.getSysId());
|
||||
tea.setName(entity.getUser().getName());
|
||||
tea.setDepartId(entity.getUser().getDepartId());
|
||||
tea.setGender(entity.getUser().getGender());
|
||||
tea.setIdNumber(entity.getUser().getIdNumber());
|
||||
tea.setBirthday(entity.getUser().getBirthday());
|
||||
tea.setMobile(entity.getUser().getMobileNo());
|
||||
tea.setEmail(entity.getAccount().getEmail());
|
||||
tea.setHomePhoneNo(entity.getUser().getHomePhoneNo());
|
||||
tea.setPersonalLabel(entity.getPersonalLabel());
|
||||
tea.setCompanyId(entity.getUser().getCompanyId());
|
||||
tea.setDomainId(entity.getUser().getDomainId());
|
||||
tea.setOperatingPost(entity.getOperatingPost());
|
||||
tea.setSuperiorManager(entity.getSuperiorManager());
|
||||
tea.setAddress(entity.getAddress());
|
||||
tea.setDescription(entity.getDescription());
|
||||
tea.setTeaching(entity.getTeaching());
|
||||
tea.setWaitStatus(entity.getWaitStatus());
|
||||
return tea;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRED,rollbackFor = Exception.class)
|
||||
public void update(TeacherVo entity) throws XaskException {
|
||||
Teacher teacher = new Teacher();
|
||||
BeanUtils.copyProperties(entity, teacher, "account");
|
||||
dao.update(teacher);
|
||||
Account account = accountService.get(teacher.getId());
|
||||
account.setAvatar(entity.getAccount().getAvatar());
|
||||
accountService.update(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
dao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher getBySysId(String sysId){
|
||||
return dao.getBySysId(sysId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncTeacher(TeacherVo tea)throws XaskException{
|
||||
//先检查是否本地库有,有则更新
|
||||
Teacher old = this.getBySysId(tea.getSysId());
|
||||
if (old != null){
|
||||
if(old.getUser()==null) {
|
||||
//教师信息有,但是没有用户信息,这个怎么回事,kid不同了会有这种情况
|
||||
}
|
||||
Teacher teacher = this.setTeacher(tea);
|
||||
BeanUtils.copyProperties(teacher,old,"id");
|
||||
dao.update(old);
|
||||
Account account = accountService.get(old.getId());
|
||||
account.setCompanyId(tea.getAccount().getCompanyId());
|
||||
account.setEmail(tea.getAccount().getEmail());
|
||||
account.setMobile(tea.getAccount().getMobile());
|
||||
account.setNickName(tea.getAccount().getNickName());
|
||||
if(StringUtils.isBlank(account.getAvatar())){//没有头像才更新
|
||||
account.setAvatar(tea.getAccount().getAvatar());
|
||||
}
|
||||
accountService.update(account);
|
||||
tea.getUser().setId(account.getId());
|
||||
userService.update(tea.getUser());
|
||||
}else{
|
||||
// 如果返回的账号和用户信息是空则不执行(测试环境会有这中情况)
|
||||
if(tea.getAccount() == null || tea.getUser() == null){
|
||||
throw new XaskException("原数据中无教师关联的用户信息,不能同步");
|
||||
//return;
|
||||
}
|
||||
// 先查询是否有账号,这里会出现多个教师的userId 是相同的,这种情况会按数据已存在来处理
|
||||
Account acc = accountService.getBySysId(tea.getAccount().getSysId());
|
||||
if(acc != null){
|
||||
tea.getAccount().setId(acc.getId());
|
||||
// 将不需要更新的字段重新赋值
|
||||
tea.getAccount().setNickName(acc.getNickName());
|
||||
if(StringUtils.isNotBlank(acc.getAvatar())) {
|
||||
tea.getAccount().setAvatar(acc.getAvatar());
|
||||
}
|
||||
|
||||
tea.getUser().setId(acc.getId());
|
||||
}
|
||||
this.save(tea);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过工号导入教师数据
|
||||
* @param codes
|
||||
* @throws XaskException
|
||||
*/
|
||||
//@Override
|
||||
public void syncTeacherByCodes(TeacherVo tea)throws XaskException{
|
||||
//先检查是否本地库有,有则更新
|
||||
Teacher old = this.getBySysId(tea.getSysId());
|
||||
if (old == null){
|
||||
// 如果返回的账号和用户信息是空则不执行(测试环境会有这中情况)
|
||||
if(tea.getAccount() == null || tea.getUser() == null){
|
||||
throw new XaskException("原数据中无教师关联的用户信息,不能同步");
|
||||
//return;
|
||||
}
|
||||
Account acc = accountService.getBySysId(tea.getAccount().getSysId());
|
||||
old=new Teacher();
|
||||
// 先查询是否有账号,这里会出现多个教师的userId 是相同的,这种情况会按数据已存在来处理
|
||||
if(acc != null){
|
||||
tea.getAccount().setId(acc.getId());
|
||||
// 将不需要更新的字段重新赋值
|
||||
tea.getAccount().setNickName(acc.getNickName());
|
||||
if(StringUtils.isNotBlank(acc.getAvatar())) {
|
||||
tea.getAccount().setAvatar(acc.getAvatar());
|
||||
}
|
||||
|
||||
tea.getUser().setId(acc.getId());
|
||||
}
|
||||
this.save(tea);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xboe.module.teacher.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TeacherSimpleVo {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xboe.module.teacher.vo;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TeacherVo extends Teacher {
|
||||
|
||||
private Account account;
|
||||
|
||||
private String departName;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.xboe.system.organization.dao;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构管理DAO
|
||||
*/
|
||||
@Repository
|
||||
public class OrganizationDao extends BaseDao<Organization> {
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param organization
|
||||
* @return
|
||||
*/
|
||||
public List<Organization> findList(Organization organization) {
|
||||
QueryBuilder qb = QueryBuilder.from(this.getEntityClass());
|
||||
qb.addFilter(FieldFilters.eq("deleted", false));
|
||||
if (organization != null) {
|
||||
if (StringUtil.isNotBlank(organization.getName())) {
|
||||
qb.addFilter(FieldFilters.like("name", LikeMatchMode.ANYWHERE, organization.getName()));
|
||||
}
|
||||
if (StringUtil.isNotBlank(organization.getParentId())) {
|
||||
qb.addFilter(FieldFilters.eq("parentId", organization.getParentId()));
|
||||
}
|
||||
}
|
||||
qb.addOrder(OrderCondition.asc("parentId"));
|
||||
return this.findList(qb.builder());
|
||||
}
|
||||
|
||||
/**
|
||||
* 按父id查询机构
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
public List<Organization> findListByParentId(String parentId) {
|
||||
return this.findList(FieldFilters.eq("parentId",parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 机构数量
|
||||
*
|
||||
* @param organization
|
||||
* @return
|
||||
*/
|
||||
public Integer getOrganizationCount(Organization organization) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
if (organization != null) {
|
||||
if (StringUtil.isNotBlank(organization.getParentId())) {
|
||||
filters.add(FieldFilters.eq("parentId", organization.getParentId()));
|
||||
}
|
||||
}
|
||||
return this.count(filters.toArray(new IFieldFilter[filters.size()]));
|
||||
}
|
||||
|
||||
public PageList<Organization> query(Integer pageIndex, Integer pageSize, Organization organization, boolean showChild,OrderCondition order){
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
if (organization != null) {
|
||||
if (StringUtils.isNotBlank(organization.getName())) {
|
||||
filters.add(FieldFilters.like("name", LikeMatchMode.ANYWHERE, organization.getName()));
|
||||
}
|
||||
|
||||
if(showChild){ // 是否显示子节点
|
||||
// parentId 为 -1 ,显示所有节点
|
||||
if(!StringUtil.equals(organization.getParentId(), BaseConstant.TREEDATA_ROOT_PARENT_ID)){
|
||||
Organization parendOrg = this.get(organization.getParentId());
|
||||
filters.add(FieldFilters.like("namePath", LikeMatchMode.ANYWHERE, parendOrg.getName() + "/"));
|
||||
}
|
||||
}else{
|
||||
if (StringUtil.isNotBlank(organization.getParentId())) {
|
||||
filters.add(FieldFilters.eq("parentId", organization.getParentId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return this.getGenericDao().findPage(pageIndex, pageSize, getEntityClass(), filters, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据旧系统ID查询数据
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
public Organization getBySysId(String sysId) {
|
||||
return this.findOne(FieldFilters.eq("sysId",sysId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一性校验
|
||||
*
|
||||
* @param name
|
||||
* @param excludeId
|
||||
* @return
|
||||
*/
|
||||
public Organization checkName(String name, String excludeId) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
|
||||
filters.add(FieldFilters.eq("name", name));
|
||||
if (StringUtil.isNotBlank(excludeId)) {
|
||||
List<String> excludeIds = new ArrayList<>();
|
||||
excludeIds.add(excludeId);
|
||||
filters.add(FieldFilters.notIn("id", excludeIds));
|
||||
}
|
||||
|
||||
return findOne(filters.toArray(new IFieldFilter[filters.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一性校验
|
||||
*
|
||||
* @param code
|
||||
* @param excludeId
|
||||
* @return
|
||||
*/
|
||||
public Organization checkCode(String code, String excludeId) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
|
||||
filters.add(FieldFilters.eq("code", code));
|
||||
if (StringUtil.isNotBlank(excludeId)) {
|
||||
List<String> excludeIds = new ArrayList<>();
|
||||
excludeIds.add(excludeId);
|
||||
filters.add(FieldFilters.notIn("id", excludeIds));
|
||||
}
|
||||
|
||||
return findOne(filters.toArray(new IFieldFilter[filters.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新机构上下级关系
|
||||
*/
|
||||
public void updatePatentId(){
|
||||
this.sqlUpdate("UPDATE boe_organization o1 SET o1.parent_id = '-1'");
|
||||
this.sqlUpdate("UPDATE boe_organization o1, boe_organization o2 SET o1.parent_id = o2.id WHERE o2.sys_id = o1.sys_parent_id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.xboe.system.organization.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 机构实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "organization")
|
||||
public class Organization extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 原系统ID
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 旧系统父id
|
||||
*/
|
||||
@Column(name = "sys_parent_id", length = 36)
|
||||
private String sysParentId;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "code", nullable = false, length = 50)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
@Column(name = "name", nullable = false, length = 50)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 组织全路径
|
||||
*/
|
||||
@Column(name = "name_path")
|
||||
private String namePath;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
@Column(name = "parent_id", length = 18)
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description", columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 域ID
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 组织部门经理ID
|
||||
*/
|
||||
@Column(name = "orgnization_manager_id", length = 36)
|
||||
private String orgnizationManagerId;
|
||||
|
||||
/**
|
||||
* 组织级别
|
||||
*/
|
||||
@Column(name = "organization_level", length = 50)
|
||||
private String organizationLevel;
|
||||
|
||||
/**
|
||||
* 是否制造组织
|
||||
*/
|
||||
@Column(name = "is_make_org", length = 1)
|
||||
private Boolean isMakeOrg;
|
||||
|
||||
/**
|
||||
* 是否服务现地
|
||||
*/
|
||||
@Column(name = "is_service_site", length = 1)
|
||||
private Boolean isServiceSite;
|
||||
|
||||
/**
|
||||
* 是否默认注册组织
|
||||
*/
|
||||
@Column(name = "is_default_organization", length = 1)
|
||||
private Boolean isDefaultOrganization;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0:临时,1:正常,2:停用
|
||||
*/
|
||||
@Column(name = "status", nullable = false, length = 1)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.xboe.system.organization.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.vo.OrgSimpleVo;
|
||||
|
||||
/**
|
||||
* 机构接口
|
||||
*/
|
||||
public interface IOrganizationService {
|
||||
|
||||
/**
|
||||
* 按ID查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Organization get(String id);
|
||||
|
||||
/**
|
||||
* 按SysID查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Organization getBySysId(String id);
|
||||
|
||||
/**
|
||||
* 按ID查询名称
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String getName(String id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param organization
|
||||
* @return
|
||||
*/
|
||||
List<Organization> findList(Organization organization);
|
||||
|
||||
/**
|
||||
* 按父ID查询机构
|
||||
* 用于构建动态树,返回一些简单的信息
|
||||
*
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
List<OrgSimpleVo> listByParent(String parentId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param entity
|
||||
* @param showChild
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
PageList<Organization> query(Integer pageIndex, Integer pageSize, Organization entity,boolean showChild, OrderCondition order);
|
||||
|
||||
/**
|
||||
* 获得总数
|
||||
*
|
||||
* @param organization
|
||||
* @return
|
||||
*/
|
||||
Integer getOrganizationCount(Organization organization);
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param organization
|
||||
*/
|
||||
void save(Organization organization) throws XaskException;
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param organization
|
||||
*/
|
||||
void update(Organization organization) throws XaskException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void delete(String id) throws XaskException;
|
||||
|
||||
/**
|
||||
* 全量同步机构数据
|
||||
* 以id为同步依据,有重复则更新数据
|
||||
*
|
||||
* @throws XaskException
|
||||
*/
|
||||
void syncAll(List<Organization> orgList) throws XaskException;
|
||||
|
||||
/**
|
||||
* 更新机构上下级关系
|
||||
*/
|
||||
void updatePatentId();
|
||||
|
||||
/**
|
||||
* 递归更新全名称路径
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
// void updateNamePath(List<Organization> list, String parentNamePath);
|
||||
|
||||
/**
|
||||
* 按父id查询机构
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
List<Organization> findListByParentId(String parentId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
package com.xboe.system.organization.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.constants.Constants;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.externalinterface.system.service.IFwOrganizationService;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.system.organization.dao.OrganizationDao;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.organization.vo.OrgSimpleVo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrganizationServiceImpl implements IOrganizationService {
|
||||
|
||||
@Resource
|
||||
OrganizationDao dao;
|
||||
|
||||
@Resource
|
||||
IFwOrganizationService fwOrganizationService;
|
||||
|
||||
@Cacheable(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORG + "'+#id", unless = "#result == null")
|
||||
@Override
|
||||
public Organization get(String id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Organization getBySysId(String id) {
|
||||
return dao.getBySysId(id);
|
||||
}
|
||||
|
||||
@Cacheable(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORGNAME + "'+#id", unless = "#result == null")
|
||||
@Override
|
||||
public String getName(String id) {
|
||||
if(StringUtil.isNotBlank(id)){
|
||||
Organization org = this.get(id);
|
||||
if(org != null){
|
||||
return org.getName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Organization> findList(Organization organization) {
|
||||
return dao.findList(organization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgSimpleVo> listByParent(String parentId) {
|
||||
Organization query = new Organization();
|
||||
query.setParentId(parentId);
|
||||
List<Organization> list = this.findList(query);
|
||||
List<OrgSimpleVo> result = null;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
result = new ArrayList<>();
|
||||
OrgSimpleVo vo;
|
||||
for (Organization org : list) {
|
||||
vo = new OrgSimpleVo();
|
||||
vo.setCode(org.getCode());
|
||||
vo.setId(org.getId());
|
||||
vo.setName(org.getName());
|
||||
vo.setParentId(org.getParentId());
|
||||
result.add(vo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageList<Organization> query(Integer pageIndex, Integer pageSize, Organization entity,boolean showChild, OrderCondition order) {
|
||||
return dao.query(pageIndex,pageSize,entity,showChild,order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrganizationCount(Organization organization) {
|
||||
return dao.getOrganizationCount(organization);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(Organization organization) throws XaskException {
|
||||
Organization checkName = dao.checkName(organization.getName(), null);
|
||||
if (checkName != null) {
|
||||
throw new XaskException("存在同名组织机构");
|
||||
}
|
||||
Organization checkCode = dao.checkCode(organization.getCode(), null);
|
||||
if (checkCode != null) {
|
||||
throw new XaskException("存在相同组织部门代码");
|
||||
}
|
||||
if (StringUtil.isBlank(organization.getParentId())) {
|
||||
organization.setParentId(BaseConstant.TREEDATA_ROOT_PARENT_ID);
|
||||
}
|
||||
if (organization.getIsMakeOrg() == null) {
|
||||
organization.setIsMakeOrg(false);
|
||||
}
|
||||
if (organization.getIsServiceSite() == null) {
|
||||
organization.setIsServiceSite(false);
|
||||
}
|
||||
if (organization.getIsDefaultOrganization() == null) {
|
||||
organization.setIsDefaultOrganization(false);
|
||||
}
|
||||
if (organization.getStatus() == null) {
|
||||
organization.setStatus(Constants.ORGANIZATION_STATUS_NORMAL);
|
||||
}
|
||||
if (!BaseConstant.TREEDATA_ROOT_PARENT_ID.equals(organization.getParentId())) {
|
||||
Organization parent = dao.get(organization.getParentId());
|
||||
organization.setNamePath(parent.getNamePath() + "/" + organization.getName());
|
||||
} else {
|
||||
organization.setNamePath("/" + organization.getName());
|
||||
}
|
||||
dao.save(organization);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORG + "'+#organization.id"),
|
||||
@CacheEvict(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORGNAME + "'+#organization.id")})
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(Organization organization) throws XaskException {
|
||||
Organization checkName = dao.checkName(organization.getName(), organization.getId());
|
||||
if (checkName != null) {
|
||||
throw new XaskException("存在同名组织机构");
|
||||
}
|
||||
Organization checkCode = dao.checkCode(organization.getCode(), organization.getId());
|
||||
if (checkCode != null) {
|
||||
throw new XaskException("存在相同组织部门代码");
|
||||
}
|
||||
Organization old = dao.get(organization.getId());
|
||||
old.setCode(organization.getCode());
|
||||
old.setName(organization.getName());
|
||||
old.setDescription(organization.getDescription());
|
||||
if (!BaseConstant.TREEDATA_ROOT_PARENT_ID.equals(old.getParentId())) {
|
||||
Organization parent = dao.get(organization.getParentId());
|
||||
old.setNamePath(parent.getNamePath() + "/" + old.getName());
|
||||
} else {
|
||||
old.setNamePath("/" + old.getName());
|
||||
}
|
||||
dao.update(old);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORG + "'+#id"),
|
||||
@CacheEvict(value = CacheName.NAME_ORG, key = "'" + CacheName.KEY_ORGNAME + "'+#id")})
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(String id) throws XaskException {
|
||||
Organization param = new Organization();
|
||||
param.setParentId(id);
|
||||
Integer organizationCount = this.getOrganizationCount(param);
|
||||
if (organizationCount > 0) {
|
||||
throw new XaskException("请先删除下级机构");
|
||||
}
|
||||
dao.setDeleted(id);
|
||||
}
|
||||
|
||||
@CacheEvict(value = CacheName.NAME_ORG, allEntries = true)
|
||||
@Override
|
||||
@Transactional
|
||||
public void syncAll(List<Organization> orgList) throws XaskException {
|
||||
try {
|
||||
for (Organization org : orgList) {
|
||||
|
||||
//先检查是否本地库有,有则更新
|
||||
Organization old = dao.getBySysId(org.getSysId());
|
||||
if (old != null) {
|
||||
BeanUtils.copyProperties(org, old, "id");
|
||||
dao.update(old);
|
||||
} else {
|
||||
dao.save(org);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步机构出现错误",e);
|
||||
throw new XaskException("同步机构出现错误");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public void updateNamePath(List<Organization> list, String parentNamePath) {
|
||||
// for (Organization org : list) {
|
||||
// org.setNamePath(parentNamePath + "/" + org.getName());
|
||||
// dao.updateFieldById(org.getId(), "namePath", org.getNamePath());
|
||||
// this.updateNamePath(dao.findListByParentId(org.getId()), org.getNamePath());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<Organization> findListByParentId(String parentId) {
|
||||
return dao.findListByParentId(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updatePatentId() {
|
||||
dao.updatePatentId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.system.organization.vo;
|
||||
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构VO
|
||||
*/
|
||||
@Data
|
||||
public class OrgSimpleVo {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 组织名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父组织部门ID
|
||||
*/
|
||||
private String parentId;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xboe.system.organization.vo;
|
||||
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构VO
|
||||
*/
|
||||
@Data
|
||||
public class OrganizationVo extends Organization {
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<OrganizationVo> children;
|
||||
|
||||
/**
|
||||
* 父级名称
|
||||
*/
|
||||
private String parentName;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.xboe.system.timetask;
|
||||
|
||||
import com.xboe.core.ITimeTaskExecutor;
|
||||
import com.xboe.core.SpringContext;
|
||||
import com.xboe.system.timetask.entity.SysTimeTask;
|
||||
import com.xboe.system.timetask.service.ISysTimeTaskService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
/**
|
||||
* 用于对定时任务的管控
|
||||
*/
|
||||
@Lazy(value = false)
|
||||
@EnableScheduling
|
||||
@Configuration
|
||||
|
||||
public class SysTimeTaskManager implements SchedulingConfigurer{
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SysTimeTaskManager.class);
|
||||
|
||||
private static ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||
|
||||
private static Map<String,ScheduledFuture<?>> scheduledFutureMap = new HashMap<>();
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysTimeTaskService service;
|
||||
|
||||
static {
|
||||
threadPoolTaskScheduler.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
|
||||
List<SysTimeTask> tasks= null;
|
||||
try {
|
||||
tasks = service.getAll();
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
logger.info("查询失败",e);
|
||||
}
|
||||
logger.info("定时任务启动,预计启动任务数量="+tasks.size()+"; time="+LocalDateTime.now().toString());
|
||||
|
||||
//校验数据(这个步骤主要是为了打印日志,可以省略)
|
||||
//checkDataList(tasks);
|
||||
//通过校验的数据执行定时任务
|
||||
int count = 0;
|
||||
if(tasks.size()>0) {
|
||||
for(SysTimeTask task:tasks) {
|
||||
if(StringUtils.isBlank(task.getCron()) || StringUtils.isBlank(task.getBean())) {
|
||||
logger.error("定时任务数据不对:cron和executorBean都不能为空");
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
//taskRegistrar.addTriggerTask(getRunnable(task), getTrigger(task));
|
||||
start(task);
|
||||
count++;
|
||||
} catch (Exception e) {
|
||||
logger.error("定时任务启动错误:" + task.getName() + ";" + task.getBean() + ";" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("定时任务实际启动数量="+count+"; time="+LocalDateTime.now());
|
||||
}
|
||||
|
||||
private static Runnable getRunnable(SysTimeTask task){
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ITimeTaskExecutor executor= (ITimeTaskExecutor)SpringContext.getBean(task.getBean());
|
||||
executor.execute(task.getParams());
|
||||
} catch (Exception e) {
|
||||
logger.error("定时任务启动错误,执行失败【"+task.getName()+","+task.getBean()+"】"+ e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Trigger getTrigger(SysTimeTask task){
|
||||
|
||||
return new Trigger() {
|
||||
@Override
|
||||
public Date nextExecutionTime(TriggerContext triggerContext) {
|
||||
//将Cron 0/1 * * * * ? 输入取得下一次执行的时间
|
||||
logger.info("cron="+task.getCron());
|
||||
CronTrigger trigger = new CronTrigger(task.getCron());
|
||||
Date nextExec = trigger.nextExecutionTime(triggerContext);
|
||||
return nextExec;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启动定时任务
|
||||
* @param task
|
||||
* @param
|
||||
*/
|
||||
public static void start(SysTimeTask task){
|
||||
if(StringUtils.isBlank(task.getId())) {
|
||||
logger.info("启动定时任务失败:未指定任务的ID");
|
||||
return;
|
||||
}
|
||||
ScheduledFuture<?> scheduledFuture = threadPoolTaskScheduler.schedule(getRunnable(task),getTrigger(task));
|
||||
scheduledFutureMap.put(task.getId(),scheduledFuture);
|
||||
logger.info("启动定时任务:" + task.getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消定时任务
|
||||
* @param task
|
||||
*/
|
||||
public static void cancel(SysTimeTask task){
|
||||
|
||||
ScheduledFuture<?> scheduledFuture = scheduledFutureMap.get(task.getId());
|
||||
|
||||
if(scheduledFuture != null && !scheduledFuture.isCancelled()){
|
||||
scheduledFuture.cancel(Boolean.FALSE);
|
||||
}
|
||||
|
||||
scheduledFutureMap.remove(task.getId());
|
||||
logger.info("取消定时任务" + task.getId() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param task
|
||||
* @param
|
||||
*/
|
||||
public static void reset(SysTimeTask task){
|
||||
logger.info("修改定时任务开始" + task.getId() );
|
||||
cancel(task);
|
||||
start(task);
|
||||
logger.info("修改定时任务结束" + task.getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xboe.system.timetask.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.system.timetask.entity.SysTimeTask;
|
||||
|
||||
@Repository
|
||||
public class SysTimeTaskDao extends BaseDao<SysTimeTask>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xboe.system.timetask.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 系统定时任务表
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"sys_timetask")
|
||||
@Data
|
||||
public class SysTimeTask implements java.io.Serializable{
|
||||
|
||||
public static final int STATUS_NONE=1;
|
||||
|
||||
public static final int STATUS_EXECUTE=3;
|
||||
|
||||
public static final int STATUS_FINISH=9;
|
||||
|
||||
/**循环任务 */
|
||||
public static final int TASKTYPE_LOOP=1;
|
||||
|
||||
/**只执行一次 */
|
||||
public static final int TASKTYPE_ONCE=2;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**任务的id
|
||||
* 如果手动同步,可以直接根据id去调相应的任务去执行
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "id",length=20)
|
||||
private String id;
|
||||
|
||||
/**任务名称*/
|
||||
@Column(name = "name",length=30)
|
||||
private String name;
|
||||
|
||||
/**执行时间*/
|
||||
@Column(name = "cron",length=30)
|
||||
private String cron;
|
||||
|
||||
/**状态 1未执行,2表已执行,执行中,9已完成*/
|
||||
@Column(name = "status",length=1)
|
||||
private Integer status;
|
||||
|
||||
/**反向关联的ID*/
|
||||
@Column(name = "ref_id",length=20)
|
||||
private String refId;
|
||||
|
||||
@Column(name = "ref_type",length=20)
|
||||
private String refType;
|
||||
|
||||
/**实现执行者接口的bean名字,一般使用类的全名*/
|
||||
@Column(name = "bean",length=100)
|
||||
private String bean;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Column(name = "enable",length=1)
|
||||
private Boolean enable;
|
||||
|
||||
/**执行时传入的参数*/
|
||||
@Column(name = "params",length=100)
|
||||
private String params;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xboe.system.timetask.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.system.timetask.entity.SysTimeTask;
|
||||
|
||||
/**
|
||||
* 时间任务管理处理
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
public interface ISysTimeTaskService {
|
||||
|
||||
List<SysTimeTask> getAll();
|
||||
|
||||
SysTimeTask get(String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xboe.system.timetask.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.system.timetask.dao.SysTimeTaskDao;
|
||||
import com.xboe.system.timetask.entity.SysTimeTask;
|
||||
import com.xboe.system.timetask.service.ISysTimeTaskService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SysTimeTaskServiceImpl implements ISysTimeTaskService{
|
||||
|
||||
@Autowired
|
||||
private SysTimeTaskDao dao;
|
||||
|
||||
@Override
|
||||
public List<SysTimeTask> getAll() {
|
||||
return dao.getAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTimeTask get(String id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.xboe.system.user.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 用户信息api
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/xboe/sys/user")
|
||||
public class UserApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
IUserService service;
|
||||
|
||||
@Resource
|
||||
IAccountService accountService;
|
||||
|
||||
@Resource
|
||||
IOrganizationService organizationService;
|
||||
|
||||
@Resource
|
||||
IFwUserService fwUserService;
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
/**
|
||||
* 全量同步
|
||||
* */
|
||||
@GetMapping("/sync-all")
|
||||
public JsonResponse<Boolean> syncAll(Integer pages){
|
||||
try {
|
||||
|
||||
try {
|
||||
|
||||
// 循环获取信息,每次20条,直到获取为空的时候为止
|
||||
boolean getTea = true;
|
||||
int pageIndex = 1;
|
||||
while (getTea) {
|
||||
if(pages!=null) {
|
||||
if(pageIndex>pages) {
|
||||
getTea = false;
|
||||
}
|
||||
}
|
||||
List<UserVo> idList = fwUserService.list(pageIndex++, 100);
|
||||
if (idList != null) {
|
||||
// 同步
|
||||
for (UserVo uv : idList) {
|
||||
try {
|
||||
userService.syncUpdateUser(uv);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 捕获异常继续执行
|
||||
log.error("同步用户 "+ uv.getAccount() != null ? uv.getAccount().getLoginName() : "" +" 出现错误:" + e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getTea = false;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception xe) {
|
||||
log.error("同步用户出现错误",xe);
|
||||
throw new XaskException("同步用户出现错误");
|
||||
}
|
||||
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步用户失败",e);
|
||||
return error("同步用户失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.xboe.system.user.dao;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.LikeMatchMode;
|
||||
import com.xboe.system.user.entity.SysManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台管理人员DAO
|
||||
*/
|
||||
@Repository
|
||||
public class SysManagerDao extends BaseDao<SysManager> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param sysManager
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public PageList<SysManager> query(int pageIndex, int pageSize, SysManager sysManager, OrderCondition order) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
|
||||
if (sysManager != null) {
|
||||
if (sysManager.getUser() != null) {
|
||||
if (StringUtils.isNotBlank(sysManager.getUser().getName())) {
|
||||
filters.add(FieldFilters.like("user.name", LikeMatchMode.ANYWHERE, sysManager.getUser().getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.getGenericDao().findPage(pageIndex, pageSize, getEntityClass(), filters, order);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.xboe.system.user.dao;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.LikeMatchMode;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.vo.UserSimpleVo;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户DAO
|
||||
*/
|
||||
@Repository
|
||||
public class UserDao extends BaseDao<User> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param user
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public PageList<User> query(int pageIndex, int pageSize, UserVo user, OrderCondition order) {
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
|
||||
if (user != null) {
|
||||
if (StringUtils.isNotBlank(user.getKeyWord())) {
|
||||
filters.add(FieldFilters.or(FieldFilters.like("name", LikeMatchMode.ANYWHERE, user.getName()), FieldFilters.like("userNo", LikeMatchMode.ANYWHERE, user.getUserNo())));
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getName())) {
|
||||
filters.add(FieldFilters.like("name", LikeMatchMode.ANYWHERE, user.getName()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getUserNo())) {
|
||||
filters.add(FieldFilters.like("userNo", LikeMatchMode.ANYWHERE, user.getUserNo()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getDepartId())) {
|
||||
filters.add(FieldFilters.eq("departId", user.getDepartId()));
|
||||
}
|
||||
}
|
||||
return this.getGenericDao().findPage(pageIndex, pageSize, getEntityClass(), filters, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户编号查询
|
||||
*
|
||||
* @param userNos
|
||||
* @return
|
||||
*/
|
||||
public List<User> getListByUserNos(List<String> userNos) {
|
||||
return this.getGenericDao().findList(User.class, FieldFilters.in("userNo", userNos));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按姓名查询用户信息
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<UserSimpleVo> getListByName(String keyword) {
|
||||
|
||||
String hql = "Select a.id,a.avatar,u.name,u.userNo,org.namePath from Account a left join User u on a.id=u.id left join Organization org on u.departId=org.id where u.name=?1";
|
||||
List<UserSimpleVo> results = null;
|
||||
try {
|
||||
List<Object[]> list = this.findListFields(hql, keyword);
|
||||
if(list != null && !list.isEmpty()) {
|
||||
results = new ArrayList<>();
|
||||
for (Object[] objs : list) {
|
||||
results.add(resultToVo(objs));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private UserSimpleVo resultToVo(Object[] objs){
|
||||
String id = (String) objs[0];
|
||||
String avatar = (String) objs[1];
|
||||
String name = (String) objs[2];
|
||||
String code = (String) objs[3];
|
||||
String namePath = (String) objs[4];
|
||||
UserSimpleVo usv = new UserSimpleVo();
|
||||
usv.setAid(id);
|
||||
usv.setAvatar(avatar);
|
||||
usv.setName(name);
|
||||
usv.setCode(code);
|
||||
usv.setOrgInfo(namePath);
|
||||
return usv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xboe.system.user.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdBaseEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 系统后台管理人员
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "manager")
|
||||
public class SysManager extends IdBaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@OneToOne(cascade = {}, fetch = FetchType.LAZY)
|
||||
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 最后一次登录时间
|
||||
*/
|
||||
@MetaInfo(value="最后一次登录时间")
|
||||
@Column(name = "last_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastTime;
|
||||
|
||||
/**
|
||||
* 操作信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.xboe.system.user.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户信息表
|
||||
* 存储所有的用户信息,原表中的部分信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "user")
|
||||
public class User extends IdEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 旧系统id
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 旧系统机构id
|
||||
*/
|
||||
@Column(name = "sys_depart_id", length = 36)
|
||||
private String sysDepartId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
@Column(name = "user_no", length = 30)
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 性别 1:男 2:女
|
||||
*/
|
||||
@Column(name = "gender", length = 1)
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@Column(name = "birthday")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthday;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@Column(name = "id_number", length = 18)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile_no", length = 11)
|
||||
private String mobileNo;
|
||||
|
||||
/**
|
||||
* 家庭电话
|
||||
*/
|
||||
@Column(name = "home_phone_no", length = 50)
|
||||
private String homePhoneNo;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
@Column(name = "nationality", length = 50)
|
||||
private String nationality;
|
||||
|
||||
/**
|
||||
* 毕业院校
|
||||
*/
|
||||
@Column(name = "graduated_from", length = 50)
|
||||
private String graduatedFrom;
|
||||
|
||||
/**
|
||||
* 毕业专业
|
||||
*/
|
||||
@Column(name = "graduated_major", length = 50)
|
||||
private String graduatedMajor;
|
||||
|
||||
/**
|
||||
* 最高学历
|
||||
*/
|
||||
@Column(name = "highest_education", length = 50)
|
||||
private String highestEducation;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@Column(name = "telephone_no", length = 50)
|
||||
private String telephoneNo;
|
||||
|
||||
/**
|
||||
* 职务
|
||||
*/
|
||||
@Column(name = "duty", length = 50)
|
||||
private String duty;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@Column(name = "rank", length = 50)
|
||||
private String rank;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 所在公司
|
||||
*/
|
||||
@Column(name = "company_id", length = 36)
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 所在部门
|
||||
*/
|
||||
@Column(name = "depart_id", length = 18)
|
||||
private String departId;
|
||||
|
||||
@Transient
|
||||
private String departName;
|
||||
|
||||
|
||||
/**
|
||||
* 所在域
|
||||
*/
|
||||
@Column(name = "domain_id", length = 36)
|
||||
private String domainId;
|
||||
|
||||
/**
|
||||
* 扩展字段,多租户系统的标识值
|
||||
*/
|
||||
@Column(name = "sass_id", length = 18)
|
||||
private String sassId;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,2表教师,3表管理员
|
||||
* 该字段暂用于表示是否前台管理员
|
||||
*/
|
||||
@Column(name = "user_type", length = 1)
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 学习总时长
|
||||
*/
|
||||
@Column(name = "study_total", length = 11)
|
||||
private Integer studyTotal;
|
||||
|
||||
/**
|
||||
* boe的时长,和系统时长单独保存
|
||||
*/
|
||||
@Column(name = "learning_Duration", length = 11)
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 最近一次登录时间
|
||||
*/
|
||||
@Column(name = "last_login_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastLoginAt;
|
||||
|
||||
/**
|
||||
* 最近一次登录IP
|
||||
*/
|
||||
@Column(name = "last_login_ip", length = 30)
|
||||
private String lastLoginIp;
|
||||
|
||||
/**
|
||||
* 最近一次登录MAC地址
|
||||
*/
|
||||
@Column(name = "last_login_mac", length = 30)
|
||||
private String lastLoginMac;
|
||||
|
||||
/**
|
||||
* 最近一次操作时间
|
||||
*/
|
||||
@Column(name = "last_action_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastActionAt;
|
||||
|
||||
/**
|
||||
* 最近一次操作IP
|
||||
*/
|
||||
@Column(name = "last_action_ip", length = 30)
|
||||
private String lastActionIp;
|
||||
|
||||
/**
|
||||
* 最近一次操作MAC地址
|
||||
*/
|
||||
@Column(name = "last_action_mac", length = 30)
|
||||
private String lastActionMac;
|
||||
|
||||
/**
|
||||
* 在线状态;
|
||||
* 0:离线,1:在线
|
||||
*/
|
||||
@Column(name = "online", length = 1)
|
||||
private Boolean online;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.xboe.system.user.service;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.system.user.entity.SysManager;
|
||||
import com.xboe.system.user.vo.SysManagerVo;
|
||||
|
||||
/**
|
||||
* 后台管理人员接口
|
||||
*/
|
||||
public interface ISysManagerService {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param sysManager
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
PageList<SysManager> page(Integer pageIndex, Integer pageSize, SysManager sysManager, OrderCondition order);
|
||||
|
||||
/**
|
||||
* 详细信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
SysManager get(String id);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param sysManager
|
||||
* @throws XaskException
|
||||
*/
|
||||
void save(SysManagerVo sysManager) throws XaskException;
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param sysManager
|
||||
* @throws XaskException
|
||||
*/
|
||||
void update(SysManagerVo sysManager) throws XaskException;
|
||||
|
||||
/**
|
||||
* 更新最后登录时间
|
||||
* @param id
|
||||
*/
|
||||
void updateLastTime(String id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void delete(String id);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.xboe.system.user.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.vo.UserSimpleVo;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
/**
|
||||
* 用户接口
|
||||
*/
|
||||
public interface IUserService {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param user
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
PageList<User> page(Integer pageIndex, Integer pageSize, UserVo user, OrderCondition order);
|
||||
|
||||
/**
|
||||
* 根据用户的编号 ,得到用户的id
|
||||
* @param userNo
|
||||
* @return
|
||||
*/
|
||||
String getIdByUserNo(String userNo);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
User get(String id);
|
||||
|
||||
/**
|
||||
* 批量更新用户的学习时长
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
void batchUpdateStudyTime(Map<String, Integer> map);
|
||||
|
||||
/**
|
||||
* 根据员工号列表获取员工信息
|
||||
*
|
||||
* @param userNos
|
||||
* @return
|
||||
*/
|
||||
List<User> getListByUserNos(List<String> userNos);
|
||||
|
||||
/**
|
||||
* 按姓名查询用户信息
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
List<UserSimpleVo> getListByName(String keyword);
|
||||
|
||||
/**
|
||||
* 报错用户
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
void save(User user);
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
void update(User user);
|
||||
|
||||
/**
|
||||
* 记录用户最后一次登录信息
|
||||
*/
|
||||
void updateLastLoginInfo(String id, String lastLoginIp);
|
||||
|
||||
/**
|
||||
* 修改用户信息及密码
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
void updateUserInfoAndPass(UserVo user) throws XaskException;
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
void delete(User user);
|
||||
|
||||
/**
|
||||
* 设置用户类型
|
||||
*/
|
||||
void updateUserType(User user);
|
||||
|
||||
// void syncUser(UserVo uv)throws XaskException;
|
||||
|
||||
/**
|
||||
* 和上面的方法区别在于可以重复调用,调用后对已有数据更新
|
||||
* @param uv
|
||||
* @throws XaskException
|
||||
*/
|
||||
void syncUpdateUser(UserVo uv)throws XaskException;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.xboe.system.user.service.impl;
|
||||
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.constants.Constants;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.system.organization.dao.OrganizationDao;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.user.dao.SysManagerDao;
|
||||
import com.xboe.system.user.entity.SysManager;
|
||||
import com.xboe.system.user.service.ISysManagerService;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import com.xboe.system.user.vo.SysManagerVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.springframework.transaction.annotation.Propagation.REQUIRED;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class SysManagerServiceImpl implements ISysManagerService {
|
||||
|
||||
@Resource
|
||||
SysManagerDao dao;
|
||||
|
||||
@Resource
|
||||
IAccountService accountService;
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
@Resource
|
||||
OrganizationDao organizationDao;
|
||||
|
||||
@Override
|
||||
public PageList<SysManager> page(Integer pageIndex, Integer pageSize, SysManager sysManager, OrderCondition order) {
|
||||
PageList<SysManager> page = dao.query(pageIndex, pageSize, sysManager, order);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysManager get(String id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRED)
|
||||
public void save(SysManagerVo sysManager) throws XaskException {
|
||||
if (accountService.check(sysManager.getAccount().getLoginName(), sysManager.getAccount().getId()) != null) {// 检查是否已创建,使用sysManager的ID
|
||||
throw new XaskException("存在相同的登录名,请检查");
|
||||
}
|
||||
|
||||
// 当是本地库已有用户判断是否已是管理员
|
||||
if (StringUtils.isNotBlank(sysManager.getAccount().getId())) {
|
||||
SysManager old = dao.get(sysManager.getAccount().getId());
|
||||
if (old != null) {
|
||||
throw new XaskException("该用户已是管理员,不能重复添加");
|
||||
}
|
||||
}
|
||||
// 保存用户信息时需要设置其关联的部门
|
||||
if (StringUtils.isNotBlank(sysManager.getUser().getSysDepartId())) {
|
||||
Organization depart = organizationDao.getBySysId(sysManager.getUser().getSysDepartId());
|
||||
if (depart == null) {
|
||||
// throw new XaskException("该用户所属机构不存在,不能添加");
|
||||
} else {
|
||||
sysManager.getUser().setDepartId(depart.getId());
|
||||
}
|
||||
}
|
||||
// 判断是否已有账号
|
||||
if (accountService.checkAccount(sysManager.getAccount().getSysId())) {
|
||||
// 已有 账号和用户
|
||||
userService.update(sysManager.getUser());
|
||||
accountService.update(sysManager.getAccount());
|
||||
SysManager sm = new SysManager();
|
||||
sm.setId(sysManager.getAccount().getId());
|
||||
dao.save(sm);
|
||||
} else {
|
||||
// 没有 账号和用户
|
||||
userService.save(sysManager.getUser());
|
||||
sysManager.getAccount().setId(sysManager.getUser().getId());
|
||||
sysManager.getAccount().setRegTime(LocalDateTime.now());
|
||||
accountService.save(sysManager.getAccount());
|
||||
SysManager sm = new SysManager();
|
||||
sm.setId(sysManager.getAccount().getId());
|
||||
dao.save(sm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRED)
|
||||
public void update(SysManagerVo sysManager) throws XaskException {
|
||||
userService.update(sysManager.getUser());
|
||||
accountService.update(sysManager.getAccount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLastTime(String id) {
|
||||
SysManager sm = dao.get(id);
|
||||
sm.setLastTime(LocalDateTime.now());
|
||||
dao.update(sm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
dao.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.xboe.system.user.service.impl;
|
||||
|
||||
import static org.springframework.transaction.annotation.Propagation.REQUIRED;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.constants.Constants;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.FieldUpdateType;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import com.xboe.system.user.vo.UserSimpleVo;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class UserServiceImpl implements IUserService {
|
||||
|
||||
@Resource
|
||||
UserDao dao;
|
||||
|
||||
@Resource
|
||||
IAccountService accountService;
|
||||
|
||||
@Override
|
||||
public PageList<User> page(Integer pageIndex, Integer pageSize, UserVo user, OrderCondition order) {
|
||||
PageList<User> page = dao.query(pageIndex, pageSize, user, order);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER + "'+#id", unless = "#result == null")
|
||||
public User get(String id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getListByUserNos(List<String> userNos) {
|
||||
return dao.getListByUserNos(userNos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_NAME + "'+#keyword", unless = "#result == null")
|
||||
public List<UserSimpleVo> getListByName(String keyword) {
|
||||
return dao.getListByName(keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(User user) {
|
||||
// 用户默认为学员
|
||||
if (user.getUserType() == null) {
|
||||
user.setUserType(Constants.USER_TYPE_STUDENT);
|
||||
}
|
||||
if (user.getStudyTotal() == null) {
|
||||
user.setStudyTotal(0);//新用户学习时长为0
|
||||
}
|
||||
dao.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER + "'+#user.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_NAME + "'+#user.name"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_SYSID + "'+#user.sysId")})
|
||||
public void update(User user) {
|
||||
// user有些字段不能通过update来更新
|
||||
User old = dao.get(user.getId());
|
||||
BeanUtils.copyProperties(user,old,"id","userType","studyTotal");
|
||||
dao.update(old);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLastLoginInfo(String id, String lastLoginIp) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
dao.updateMultiFieldById(id,
|
||||
UpdateBuilder.create("lastLoginAt", now),
|
||||
UpdateBuilder.create("lastLoginIp", lastLoginIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER + "'+#user.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_NAME + "'+#user.name")})
|
||||
@Transactional(propagation = REQUIRED)
|
||||
public void updateUserInfoAndPass(UserVo user) throws XaskException {
|
||||
// Account account = accountService.get(user.getId());
|
||||
// account.setAvatar(user.getAccount().getAvatar());
|
||||
// account.setNickName(user.getAccount().getNickName());
|
||||
// accountService.update(account);
|
||||
// User oldUser = dao.get(user.getId());
|
||||
// oldUser.setBirthday(user.getBirthday());
|
||||
// dao.update(oldUser);
|
||||
accountService.updateAvatarAndNickName(user.getAccount());
|
||||
dao.updateMultiFieldById(user.getId(), UpdateBuilder.create("birthday", user.getBirthday()));
|
||||
|
||||
if (StringUtil.isNotBlank(user.getOldPass()) && StringUtil.isNotBlank(user.getNewPass())) {
|
||||
accountService.updatePass(user.getId(), user.getOldPass(), user.getNewPass());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER + "'+#user.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_NAME + "'+#user.name"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_SYSID + "'+#user.sysId")})
|
||||
public void delete(User user) {
|
||||
dao.setDeleted(user.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER + "'+#user.id"),
|
||||
@CacheEvict(value = CacheName.NAME_USER, key = "'" + CacheName.KEY_USER_NAME + "'+#user.name")})
|
||||
public void updateUserType(User user) {
|
||||
dao.updateFieldById(user.getId(), "userType", user.getUserType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdateStudyTime(Map<String, Integer> map) {
|
||||
for(String key : map.keySet()) {
|
||||
int value=map.get(key);
|
||||
dao.updateMultiFieldById(key,UpdateBuilder.create("studyTotal","studyTotal+"+value,FieldUpdateType.EXPRESSION));
|
||||
}
|
||||
|
||||
}
|
||||
// @Override
|
||||
// public void syncUser(UserVo uv)throws XaskException{
|
||||
// // 先检查是否本地库有,有则更新
|
||||
// Account old = accountService.getBySysId(uv.getSysId());
|
||||
// if (old != null) {
|
||||
// old.setCompanyId(uv.getAccount().getCompanyId());
|
||||
// old.setEmail(uv.getAccount().getEmail());
|
||||
// old.setMobile(uv.getAccount().getMobile());
|
||||
// old.setNickName(uv.getAccount().getNickName());
|
||||
// if(StringUtils.isBlank(old.getAvatar())){// 没有头像才更新
|
||||
// old.setAvatar(uv.getAccount().getAvatar());
|
||||
// }
|
||||
// accountService.update(old);
|
||||
// uv.setId(old.getId());
|
||||
// this.update(uv);
|
||||
// } else {
|
||||
// if (accountService.check(uv.getAccount().getLoginName(), uv.getAccount().getId()) != null) {// 检查是否已创建,使用sysManager的ID
|
||||
// throw new XaskException("存在相同的登录名,请检查");
|
||||
// }
|
||||
//
|
||||
// uv.setUserType(Constants.USER_TYPE_STUDENT);
|
||||
// // 没有 账号和用户
|
||||
// User newUser = new User();
|
||||
// BeanUtils.copyProperties(uv,newUser,"id");
|
||||
// this.save(newUser);
|
||||
// uv.getAccount().setId(newUser.getId());
|
||||
// uv.getAccount().setRegTime(LocalDateTime.now());
|
||||
// accountService.save(uv.getAccount());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void syncUpdateUser(UserVo uv)throws XaskException{
|
||||
// 先检查是否本地库有,有则更新
|
||||
Account old = accountService.getBySysId(uv.getSysId());
|
||||
if (old != null) {
|
||||
old.setCompanyId(uv.getAccount().getCompanyId());
|
||||
old.setEmail(uv.getAccount().getEmail());
|
||||
old.setMobile(uv.getAccount().getMobile());
|
||||
old.setNickName(uv.getAccount().getNickName());
|
||||
if(StringUtils.isBlank(old.getAvatar())){// 没有头像才更新
|
||||
old.setAvatar(uv.getAccount().getAvatar());
|
||||
}
|
||||
accountService.update(old);
|
||||
uv.setId(old.getId());
|
||||
this.update(uv);
|
||||
} else {
|
||||
if (accountService.check(uv.getAccount().getLoginName(), uv.getAccount().getId()) != null) {// 检查是否已创建,使用sysManager的ID
|
||||
throw new XaskException("存在相同的登录名,请检查");
|
||||
}
|
||||
|
||||
uv.setUserType(Constants.USER_TYPE_STUDENT);
|
||||
// 没有 账号和用户
|
||||
User newUser = new User();
|
||||
BeanUtils.copyProperties(uv,newUser,"id");
|
||||
this.save(newUser);
|
||||
uv.getAccount().setId(newUser.getId());
|
||||
uv.getAccount().setRegTime(LocalDateTime.now());
|
||||
accountService.save(uv.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdByUserNo(String userNo) {
|
||||
Object id=dao.findField("id",FieldFilters.eq("userNo", userNo));
|
||||
return (String)id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xboe.system.user.vo;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.system.user.entity.SysManager;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 后台管理人员VO
|
||||
*/
|
||||
@Data
|
||||
public class SysManagerVo extends SysManager {
|
||||
|
||||
private Account account;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xboe.system.user.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 显示的作者信息
|
||||
*/
|
||||
@Data
|
||||
public class UserSimpleVo implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 账户的id
|
||||
*/
|
||||
private String aid;
|
||||
|
||||
/**
|
||||
* 用户的头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 员工号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 机构信息,多级使用/分隔
|
||||
*/
|
||||
private String orgInfo;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xboe.system.user.vo;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户VO
|
||||
*/
|
||||
@Data
|
||||
public class UserVo extends User {
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyWord;
|
||||
|
||||
/**
|
||||
* 账号信息
|
||||
*/
|
||||
private Account account;
|
||||
|
||||
/**
|
||||
* 旧密码
|
||||
*/
|
||||
private String oldPass;
|
||||
|
||||
/**
|
||||
* 新密码
|
||||
*/
|
||||
private String newPass;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xboe.task;
|
||||
|
||||
import com.xboe.module.searchterms.service.ISearchTermsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@Slf4j
|
||||
public class SearchTermsSchedule {
|
||||
|
||||
@Resource
|
||||
private ISearchTermsService service;
|
||||
/**
|
||||
* 定时清理热门搜索词
|
||||
* */
|
||||
@Scheduled(cron="0 0 0 1,15 * ?")
|
||||
public void searchTermsDelete(){
|
||||
log.info("开始执行定时清理热门搜索词时间"+LocalDateTime.now());
|
||||
try {
|
||||
service.delete(LocalDateTime.now());
|
||||
} catch (Exception e) {
|
||||
log.error("清理失败",e);
|
||||
}
|
||||
log.info("结束执行定时清理热门搜索词时间"+LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.xboe.task;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.externalinterface.system.service.IFwOrganizationService;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.externalinterface.system.service.ILnTeacherService;
|
||||
import com.xboe.module.teacher.service.ITeacherService;
|
||||
import com.xboe.module.teacher.vo.TeacherVo;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
||||
@EnableScheduling // 2.开启定时任务
|
||||
@Slf4j
|
||||
public class SyncScheduleTask {
|
||||
|
||||
@Resource
|
||||
IOrganizationService orgService;
|
||||
|
||||
@Resource
|
||||
ITeacherService teacherService;
|
||||
|
||||
@Resource
|
||||
ILnTeacherService lnTeacherService;
|
||||
|
||||
@Resource
|
||||
IFwUserService fwUserService;
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
@Resource
|
||||
IFwOrganizationService fwOrganizationService;
|
||||
|
||||
//因为有用户中了,所以这个同步不需要了
|
||||
//每隔1个小时执行一次
|
||||
//@Scheduled(cron = "0 0 */1 * * ?")
|
||||
//@Scheduled(fixedRate=180000)
|
||||
private void syncAllOrg(){
|
||||
|
||||
log.info("开始执行机构同步定时任务时间: " + LocalDateTime.now());
|
||||
try {
|
||||
// 机构有依赖关系必须在一个事务中同步
|
||||
boolean getOrg = true;
|
||||
int pageIndex = 1;
|
||||
while (getOrg) {
|
||||
List<Organization> orgList = fwOrganizationService.list(pageIndex++, 100, null);
|
||||
if(orgList!=null && !orgList.isEmpty() && orgList.size()>0) {
|
||||
orgService.syncAll(orgList);
|
||||
}else {
|
||||
getOrg=false;
|
||||
}
|
||||
}
|
||||
// 更新上下级关系和全路径名称
|
||||
orgService.updatePatentId();
|
||||
// 更新全路径名称 (更新上下级关系时没有层级关系故不能和更新上下级关系同时处理)
|
||||
// 2022年6月10日,讨论结果,不再计算namePath ,而是使用同步过来的数据
|
||||
//orgService.updateNamePath(orgService.findListByParentId(BaseConstant.TREEDATA_ROOT_PARENT_ID), "");
|
||||
} catch (XaskException xe) {
|
||||
log.error("同步错误",xe);
|
||||
}
|
||||
log.info("结束执行机构同步定时任务时间: " + LocalDateTime.now());
|
||||
|
||||
}
|
||||
|
||||
//每天19点执行一次同步
|
||||
@Scheduled(cron = "0 0 19 * * ?")
|
||||
//或直接指定时间间隔,例如:1个小时
|
||||
//@Scheduled(fixedRate=180000)
|
||||
private void syncAllTeacher() {
|
||||
log.info("开始执行教师定时任务时间: " + LocalDateTime.now());
|
||||
//try {
|
||||
try {
|
||||
//循环获取信息,每次20条,直到获取为空的时候为止
|
||||
boolean getTea = true;
|
||||
int pageIndex = 1;
|
||||
while (getTea) {
|
||||
List<TeacherVo> teaList = lnTeacherService.list(pageIndex++, 20, null);
|
||||
if (teaList != null) {
|
||||
//同步
|
||||
for (TeacherVo tea : teaList) {
|
||||
// 转码描述中的html
|
||||
if(StringUtil.isNotBlank(tea.getDescription())){
|
||||
tea.setDescription(StringEscapeUtils.unescapeHtml4(tea.getDescription()));
|
||||
}
|
||||
try {
|
||||
//if(tea.getcod)
|
||||
teacherService.syncTeacher(tea);
|
||||
}catch (Exception e) {
|
||||
// 捕获异常继续执行
|
||||
log.error("同步教师 "+tea.getName()+" 出现错误:",e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getTea = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("同步教师出现错误",e);
|
||||
//throw new XaskException("同步教师出现错误");
|
||||
}
|
||||
// } catch (XaskException xe) {
|
||||
// log.error(xe.getMessage());
|
||||
// }
|
||||
|
||||
log.info("结束执行教师定时任务时间: " + LocalDateTime.now());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xboe.task;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.xboe.core.ITimeTaskExecutor;
|
||||
import com.xboe.core.cache.IXaskCache;
|
||||
import com.xboe.core.cache.XaskCacheProvider;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 同步处理学习时长的处理,每天晚上运行一次
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("com.xboe.task.UserStudyTimeSchedule")
|
||||
public class UserStudyTimeSchedule implements ITimeTaskExecutor{
|
||||
|
||||
@Resource
|
||||
IUserService userService;
|
||||
|
||||
@Override
|
||||
public void execute(String params) {
|
||||
|
||||
IXaskCache cache=XaskCacheProvider.getCache();
|
||||
|
||||
try {
|
||||
log.info("更新用户时长任务开始执行");
|
||||
//注以下处理是不对的,不能把redis当数据库来操作,此处需要修改,当前只是临时解决方案
|
||||
//后缀这里从学习时长时统计出来
|
||||
Collection<String> keys = cache.keys("study:user:time:*");
|
||||
Map<String,Integer> userTimeMap=new HashMap<String,Integer>();
|
||||
List<Object> values= cache.batchGet(keys);
|
||||
int i=0;
|
||||
Iterator<String> aids=keys.iterator();
|
||||
while(aids.hasNext()) {
|
||||
String aid=aids.next();
|
||||
aid=aid.substring(aid.lastIndexOf(":")+1);
|
||||
userTimeMap.put(aid, (Integer)values.get(i));
|
||||
//System.out.println(aid+"="+values.get(i));
|
||||
i++;
|
||||
}
|
||||
//更新数据库
|
||||
userService.batchUpdateStudyTime(userTimeMap);
|
||||
//删除缓存
|
||||
cache.batchDelete(keys);
|
||||
log.info("更新用户时长任务执行完成");
|
||||
}catch(Exception e) {
|
||||
log.error("更新用户时长错误",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
## redis
|
||||
spring.redis.database=2
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
|
||||
spring.redis.port=6379
|
||||
|
||||
## datasource config
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://192.168.0.10:3306/boe_base1?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
|
||||
|
||||
# logging.level.org.hibernate.SQL=DEBUG
|
||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
|
||||
# 设置logback.xml位置
|
||||
logging.config=classpath:log/logback-dev.xml
|
||||
|
||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
||||
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 上传相磁的路径配置
|
||||
xboe.upload.file.temp_path=E:/Projects/BOE/java/static/temp
|
||||
xboe.upload.file.save_path=E:/Projects/BOE/java/static/upload
|
||||
xboe.upload.file.http_path=http://localhost:9090/cdn/upload
|
||||
|
||||
## 外部接口调用地址 旧系统机构及用户数据接口
|
||||
xboe.externalinterface.url.system=http://localhost:9091
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
jasypt.encryptor.algorithm=PBEWithMD5AndDES
|
||||
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
## redis
|
||||
spring.redis.database=2
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
|
||||
spring.redis.port=6379
|
||||
|
||||
## datasource config
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
|
||||
|
||||
logging.level.org.hibernate.SQL=ERROR
|
||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
|
||||
# 设置logback.xml位置
|
||||
logging.config=classpath:log/logback-pro.xml
|
||||
|
||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
||||
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 上传相磁的路径配置
|
||||
xboe.upload.file.temp_path=E:/Projects/BOE/java/static/temp
|
||||
xboe.upload.file.save_path=E:/Projects/BOE/java/static/upload
|
||||
xboe.upload.file.http_path=http://localhost:9090/cdn/upload
|
||||
|
||||
## 外部接口调用地址 旧系统机构及用户数据接口
|
||||
xboe.externalinterface.url.system=http://localhost:9091
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
jasypt.encryptor.algorithm=PBEWithMD5AndDES
|
||||
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
|
||||
@@ -0,0 +1,37 @@
|
||||
## redis
|
||||
spring.redis.database=2
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
|
||||
spring.redis.port=6379
|
||||
|
||||
## datasource config
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
|
||||
|
||||
logging.level.org.hibernate.SQL=ERROR
|
||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
|
||||
# 设置logback.xml位置
|
||||
logging.config=classpath:log/logback-pro.xml
|
||||
|
||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||
spring.web.resources.static-locations=file:E:/Projects/BOE/java/static
|
||||
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 上传相磁的路径配置
|
||||
xboe.upload.file.temp_path=E:/Projects/BOE/java/static/temp
|
||||
xboe.upload.file.save_path=E:/Projects/BOE/java/static/upload
|
||||
xboe.upload.file.http_path=http://localhost:9090/cdn/upload
|
||||
|
||||
## 外部接口调用地址 旧系统机构及用户数据接口
|
||||
xboe.externalinterface.url.system=http://localhost:9091
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
jasypt.encryptor.algorithm=PBEWithMD5AndDES
|
||||
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
|
||||
@@ -0,0 +1,34 @@
|
||||
## redis
|
||||
spring.redis.database=2
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
|
||||
spring.redis.port=6379
|
||||
|
||||
## datasource config
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=boe_base
|
||||
spring.datasource.password=ENC(MaC28GJw2JcbH8Lil0CrqSDTYxX49FJ0rxcmHH2pX0k=)
|
||||
|
||||
# logging.level.org.hibernate.SQL=DEBUG
|
||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
|
||||
# 设置logback.xml位置
|
||||
logging.config=classpath:log/logback-test.xml
|
||||
|
||||
## xboe config
|
||||
xboe.api.cross_filter=true
|
||||
|
||||
## 上传相磁的路径配置
|
||||
xboe.upload.file.temp_path=/www/wwwroot/file/temp
|
||||
xboe.upload.file.save_path=/www/wwwroot/file/upload
|
||||
xboe.upload.file.http_path=http://114.115.162.187/file/upload
|
||||
|
||||
## 外部接口调用地址 旧系统机构及用户数据接口
|
||||
xboe.externalinterface.url.system=http://127.0.0.1:9091
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
jasypt.encryptor.algorithm=PBEWithMD5AndDES
|
||||
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
|
||||
@@ -0,0 +1,66 @@
|
||||
spring.profiles.active=@profileActive@
|
||||
spring.application.name=boe-server-task
|
||||
server.port=9092
|
||||
server.servlet.session.timeout=30m
|
||||
|
||||
|
||||
server.servlet.encoding.charset=UTF-8
|
||||
server.servlet.encoding.enabled=true
|
||||
server.servlet.encoding.force=true
|
||||
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
|
||||
|
||||
|
||||
ok.http.connect-timeout=30
|
||||
ok.http.read-timeout=30
|
||||
ok.http.write-timeout=30
|
||||
# 连接池中整体的空闲连接的最大数量
|
||||
ok.http.max-idle-connections=200
|
||||
# 连接空闲时间最多为 300 秒
|
||||
ok.http.keep-alive-duration=300
|
||||
|
||||
#spring.jackson.locale=
|
||||
#spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||
# spring.jackson.default-property-inclusion=NON_NULL
|
||||
spring.jackson.time-zone=GMT+8
|
||||
|
||||
spring.servlet.multipart.max-file-size=1024MB
|
||||
spring.servlet.multipart.max-request-size=1024MB
|
||||
|
||||
## 静态文件目录,默认是在static下面,以后独立到nginx下面配置
|
||||
spring.mvc.static-path-pattern=/cdn/**
|
||||
|
||||
spring.redis.database=2
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.password=1Qaz2wsx
|
||||
spring.redis.port=6379
|
||||
|
||||
spring.redis.lettuce.pool.max-active=8
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.pool.max-idle=30
|
||||
spring.redis.lettuce.pool.max-wait=10000ms
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
|
||||
# 上传的临时目录,部署到服务器必须指定
|
||||
# spring.servlet.multipart.location=
|
||||
|
||||
# jpa config
|
||||
spring.jpa.database = MYSQL
|
||||
spring.jpa.show-sql = true
|
||||
# spring.jpa.properties.hibernate.cache.use_second_level_cache=true
|
||||
# spring.jpa.properties.hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.properties.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
#spring.transaction
|
||||
# spring.jpa.properties.hibernate.allow_update_outside_transaction=true
|
||||
# spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
|
||||
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
|
||||
|
||||
|
||||
# 设置logback.xml位置
|
||||
logging.config=classpath:log/logback-@profileActive@.xml
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="logs/${spring.application.name}"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="/home/logs/${spring.application.name}"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="logs/${spring.application.name}"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/debug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user