2,新增敏感词local策略 3,新增随时拜访访客短信模版dev-suit
| @@ -1,6 +1,6 @@ | |||
| package com.xueyi.tenant.api.tenant.domain.dto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode; | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class SysEnterpriseStaffDto extends SysEnterpriseStaff { | |||
| public class SysEnterpriseStaffDto extends SysEnterpriseStaffPo { | |||
| private static final long serialVersionUID = 1L; | |||
| private String oldPhone; | |||
| @@ -0,0 +1,17 @@ | |||
| package com.xueyi.tenant.api.tenant.domain.model; | |||
| import com.xueyi.common.core.web.entity.model.BaseConverter; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.query.SysEnterpriseStaffQuery; | |||
| import org.mapstruct.Mapper; | |||
| import org.mapstruct.MappingConstants; | |||
| /** | |||
| * 租户 对象映射器 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) | |||
| public interface SysStaffConverter extends BaseConverter<SysEnterpriseStaffQuery, SysEnterpriseStaffDto, SysEnterpriseStaffPo> { | |||
| } | |||
| @@ -15,15 +15,13 @@ import java.io.Serial; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @TableName(value = "sys_enterprise_staff", excludeProperty = {"name","sort","createBy","createTime","updateBy","updateTime","remark","tenantId", "status"}) | |||
| public class SysEnterpriseStaff extends TBaseEntity { | |||
| public class SysEnterpriseStaffPo extends TBaseEntity { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| protected Long id; | |||
| protected Long staffId; | |||
| protected String phone; | |||
| private Long tId;//租户号 | |||
| @@ -1,6 +1,6 @@ | |||
| package com.xueyi.tenant.api.tenant.domain.query; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @@ -13,7 +13,7 @@ import java.io.Serial; | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class SysEnterpriseStaffQuery extends SysEnterpriseStaff { | |||
| public class SysEnterpriseStaffQuery extends SysEnterpriseStaffPo { | |||
| @Serial | |||
| private static final long serialVersionUID = 1L; | |||
| @@ -6,7 +6,7 @@ import com.xueyi.common.core.constant.basic.ServiceConstants; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| import com.xueyi.tenant.api.tenant.feign.factory.RemoteTenantFallbackFactory; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| @@ -53,10 +53,10 @@ public interface RemoteTenantService { | |||
| R<TeTenantPo> queryTenantByStaffPhone(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @GetMapping("/tenant/query-staff-by-phone") | |||
| R<SysEnterpriseStaff> queryStaff(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| R<SysEnterpriseStaffPo> queryStaff(@RequestParam ("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| @PostMapping("/tenant/save-staff") | |||
| R<SysEnterpriseStaff> saveEnterpriseStaff(@RequestBody SysEnterpriseStaff staff, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| R<SysEnterpriseStaffPo> saveEnterpriseStaff(@RequestBody SysEnterpriseStaffPo staff, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); | |||
| } | |||
| @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.core.web.result.R; | |||
| import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @@ -61,12 +61,12 @@ public class RemoteTenantFallbackFactory implements FallbackFactory<RemoteTenant | |||
| @Override | |||
| public R<SysEnterpriseStaff> queryStaff(String phone, String source) { | |||
| public R<SysEnterpriseStaffPo> queryStaff(String phone, String source) { | |||
| return R.fail("验证用户手机号失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public R<SysEnterpriseStaff> saveEnterpriseStaff(SysEnterpriseStaff staff, String source) { | |||
| public R<SysEnterpriseStaffPo> saveEnterpriseStaff(SysEnterpriseStaffPo staff, String source) { | |||
| return R.fail("保存员工失败:" + throwable.getMessage()); | |||
| } | |||
| }; | |||
| @@ -23,7 +23,7 @@ import com.xueyi.common.sms.configure.SmsProperties; | |||
| import com.xueyi.system.api.model.LoginUser; | |||
| import com.xueyi.system.api.sms.domain.vo.SmsReqEntity; | |||
| import com.xueyi.system.api.sms.feign.RemoteSmsService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.slf4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -85,7 +85,7 @@ public class TokenController { | |||
| @PostMapping("phoneLogin") | |||
| public AjaxResult loginByPhone(@Valid @RequestBody PhoneLoginBody form) { | |||
| R<SysEnterpriseStaff> staffR = tenantService.queryStaff(form.getPhone(), SecurityConstants.INNER); | |||
| R<SysEnterpriseStaffPo> staffR = tenantService.queryStaff(form.getPhone(), SecurityConstants.INNER); | |||
| if (staffR.isFail() || staffR.getData() == null) { | |||
| return AjaxResult.error("手机号不正确,清查验"); | |||
| } | |||
| @@ -162,7 +162,7 @@ public class TokenController { | |||
| @GetMapping("validCode") | |||
| public R<String> validCode(@RequestParam String phone) { | |||
| R<SysEnterpriseStaff> staff = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| R<SysEnterpriseStaffPo> staff = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| if (staff.getData() == null) { | |||
| return R.fail("手机号不存在,请查验"); | |||
| } | |||
| @@ -28,6 +28,7 @@ public class SmsProperties { | |||
| private String defaultRemindTemplate; | |||
| private String warningTemplate; | |||
| private String visitorTemplate; | |||
| private String vipVisitorTemplate; | |||
| private String robotName; | |||
| private String receptionPhones; | |||
| } | |||
| @@ -12,6 +12,11 @@ import com.xueyi.common.web.entity.manager.impl.handle.BaseHandleManagerImpl; | |||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||
| import java.io.Serializable; | |||
| import java.lang.reflect.Field; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.Collection; | |||
| import java.util.List; | |||
| @@ -296,4 +301,44 @@ public class BaseManagerImpl<Q extends P, D extends P, P extends BaseEntity, PM | |||
| .last(SqlConstants.LIMIT_ONE)); | |||
| return mapperDto(po); | |||
| } | |||
| private <R> R createObj(Class<R> clazz) { | |||
| try { | |||
| return clazz.getDeclaredConstructor().newInstance(); | |||
| } catch (InstantiationException | IllegalAccessException | InvocationTargetException | | |||
| NoSuchMethodException e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| public List<Field> getAllFields(Class<?> clazz) { | |||
| List<Field> fields = new ArrayList<>(); | |||
| while (clazz != null) { | |||
| fields.addAll(Arrays.asList(clazz.getDeclaredFields())); | |||
| clazz = clazz.getSuperclass(); | |||
| } | |||
| return fields; | |||
| } | |||
| public D merge(D origin, D newInstance, Class<D> type) { | |||
| D result = createObj(type); | |||
| for (Field field : getAllFields(type)) { | |||
| field.setAccessible(true); | |||
| try { | |||
| if (Modifier.isFinal(field.getModifiers())){ | |||
| continue; | |||
| } | |||
| Object valueA = field.get(origin); | |||
| Object valueB = field.get(newInstance); | |||
| if (valueB != null) { | |||
| field.set(result, valueB); | |||
| } else { | |||
| field.set(result, valueA); | |||
| } | |||
| } catch (IllegalAccessException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| return result; | |||
| } | |||
| } | |||
| @@ -252,6 +252,13 @@ public class BaseServiceImpl<Q extends BaseEntity, D extends BaseEntity, IDG ext | |||
| } | |||
| } | |||
| public <D> D createObject(Class<D> type) { | |||
| try { | |||
| return type.getDeclaredConstructor().newInstance(); | |||
| } catch (Exception e) { | |||
| return null; | |||
| } | |||
| } | |||
| @Override | |||
| public void saveToEs(BaseEntity dto) { | |||
| @@ -81,6 +81,13 @@ | |||
| <artifactId>xueyi-api-system</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.houbb</groupId> | |||
| <artifactId>sensitive-word</artifactId> | |||
| <version>0.12.0</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| @@ -1,7 +1,6 @@ | |||
| package com.xueyi.nlt.nlt.controller; | |||
| import co.elastic.clients.elasticsearch.ElasticsearchClient; | |||
| import com.alibaba.druid.support.json.JSONUtils; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson2.JSONArray; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| @@ -41,6 +40,7 @@ import com.xueyi.nlt.nlt.domain.LlmContext; | |||
| import com.xueyi.nlt.nlt.domain.LlmParam; | |||
| import com.xueyi.nlt.nlt.domain.LlmResponse; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmIntentDto; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.po.DmRegularPo; | |||
| import com.xueyi.nlt.nlt.domain.query.DmIntentQuery; | |||
| import com.xueyi.nlt.nlt.domain.vo.IntentTemplateVo; | |||
| @@ -50,7 +50,7 @@ import com.xueyi.nlt.nlt.mapper.DmRegularMapper; | |||
| import com.xueyi.nlt.nlt.service.IDmIntentService; | |||
| import com.xueyi.nlt.nlt.service.ISensitiveService; | |||
| import com.xueyi.nlt.nlt.service.ISysLlmService; | |||
| import com.xueyi.nlt.nlt.service.impl.XunFeiSensitiveSeviceImpl; | |||
| import com.xueyi.nlt.nlt.service.impl.DmSensitiveWordServiceImpl; | |||
| import com.xueyi.nlt.nlt.template.*; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
| import com.xueyi.system.api.digitalmans.domain.dto.DmSkillDto; | |||
| @@ -969,6 +969,9 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| @Autowired | |||
| private ISensitiveService sensitiveService; | |||
| @Autowired | |||
| private DmSensitiveWordServiceImpl sensitiveWordService; | |||
| @GetMapping("/api/create-sensitive-lib") | |||
| public AjaxResult addSensitiveBlack(@RequestParam("name") String name, @RequestParam(value = "category" ,required = false) String category, @RequestParam("type") String type){ | |||
| try { | |||
| @@ -991,8 +994,12 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
| String res = ""; | |||
| if ("black".equals(type)) { | |||
| res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.BLACK_LIB_ID, new String[]{content}); | |||
| DmSensitiveWordDto sensitiveWordPo = new DmSensitiveWordDto(content, DmSensitiveWordDto.SENSITIVE_TYPE_BLACK); | |||
| sensitiveWordService.insert(sensitiveWordPo); | |||
| } else { | |||
| res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.WHITE_LIB_ID, new String[]{content}); | |||
| DmSensitiveWordDto sensitiveWordPo = new DmSensitiveWordDto(content, DmSensitiveWordDto.SENSITIVE_TYPE_WHITE); | |||
| sensitiveWordService.insert(sensitiveWordPo); | |||
| } | |||
| return AjaxResult.success(JSON.parse(res)); | |||
| } catch (Exception e) { | |||
| @@ -0,0 +1,21 @@ | |||
| package com.xueyi.nlt.nlt.domain.dto; | |||
| import com.xueyi.nlt.nlt.domain.po.DmSensitiveWordPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class DmSensitiveWordDto extends DmSensitiveWordPo { | |||
| private static final long serialVersionUID = 1L; | |||
| public static final Integer SENSITIVE_TYPE_BLACK = 1; | |||
| public static final Integer SENSITIVE_TYPE_WHITE = 2; | |||
| public DmSensitiveWordDto (){} | |||
| public DmSensitiveWordDto (String content, Integer type){ | |||
| super(content, type); | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| package com.xueyi.nlt.nlt.domain.model; | |||
| import com.xueyi.common.core.web.entity.model.BaseConverter; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.po.DmSensitiveWordPo; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| import org.mapstruct.Mapper; | |||
| import org.mapstruct.MappingConstants; | |||
| @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) | |||
| public interface DmSensitiveWordConverter extends BaseConverter<DmSensitiveWordQuery, DmSensitiveWordDto, DmSensitiveWordPo> { | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| package com.xueyi.nlt.nlt.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.xueyi.common.core.web.tenant.base.TBaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.CREATE_BY; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.CREATE_TIME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.DEL_FLAG; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.NAME; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.REMARK; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.SORT; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.STATUS; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.UPDATE_BY; | |||
| import static com.xueyi.common.core.constant.basic.EntityConstants.UPDATE_TIME; | |||
| /** | |||
| * 访客 持久化对象 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @TableName(value = "dm_sensitive_word", excludeProperty = { SORT, NAME, STATUS, REMARK, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, DEL_FLAG, "tenantId"}) | |||
| public class DmSensitiveWordPo extends TBaseEntity { | |||
| private static final long serialVersionUID = 1L; | |||
| private String content; | |||
| private Integer type; | |||
| public DmSensitiveWordPo (){} | |||
| public DmSensitiveWordPo (String content, Integer type){ | |||
| this.content = content; | |||
| this.type = type; | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| package com.xueyi.nlt.nlt.domain.query; | |||
| import com.xueyi.nlt.nlt.domain.po.DmSensitiveWordPo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class DmSensitiveWordQuery extends DmSensitiveWordPo { | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| package com.xueyi.nlt.nlt.manager; | |||
| import com.xueyi.common.web.entity.manager.IBaseManager; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| public interface IDmSensitiveWordManager extends IBaseManager<DmSensitiveWordQuery, DmSensitiveWordDto> { | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.xueyi.nlt.nlt.manager.impl; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.manager.impl.BaseManagerImpl; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.model.DmSensitiveWordConverter; | |||
| import com.xueyi.nlt.nlt.domain.po.DmSensitiveWordPo; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| import com.xueyi.nlt.nlt.manager.IDmSensitiveWordManager; | |||
| import com.xueyi.nlt.nlt.mapper.DmSensitiveWordMapper; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.List; | |||
| @Component | |||
| public class DmSensitiveWordManager extends BaseManagerImpl<DmSensitiveWordQuery, DmSensitiveWordDto, DmSensitiveWordPo, DmSensitiveWordMapper, DmSensitiveWordConverter> implements IDmSensitiveWordManager { | |||
| @Override | |||
| @TenantIgnore(tenantLine = true) | |||
| public List<DmSensitiveWordDto> selectList(DmSensitiveWordQuery query) { | |||
| List<DmSensitiveWordPo> poList = baseMapper.selectList(selectListQuery(query)); | |||
| return subMerge(mapperDto(poList)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| package com.xueyi.nlt.nlt.mapper; | |||
| import com.xueyi.common.datasource.annotation.Master; | |||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.po.DmSensitiveWordPo; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| @Master | |||
| public interface DmSensitiveWordMapper extends BaseMapper<DmSensitiveWordQuery, DmSensitiveWordDto, DmSensitiveWordPo> { | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| package com.xueyi.nlt.nlt.service; | |||
| import com.xueyi.common.web.entity.service.IBaseService; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| public interface IDmSensitiveWordService extends IBaseService<DmSensitiveWordQuery, DmSensitiveWordDto> { | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.xueyi.nlt.nlt.service.impl; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.nlt.nlt.domain.dto.DmSensitiveWordDto; | |||
| import com.xueyi.nlt.nlt.domain.query.DmSensitiveWordQuery; | |||
| import com.xueyi.nlt.nlt.manager.IDmSensitiveWordManager; | |||
| import com.xueyi.nlt.nlt.service.IDmSensitiveWordService; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.annotation.PostConstruct; | |||
| import java.util.List; | |||
| @Service | |||
| public class DmSensitiveWordServiceImpl extends BaseServiceImpl<DmSensitiveWordQuery, DmSensitiveWordDto, IDmSensitiveWordManager> implements IDmSensitiveWordService { | |||
| @Override | |||
| public List<DmSensitiveWordDto> selectList(DmSensitiveWordQuery query) { | |||
| return super.selectList(query); | |||
| } | |||
| //TODO. 查询自定义敏感词库,塞入缓存 | |||
| @PostConstruct | |||
| public void init() { | |||
| this.selectList(null); | |||
| System.err.println("init"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package com.xueyi.nlt.nlt.service.impl; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.github.houbb.sensitive.word.core.SensitiveWordHelper; | |||
| import com.xueyi.nlt.nlt.service.ISensitiveService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |||
| import org.springframework.stereotype.Service; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-01-15 15:53 | |||
| */ | |||
| @Service | |||
| @ConditionalOnProperty(name = "sensitive.type", havingValue = "local", matchIfMissing = true) | |||
| public class LocalSensitiveServiceImpl implements ISensitiveService { | |||
| Logger logger = LoggerFactory.getLogger(LocalSensitiveServiceImpl.class); | |||
| @Override | |||
| public String addKeyWord(String libId, String[] wordList) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public String createWhite(String name) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public String createBlack(String name, String category) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public String checkSensitiveWord(String content, Integer useLib) { | |||
| JSONObject jsonObject = new JSONObject(); | |||
| JSONObject jsonObject2 = new JSONObject(); | |||
| jsonObject2.put("suggest",SensitiveWordHelper.contains(content)? "block":"pass"); | |||
| jsonObject.put("result", jsonObject2); | |||
| JSONObject json = new JSONObject(); | |||
| json.put("data", jsonObject); | |||
| return json.toJSONString(); | |||
| } | |||
| } | |||
| @@ -42,9 +42,9 @@ import java.util.UUID; | |||
| */ | |||
| @Service | |||
| @Primary | |||
| public class XunFeiSensitiveSeviceImpl implements ISensitiveService { | |||
| public class XunFeiSensitiveServiceImpl implements ISensitiveService { | |||
| Logger logger = LoggerFactory.getLogger(XunFeiSensitiveSeviceImpl.class); | |||
| Logger logger = LoggerFactory.getLogger(XunFeiSensitiveServiceImpl.class); | |||
| private String appid; | |||
| private String APIKey; | |||
| @@ -9,7 +9,6 @@ import com.xueyi.system.common.service.IDmHolidayService; | |||
| import org.springframework.stereotype.Service; | |||
| import java.time.LocalDate; | |||
| import java.util.Date; | |||
| @Service | |||
| public class IDmHolidayServiceImpl extends BaseServiceImpl<DmHolidayQuery, DmHolidayDto, IDmHolidayManager> implements IDmHolidayService { | |||
| @@ -1,10 +1,5 @@ | |||
| package com.xueyi.system.staff.controller; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.xueyi.common.cache.utils.SourceUtil; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.core.IdUtil; | |||
| import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.core.utils.core.StrUtil; | |||
| import com.xueyi.common.core.utils.file.FileTypeUtil; | |||
| @@ -21,21 +16,14 @@ import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.file.api.domain.SysFile; | |||
| import com.xueyi.file.api.feign.RemoteFileService; | |||
| import com.xueyi.nlt.api.netty.domain.vo.DmWebSocketMessageVo; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
| import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.api.staff.domain.vo.DmStaffFeature; | |||
| import com.xueyi.system.authority.service.ISysLoginService; | |||
| import com.xueyi.system.organize.service.ISysEnterpriseService; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.IDmResourcesService; | |||
| import com.xueyi.system.staff.domain.query.DmStaffQuery; | |||
| import com.xueyi.system.staff.service.IDmStaffService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||
| @@ -51,7 +39,6 @@ import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.Serializable; | |||
| import java.util.Arrays; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| @@ -71,19 +58,9 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @Autowired | |||
| private RemoteFileService remoteFileService; | |||
| @Autowired | |||
| private RemoteIntentService remoteIntentService; | |||
| @Autowired | |||
| ISysEnterpriseService enterpriseService; | |||
| @Autowired | |||
| IDmResourcesService resourcesService; | |||
| @Autowired | |||
| RemoteTenantService tenantService; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| protected String getNodeName() { | |||
| @@ -140,50 +117,7 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @RequiresPermissions(Auth.DM_STAFF_ADD) | |||
| @Log(title = "人员管理", businessType = BusinessType.INSERT) | |||
| public AjaxResult add(@Validated({V_A.class}) @RequestBody DmStaffDto dmStaff) { | |||
| Long tenantId = Long.parseLong(String.valueOf(SecurityContextHolder.getLocalMap().get("enterprise_id"))); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| if (dmStaff.getResourceId() != null) { | |||
| DmResourcesDto dto = resourcesService.selectById(dmStaff.getResourceId()); | |||
| if (dto != null) { | |||
| dmStaff.setAvatar(dto.getUrl()); | |||
| } | |||
| } | |||
| long id = IdUtil.getSnowflakeNextId(); | |||
| dmStaff.setId(id); | |||
| //以下代码添加主库企业和员工的关系映射表,用于手机号登录以及小程序登录 | |||
| SysEnterpriseStaff enterpriseStaff = new SysEnterpriseStaff(); | |||
| enterpriseStaff.setPhone(dmStaff.getPhone()); | |||
| enterpriseStaff.setStaffId(id); | |||
| enterpriseStaff.setId(id); | |||
| enterpriseStaff.setTId(SecurityContextHolder.getEnterpriseId()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| AjaxResult result = super.add(dmStaff); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| JSONObject birthJson = new JSONObject(); | |||
| birthJson.put("name",dmStaff.getUserName()); | |||
| birthJson.put("orderId",dmStaff.getId()); | |||
| birthJson.put("years",new Date().getYear() - dmStaff.getBirthDate().getYear()); | |||
| birthJson.put("timestamp",dmStaff.getBirthDate().getTime()); | |||
| vo.setTemplate("birthday"); | |||
| vo.setFormat(birthJson); | |||
| System.out.println(birthJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| if (dmStaff.getHireDate() != null) { | |||
| DmWebSocketMessageVo vo2 = new DmWebSocketMessageVo(); | |||
| JSONObject hireJson = new JSONObject(); | |||
| hireJson.put("name",dmStaff.getUserName()); | |||
| hireJson.put("orderId",dmStaff.getId()); | |||
| hireJson.put("years",new Date().getYear() - dmStaff.getHireDate().getYear()); | |||
| hireJson.put("timestamp",dmStaff.getHireDate().getTime()); | |||
| vo2.setTemplate("hireDate"); | |||
| vo2.setFormat(hireJson); | |||
| System.out.println(hireJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo2,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| return result; | |||
| return super.add(dmStaff); | |||
| } | |||
| /** | |||
| @@ -194,40 +128,6 @@ public class DmStaffController extends BaseController<DmStaffQuery, DmStaffDto, | |||
| @RequiresPermissions(Auth.DM_STAFF_EDIT) | |||
| @Log(title = "人员管理", businessType = BusinessType.UPDATE) | |||
| public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmStaffDto dmStaff) { | |||
| Long tenantId = Long.parseLong(String.valueOf(SecurityContextHolder.getLocalMap().get("enterprise_id"))); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| SysEnterpriseStaff enterpriseStaff = new SysEnterpriseStaff(); | |||
| enterpriseStaff.setPhone(dmStaff.getPhone()); | |||
| enterpriseStaff.setStaffId(dmStaff.getId()); | |||
| enterpriseStaff.setId(dmStaff.getId()); | |||
| enterpriseStaff.setTId(SecurityContextHolder.getEnterpriseId()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| JSONObject birthJson = new JSONObject(); | |||
| birthJson.put("name",dmStaff.getUserName()); | |||
| birthJson.put("orderId",dmStaff.getId()); | |||
| birthJson.put("years",new Date().getYear() - dmStaff.getBirthDate().getYear()); | |||
| birthJson.put("timestamp",dmStaff.getBirthDate().getTime()); | |||
| vo.setTemplate("birthday"); | |||
| vo.setFormat(birthJson); | |||
| System.out.println(birthJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| if (dmStaff.getHireDate() != null) { | |||
| DmWebSocketMessageVo vo2 = new DmWebSocketMessageVo(); | |||
| JSONObject hireJson = new JSONObject(); | |||
| hireJson.put("name",dmStaff.getUserName()); | |||
| hireJson.put("orderId",dmStaff.getId()); | |||
| hireJson.put("years",new Date().getYear() - dmStaff.getHireDate().getYear()); | |||
| hireJson.put("timestamp",dmStaff.getHireDate().getTime()); | |||
| vo2.setTemplate("hireDate"); | |||
| vo2.setFormat(hireJson); | |||
| System.out.println(hireJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo2,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| return super.edit(dmStaff); | |||
| } | |||
| @@ -9,9 +9,11 @@ import com.xueyi.common.log.enums.BusinessType; | |||
| import com.xueyi.common.security.annotation.RequiresPermissions; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitRecordsPo; | |||
| import com.xueyi.system.api.digitalmans.domain.po.DmVisitorsPo; | |||
| import com.xueyi.system.staff.domain.dto.DmVisitorSmsConfigDto; | |||
| import com.xueyi.system.staff.domain.query.DmVisitorSmsConfigQuery; | |||
| import com.xueyi.system.staff.mapper.DmVisitRecordsMapper; | |||
| import com.xueyi.system.staff.mapper.DmVisitorsMapper; | |||
| import com.xueyi.system.staff.service.IDmVisitorSmsConfigService; | |||
| import com.xueyi.system.staff.service.impl.DmVisitRecordsServiceImpl; | |||
| import com.xueyi.system.staff.service.impl.DmVisitorSmsConfigServiceImpl; | |||
| @@ -49,6 +51,10 @@ public class DmVisitorSmsConfigController extends BaseController<DmVisitorSmsCon | |||
| private DmVisitRecordsMapper visitRecordsMapper; | |||
| @Autowired | |||
| private DmVisitorsMapper visitorsMapper; | |||
| /** 定义节点名称 */ | |||
| @Override | |||
| @@ -120,8 +126,8 @@ public class DmVisitorSmsConfigController extends BaseController<DmVisitorSmsCon | |||
| @GetMapping("/send-sms") | |||
| public AjaxResult sendVisitorSms(@RequestParam("visitRecordId") Long visitRecordId, @RequestParam(value = "staffId", required = false) Long staffId) { | |||
| if (null != visitRecordId) { | |||
| public AjaxResult sendVisitorSms(@RequestParam("visitRecordId") Long visitRecordId, @RequestParam(value = "staffId", required = false) Long staffId, @RequestParam(value = "visitorId", required = false) Long visitorId) { | |||
| if (null != visitRecordId && -1 != visitRecordId) { | |||
| DmVisitRecordsPo po = visitRecordsMapper.selectById(visitRecordId); | |||
| R<String> r = visitRecordsService.sendSms(po); | |||
| if (r.isOk()) { | |||
| @@ -129,8 +135,15 @@ public class DmVisitorSmsConfigController extends BaseController<DmVisitorSmsCon | |||
| } else { | |||
| return AjaxResult.error(r.getMsg()); | |||
| } | |||
| } else {//随时到访人员发短信 | |||
| DmVisitorsPo po = visitorsMapper.selectById(visitorId); | |||
| R<String> r = visitRecordsService.sendSms(po, staffId); | |||
| if (r.isOk()) { | |||
| return AjaxResult.success("短信发送成功,请注意查收"); | |||
| } else { | |||
| return AjaxResult.error(r.getMsg()); | |||
| } | |||
| } | |||
| return AjaxResult.success("短信发送成功,请注意查收"); | |||
| } | |||
| /** | |||
| @@ -0,0 +1,67 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.xueyi.common.core.utils.core.IdUtil; | |||
| import com.xueyi.system.api.resource.domain.po.DmResourcesPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| import com.xueyi.system.resource.mapper.DmResourcesMapper; | |||
| import com.xueyi.system.staff.domain.model.DmStaffConverter; | |||
| import com.xueyi.system.staff.manager.impl.DmStaffManager; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import graphql.kickstart.tools.GraphQLMutationResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class StaffGraphQLMutationResolver implements GraphQLMutationResolver { | |||
| @Autowired | |||
| private DmStaffMapper mapper; | |||
| @Autowired | |||
| private DmResourcesMapper resourcesMapper; | |||
| @Autowired | |||
| private DmStaffManager staffManager; | |||
| @Autowired | |||
| private DmStaffConverter staffConverter; | |||
| private DmStaffDto initPo(DmStaffDto po) { | |||
| if (null != po.getResourceId() && null == po.getAvatar()) { | |||
| DmResourcesPo resourcesPo = resourcesMapper.selectById(po.getResourceId()); | |||
| if (null != resourcesPo) { | |||
| po.setAvatar(resourcesPo.getUrl()); | |||
| } | |||
| } | |||
| DmStaffDto dto2 = null; | |||
| if (null != po.getId()) { | |||
| DmStaffDto dto = staffConverter.mapperDto(mapper.selectById(po.getId())); | |||
| if (null != dto) { | |||
| dto2 = staffManager.merge(dto, po, DmStaffDto.class); | |||
| } | |||
| } | |||
| return dto2 == null ? po : staffConverter.mapperDto(dto2); | |||
| } | |||
| public DmStaffDto updateStaff(DmStaffDto po){ | |||
| Boolean result = mapper.updateById(initPo(po)) > 0; | |||
| return result ? po : null; | |||
| } | |||
| public DmStaffDto createStaff(DmStaffDto po){ | |||
| po.setId(IdUtil.getSnowflakeNextId()); | |||
| Boolean result = mapper.insert(initPo(po)) > 0; | |||
| return result ? po : null; | |||
| } | |||
| public Boolean deleteStaff(Long id){ | |||
| return mapper.deleteById(id) > 0; | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| package com.xueyi.system.staff.graphql; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.staff.domain.model.DmStaffConverter; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import graphql.kickstart.tools.GraphQLQueryResolver; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.List; | |||
| /* | |||
| * @author yk | |||
| * @description | |||
| * @date 2023-12-25 19:55 | |||
| */ | |||
| @Component | |||
| class StaffGraphQLQueryResolver implements GraphQLQueryResolver { | |||
| @Autowired | |||
| private DmStaffMapper mapper; | |||
| @Autowired | |||
| private DmStaffConverter converter; | |||
| public DmStaffDto staff(Long id){ | |||
| return converter.mapperDto(mapper.selectById(id)); | |||
| } | |||
| public List<DmStaffDto> staffs(Long id, String userName, String nickName, Integer userType, String phone){ | |||
| QueryWrapper<DmStaffPo> query = new QueryWrapper<>(); | |||
| if (null != id) { | |||
| query.eq("id", id); | |||
| } | |||
| if (StringUtils.isNotEmpty(userName)) { | |||
| query.like("user_name", userName); | |||
| } | |||
| if (StringUtils.isNotEmpty(nickName)) { | |||
| query.like("nick_name", nickName); | |||
| } | |||
| if (null != userType) { | |||
| query.eq("type", userType); | |||
| } | |||
| if (StringUtils.isNotEmpty(phone)) { | |||
| query.eq("phone", phone); | |||
| } | |||
| query.orderByDesc("id"); | |||
| return mapper.selectList(query).stream().map(t->converter.mapperDto(t)).toList(); | |||
| } | |||
| } | |||
| @@ -2,13 +2,22 @@ package com.xueyi.system.staff.service.impl; | |||
| import cn.hutool.core.date.LocalDateTimeUtil; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.xueyi.common.cache.utils.SourceUtil; | |||
| import com.xueyi.common.core.constant.basic.SecurityConstants; | |||
| import com.xueyi.common.core.context.SecurityContextHolder; | |||
| import com.xueyi.common.core.utils.core.IdUtil; | |||
| import com.xueyi.common.core.utils.core.ObjectUtil; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.service.impl.BaseServiceImpl; | |||
| import com.xueyi.common.web.utils.MyDateUtils; | |||
| import com.xueyi.nlt.api.netty.domain.vo.DmWebSocketMessageVo; | |||
| import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
| import com.xueyi.system.api.holiday.domain.po.DmHolidayPo; | |||
| import com.xueyi.system.api.model.Source; | |||
| import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; | |||
| import com.xueyi.system.api.organize.domain.vo.SysDeptExt; | |||
| import com.xueyi.system.api.pass.domain.po.DmRecognizedRecordsPo; | |||
| import com.xueyi.system.api.staff.domain.dto.DmStaffDto; | |||
| @@ -16,12 +25,17 @@ import com.xueyi.system.api.staff.domain.po.DmStaffPo; | |||
| import com.xueyi.system.api.staff.domain.vo.DmStaffFeature; | |||
| import com.xueyi.system.common.service.IDmHolidayService; | |||
| import com.xueyi.system.organize.mapper.SysDeptExtMapper; | |||
| import com.xueyi.system.organize.service.ISysEnterpriseService; | |||
| import com.xueyi.system.resource.domain.dto.DmResourcesDto; | |||
| import com.xueyi.system.resource.service.impl.DmResourcesServiceImpl; | |||
| import com.xueyi.system.staff.domain.po.DmEmpAttendancePo; | |||
| import com.xueyi.system.staff.domain.query.DmStaffQuery; | |||
| import com.xueyi.system.staff.manager.IDmStaffManager; | |||
| import com.xueyi.system.staff.mapper.DmEmpAttendanceMapper; | |||
| import com.xueyi.system.staff.mapper.DmStaffMapper; | |||
| import com.xueyi.system.staff.service.IDmStaffService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -245,4 +259,102 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto | |||
| dmEmpAttendanceMapper.insert(ea); | |||
| } | |||
| } | |||
| @Autowired | |||
| private DmResourcesServiceImpl resourcesService; | |||
| @Autowired | |||
| private RemoteTenantService tenantService; | |||
| @Autowired | |||
| ISysEnterpriseService enterpriseService; | |||
| @Autowired | |||
| private RemoteIntentService remoteIntentService; | |||
| @Override | |||
| public int insert(DmStaffDto dmStaff) { | |||
| if (dmStaff.getResourceId() != null) { | |||
| DmResourcesDto dto = resourcesService.selectById(dmStaff.getResourceId()); | |||
| if (dto != null) { | |||
| dmStaff.setAvatar(dto.getUrl()); | |||
| } | |||
| } | |||
| long id = IdUtil.getSnowflakeNextId(); | |||
| dmStaff.setId(id); | |||
| //以下代码添加主库企业和员工的关系映射表,用于手机号登录以及小程序登录 | |||
| SysEnterpriseStaffPo enterpriseStaff = new SysEnterpriseStaffPo(); | |||
| enterpriseStaff.setPhone(dmStaff.getPhone()); | |||
| enterpriseStaff.setId(id); | |||
| Long tenantId = SecurityContextHolder.getEnterpriseId(); | |||
| enterpriseStaff.setTId(tenantId); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| JSONObject birthJson = new JSONObject(); | |||
| birthJson.put("name",dmStaff.getUserName()); | |||
| birthJson.put("orderId",dmStaff.getId()); | |||
| birthJson.put("years",new Date().getYear() - dmStaff.getBirthDate().getYear()); | |||
| birthJson.put("timestamp",dmStaff.getBirthDate().getTime()); | |||
| vo.setTemplate("birthday"); | |||
| vo.setFormat(birthJson); | |||
| System.out.println(birthJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| if (dmStaff.getHireDate() != null) { | |||
| DmWebSocketMessageVo vo2 = new DmWebSocketMessageVo(); | |||
| JSONObject hireJson = new JSONObject(); | |||
| hireJson.put("name",dmStaff.getUserName()); | |||
| hireJson.put("orderId",dmStaff.getId()); | |||
| hireJson.put("years",new Date().getYear() - dmStaff.getHireDate().getYear()); | |||
| hireJson.put("timestamp",dmStaff.getHireDate().getTime()); | |||
| vo2.setTemplate("hireDate"); | |||
| vo2.setFormat(hireJson); | |||
| System.out.println(hireJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo2,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| return super.insert(dmStaff); | |||
| } | |||
| public int update(DmStaffDto dmStaff) { | |||
| Long tenantId = SecurityContextHolder.getEnterpriseId(); | |||
| SysEnterpriseDto enterpriseDto = enterpriseService.selectById(tenantId); | |||
| Source source = SourceUtil.getSourceCache(enterpriseDto.getStrategyId()); | |||
| SysEnterpriseStaffPo enterpriseStaff = new SysEnterpriseStaffPo(); | |||
| enterpriseStaff.setPhone(dmStaff.getPhone()); | |||
| enterpriseStaff.setId(dmStaff.getId()); | |||
| enterpriseStaff.setTId(SecurityContextHolder.getEnterpriseId()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| if (dmStaff.getBirthDate() != null) { | |||
| DmWebSocketMessageVo vo = new DmWebSocketMessageVo(); | |||
| JSONObject birthJson = new JSONObject(); | |||
| birthJson.put("name",dmStaff.getUserName()); | |||
| birthJson.put("orderId",dmStaff.getId()); | |||
| birthJson.put("years",new Date().getYear() - dmStaff.getBirthDate().getYear()); | |||
| birthJson.put("timestamp",dmStaff.getBirthDate().getTime()); | |||
| vo.setTemplate("birthday"); | |||
| vo.setFormat(birthJson); | |||
| System.out.println(birthJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| if (dmStaff.getHireDate() != null) { | |||
| DmWebSocketMessageVo vo2 = new DmWebSocketMessageVo(); | |||
| JSONObject hireJson = new JSONObject(); | |||
| hireJson.put("name",dmStaff.getUserName()); | |||
| hireJson.put("orderId",dmStaff.getId()); | |||
| hireJson.put("years",new Date().getYear() - dmStaff.getHireDate().getYear()); | |||
| hireJson.put("timestamp",dmStaff.getHireDate().getTime()); | |||
| vo2.setTemplate("hireDate"); | |||
| vo2.setFormat(hireJson); | |||
| System.out.println(hireJson.toJSONString()); | |||
| remoteIntentService.sendMessage(vo2,tenantId,source.getMaster(), SecurityConstants.INNER); | |||
| } | |||
| return super.update(dmStaff); | |||
| } | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.xueyi.system.staff.service.impl; | |||
| import cn.hutool.core.date.LocalDateTimeUtil; | |||
| import cn.hutool.core.util.BooleanUtil; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | |||
| @@ -200,6 +201,9 @@ public class DmVisitRecordsServiceImpl extends BaseServiceImpl<DmVisitRecordsQue | |||
| send.setPhone(visitorsPo.getPhone()); | |||
| send.setTemplate(smsProperties.getVisitorTemplate()); | |||
| if (BooleanUtil.isTrue(visitorsPo.getFlexVisit())) { | |||
| send.setTemplate(smsProperties.getVipVisitorTemplate()); | |||
| } | |||
| send.setDataMap(json.toJSONString()); | |||
| JSONObject result = smsService.sendSms(send); | |||
| @@ -217,5 +221,45 @@ public class DmVisitRecordsServiceImpl extends BaseServiceImpl<DmVisitRecordsQue | |||
| return R.ok("发送成功"); | |||
| } | |||
| public R<String> sendSms(DmVisitorsPo po, Long staffId) { | |||
| log.info("sendSms po:{}", JSON.toJSONString(po)); | |||
| if (null != po && null != po.getId()) { | |||
| DmVisitorsPo visitorsPo = visitorsMapper.selectById(po.getId()); | |||
| SmsReqEntity send = new SmsReqEntity(); | |||
| try { | |||
| if (null != visitorsPo && StringUtils.isNotEmpty(visitorsPo.getPhone()) && BooleanUtil.isTrue(visitorsPo.getFlexVisit())) { | |||
| DmDigitalmanPo dmDigitalmanPo = digitalmanMapper.selectByCode(digitalmanExtMapper.selectOne(Wrappers.<DmDigitalmanExtPo>query().lambda().last(SqlConstants.LIMIT_ONE)).getManCode()); | |||
| JSONObject json = new JSONObject(); | |||
| json.put("nickName", visitorsPo.getName()); | |||
| json.put("robotName", dmDigitalmanPo.getName()); | |||
| //给访客发送短信 | |||
| send.setPhone(visitorsPo.getPhone()); | |||
| send.setTemplate(smsProperties.getVisitorTemplate()); | |||
| if (BooleanUtil.isTrue(visitorsPo.getFlexVisit())) { | |||
| send.setTemplate(smsProperties.getVipVisitorTemplate()); | |||
| } | |||
| send.setDataMap(json.toJSONString()); | |||
| JSONObject result = smsService.sendSms(send); | |||
| DmStaffPo staffPo = staffMapper.selectById(staffId); | |||
| DmVisitorOperateLogDto visitorOperateLogPo = visitorOperateLogService.initData(po.getId(), staffPo.getId(), DmVisitorOperateLogDto.BUSINESS_TYPE_OTHER, "sendSms", JSON.toJSONString(send), result.toJSONString()); | |||
| visitorOperateLogService.insert(visitorOperateLogPo); | |||
| } else { | |||
| return R.fail("数据存在问题"); | |||
| } | |||
| } catch (Exception e) { | |||
| log.error("发送短信异常", e.getMessage()); | |||
| return R.fail("服务器错误,无法发送短信"); | |||
| } | |||
| } | |||
| return R.ok("发送成功"); | |||
| } | |||
| } | |||
| @@ -17,7 +17,7 @@ import com.xueyi.system.wechat.domain.bean.WeappSessionResponse; | |||
| import com.xueyi.system.wechat.domain.bean.WeappSignUpReq; | |||
| import com.xueyi.system.wechat.domain.po.WeappUserInfo; | |||
| import com.xueyi.system.wechat.service.WeappService; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.feign.RemoteTenantService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -73,11 +73,11 @@ public class WeappController { | |||
| } | |||
| log.info("微信login返回信息:{}", weChatUserInfo); | |||
| R<SysEnterpriseStaff> staffR = tenantService.queryStaff(weChatUserInfo.getOpenid(), SecurityConstants.INNER); | |||
| R<SysEnterpriseStaffPo> staffR = tenantService.queryStaff(weChatUserInfo.getOpenid(), SecurityConstants.INNER); | |||
| Map<String, Object> map = new HashMap<>(); | |||
| try { | |||
| map.put("weappAuth", CryptoUtil.encrypt(weChatUserInfo.toString())); | |||
| SysEnterpriseStaff staff = staffR.getData(); | |||
| SysEnterpriseStaffPo staff = staffR.getData(); | |||
| log.info("login staff:{}", staff); | |||
| if (staff != null) { | |||
| log.info("login phone:{}", staff.getPhone()); | |||
| @@ -140,10 +140,10 @@ public class WeappController { | |||
| return AjaxResult.error("手机号无对应员工,请查证后重试!"); | |||
| } else { | |||
| Map<String, Object> map = tokenService.createToken(loginInfoResult.getData()); | |||
| R<SysEnterpriseStaff> enterpriseStaffR = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| R<SysEnterpriseStaffPo> enterpriseStaffR = tenantService.queryStaff(phone, SecurityConstants.INNER); | |||
| log.info("根据手机号查询员工返回:{}", enterpriseStaffR); | |||
| if (!enterpriseStaffR.isFail() && enterpriseStaffR.getData() != null){ | |||
| SysEnterpriseStaff enterpriseStaff = enterpriseStaffR.getData(); | |||
| SysEnterpriseStaffPo enterpriseStaff = enterpriseStaffR.getData(); | |||
| enterpriseStaff.setOpenid(obj.getOpenid()); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| } | |||
| @@ -170,10 +170,10 @@ public class WeappController { | |||
| try { | |||
| String str = CryptoUtil.decrypt(signUpReq.getWeappAuth()); | |||
| WeappSessionResponse obj = JSON.parseObject(str, WeappSessionResponse.class); | |||
| R<SysEnterpriseStaff> enterpriseStaffR = tenantService.queryStaff(obj.getOpenid(), SecurityConstants.INNER); | |||
| R<SysEnterpriseStaffPo> enterpriseStaffR = tenantService.queryStaff(obj.getOpenid(), SecurityConstants.INNER); | |||
| log.info("根据手机号查询员工返回:{}", enterpriseStaffR); | |||
| if (!enterpriseStaffR.isFail() && enterpriseStaffR.getData() != null){ | |||
| SysEnterpriseStaff enterpriseStaff = enterpriseStaffR.getData(); | |||
| SysEnterpriseStaffPo enterpriseStaff = enterpriseStaffR.getData(); | |||
| enterpriseStaff.setOpenid(null); | |||
| tenantService.saveEnterpriseStaff(enterpriseStaff, SecurityConstants.INNER); | |||
| } | |||
| @@ -0,0 +1,55 @@ | |||
| extend type Query { | |||
| staffs( | |||
| id: ID | |||
| userName: String | |||
| nickName: String | |||
| userType: Int | |||
| phone: String | |||
| ): [Staff!] | |||
| staff(id: ID): Staff | |||
| } | |||
| input StaffInput { | |||
| id: ID | |||
| userName: String | |||
| nickName: String | |||
| phone: String | |||
| email: String | |||
| sex: String | |||
| userType: Int | |||
| deptId: String | |||
| avatar: String | |||
| resourceId: ID | |||
| # 删除标识,1:已删除;0:未删除 | |||
| delFlag: Int | |||
| } | |||
| extend type Mutation { | |||
| createStaff( | |||
| input: StaffInput! | |||
| ): Staff | |||
| updateStaff( | |||
| input: StaffInput! | |||
| ): Staff | |||
| deleteStaff( | |||
| id: ID!, | |||
| ): Boolean | |||
| } | |||
| type Staff { | |||
| id: ID | |||
| userName: String | |||
| nickName: String | |||
| phone: String | |||
| email: String | |||
| sex: String | |||
| userType: Int | |||
| deptId: String | |||
| avatar: String | |||
| resourceId: ID | |||
| # 删除标识,1:已删除;0:未删除 | |||
| delFlag: Int | |||
| } | |||
| @@ -20,11 +20,14 @@ import com.xueyi.common.security.auth.Auth; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.controller.BaseController; | |||
| import com.xueyi.common.web.entity.domain.mapper.DeviceTenantMergeMapper; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.TeTenantDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.model.SysStaffConverter; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| import com.xueyi.tenant.api.tenant.domain.query.TeTenantQuery; | |||
| import com.xueyi.tenant.tenant.domain.model.TeTenantRegister; | |||
| import com.xueyi.tenant.tenant.manager.impl.SysStaffManagerImpl; | |||
| import com.xueyi.tenant.tenant.mapper.SysEnterpriseStaffMapper; | |||
| import com.xueyi.tenant.tenant.service.ITeTenantService; | |||
| import org.slf4j.Logger; | |||
| @@ -67,6 +70,12 @@ public class TeTenantController extends BaseController<TeTenantQuery, TeTenantDt | |||
| @Autowired | |||
| private SysEnterpriseStaffMapper staffMapper; | |||
| @Autowired | |||
| private SysStaffManagerImpl staffManager; | |||
| @Autowired | |||
| private SysStaffConverter staffConverter; | |||
| /** | |||
| * 租户新增 | 内部调用 | |||
| */ | |||
| @@ -119,19 +128,19 @@ public class TeTenantController extends BaseController<TeTenantQuery, TeTenantDt | |||
| @InnerAuth | |||
| @GetMapping("/query-staff-by-phone") | |||
| R<SysEnterpriseStaff> queryStaff(@RequestParam("phone") String phone) { | |||
| SysEnterpriseStaff po = staffMapper.selectStaffByPhone(phone); | |||
| R<SysEnterpriseStaffPo> queryStaff(@RequestParam("phone") String phone) { | |||
| SysEnterpriseStaffPo po = staffMapper.selectStaffByPhone(phone); | |||
| return R.ok(po); | |||
| } | |||
| @InnerAuth | |||
| @PostMapping("/save-staff") | |||
| @TenantIgnore(tenantLine = true) | |||
| R<SysEnterpriseStaff> staff(@RequestBody SysEnterpriseStaff staff) { | |||
| R<SysEnterpriseStaffPo> staff(@RequestBody SysEnterpriseStaffPo staff) { | |||
| if (staff.getId() != null) { | |||
| SysEnterpriseStaff staffPo = staffMapper.selectById(staff.getId()); | |||
| SysEnterpriseStaffPo staffPo = staffMapper.selectById(staff.getId()); | |||
| if (null != staffPo) { | |||
| staffMapper.updateById(staff); | |||
| staffMapper.updateById(staffManager.merge(staffConverter.mapperDto(staffPo), staffConverter.mapperDto(staff), SysEnterpriseStaffDto.class)); | |||
| } else { | |||
| staffMapper.insert(staff); | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.xueyi.tenant.tenant.manager; | |||
| import com.xueyi.common.web.entity.manager.IBaseManager; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto; | |||
| import com.xueyi.tenant.api.tenant.domain.query.SysEnterpriseStaffQuery; | |||
| /** | |||
| * 租户管理 数据封装层 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| public interface ISysStaffManager extends IBaseManager<SysEnterpriseStaffQuery, SysEnterpriseStaffDto> { | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| package com.xueyi.tenant.tenant.manager.impl; | |||
| import com.xueyi.common.web.entity.manager.impl.BaseManagerImpl; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto; | |||
| import com.xueyi.tenant.api.tenant.domain.model.SysStaffConverter; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.query.SysEnterpriseStaffQuery; | |||
| import com.xueyi.tenant.tenant.manager.ISysStaffManager; | |||
| import com.xueyi.tenant.tenant.mapper.SysEnterpriseStaffMapper; | |||
| import org.springframework.stereotype.Component; | |||
| /** | |||
| * 租户管理 数据封装层处理 | |||
| * | |||
| * @author xueyi | |||
| */ | |||
| @Component | |||
| public class SysStaffManagerImpl extends BaseManagerImpl<SysEnterpriseStaffQuery, SysEnterpriseStaffDto, SysEnterpriseStaffPo, SysEnterpriseStaffMapper, SysStaffConverter> implements ISysStaffManager { | |||
| } | |||
| @@ -4,7 +4,7 @@ import com.xueyi.common.datasource.annotation.Master; | |||
| import com.xueyi.common.web.annotation.TenantIgnore; | |||
| import com.xueyi.common.web.entity.mapper.BaseMapper; | |||
| import com.xueyi.tenant.api.tenant.domain.dto.SysEnterpriseStaffDto; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff; | |||
| import com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo; | |||
| import com.xueyi.tenant.api.tenant.domain.po.TeTenantPo; | |||
| import com.xueyi.tenant.api.tenant.domain.query.SysEnterpriseStaffQuery; | |||
| import org.apache.ibatis.annotations.Param; | |||
| @@ -15,13 +15,13 @@ import org.apache.ibatis.annotations.Param; | |||
| * @author xueyi | |||
| */ | |||
| @Master | |||
| public interface SysEnterpriseStaffMapper extends BaseMapper<SysEnterpriseStaffQuery, SysEnterpriseStaffDto, SysEnterpriseStaff> { | |||
| public interface SysEnterpriseStaffMapper extends BaseMapper<SysEnterpriseStaffQuery, SysEnterpriseStaffDto, SysEnterpriseStaffPo> { | |||
| @TenantIgnore(tenantLine = true) | |||
| TeTenantPo selectTenantByPhone(@Param("phone") String phone); | |||
| @TenantIgnore(tenantLine = true) | |||
| SysEnterpriseStaff selectStaffByPhone(@Param("phone") String phone); | |||
| SysEnterpriseStaffPo selectStaffByPhone(@Param("phone") String phone); | |||
| @TenantIgnore(tenantLine = true) | |||
| void updateEntity(SysEnterpriseStaff po); | |||
| void updateEntity(SysEnterpriseStaffPo po); | |||
| } | |||
| @@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
| select * from te_tenant where id = (select t_id from sys_enterprise_staff where (phone = #{phone} or openid = #{phone}) and del_flag = 0 limit 1) | |||
| </select> | |||
| <select id="selectStaffByPhone" resultType="com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaff" parameterType="Object"> | |||
| <select id="selectStaffByPhone" resultType="com.xueyi.tenant.api.tenant.domain.po.SysEnterpriseStaffPo" parameterType="Object"> | |||
| select * from sys_enterprise_staff where (phone = #{phone} or openid = #{phone}) and del_flag = 0 limit 1 | |||
| </select> | |||