Reviewed-on: http://39.105.23.186:3000/develop/digimeta-MultiSaas/pulls/175tags/B.2.6.9_20240116_release
@@ -0,0 +1,15 @@ | |||
package com.xueyi.nlt.api.nlt.feign; | |||
import com.xueyi.common.core.constant.basic.ServiceConstants; | |||
import com.xueyi.common.core.web.result.AjaxResult; | |||
import com.xueyi.nlt.api.nlt.feign.factory.RemoteSensitiveFallbackFactory; | |||
import org.springframework.cloud.openfeign.FeignClient; | |||
@FeignClient(contextId = "remoteSensitiveService", value = ServiceConstants.NLT_SERVICE, fallbackFactory = RemoteSensitiveFallbackFactory.class) | |||
public interface RemoteSensitiveService { | |||
AjaxResult checkSensitive(String content); | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.xueyi.nlt.api.nlt.feign.factory; | |||
import com.xueyi.nlt.api.nlt.feign.RemoteSensitiveService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.cloud.openfeign.FallbackFactory; | |||
import org.springframework.stereotype.Component; | |||
@Slf4j | |||
@Component | |||
public class RemoteSensitiveFallbackFactory implements FallbackFactory<RemoteSensitiveService> { | |||
@Override | |||
public RemoteSensitiveService create(Throwable cause) { | |||
return null; | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteIntentFallbackFactory | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteQAFallbackFactory | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteLandingLlmFallbackFactory | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteSeniverseFallbackFactory | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteSeniverseFallbackFactory | |||
com.xueyi.nlt.api.nlt.feign.factory.RemoteSensitiveFallbackFactory |
@@ -9,6 +9,8 @@ import com.xueyi.common.core.utils.core.ObjectUtil; | |||
import com.xueyi.common.core.utils.core.StrUtil; | |||
import com.xueyi.common.security.auth.AuthUtil; | |||
import com.xueyi.common.security.utils.SecurityUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.web.method.HandlerMethod; | |||
import org.springframework.web.servlet.AsyncHandlerInterceptor; | |||
@@ -22,6 +24,7 @@ import javax.servlet.http.HttpServletResponse; | |||
* @author xueyi | |||
*/ | |||
public class HeaderInterceptor implements AsyncHandlerInterceptor { | |||
private Logger logger = LoggerFactory.getLogger(HeaderInterceptor.class); | |||
@Override | |||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
@@ -42,12 +45,14 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor { | |||
String token = SecurityUtils.getToken(); | |||
System.err.println(SecurityUtils.getAccountType()); | |||
if (StrUtil.isNotEmpty(token)) { | |||
SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); | |||
SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); | |||
SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); | |||
SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); | |||
logger.info("IsLessor:{}",JwtUtil.getIsLessor(token)); | |||
if (!(("Y").equals(JwtUtil.getIsLessor(token))|| JwtUtil.getIsLessor(token).equals("1"))) {//如果是超管租户,则不执行以下 | |||
SecurityContextHolder.setEnterpriseId(JwtUtil.getEnterpriseId(token)); | |||
SecurityContextHolder.setSourceName(JwtUtil.getSourceName(token)); | |||
SecurityContextHolder.setAccountType(JwtUtil.getAccountType(token)); | |||
SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER); | |||
} | |||
TenantConstants.AccountType accountType = TenantConstants.AccountType.getByCode(SecurityUtils.getAccountType()); | |||
if(ObjectUtil.isNotNull(accountType)) { | |||
@@ -0,0 +1,40 @@ | |||
package com.xueyi.nlt.nlt.config; | |||
import lombok.Data; | |||
import org.springframework.boot.context.properties.ConfigurationProperties; | |||
import org.springframework.context.annotation.Configuration; | |||
@Data | |||
@Configuration | |||
@ConfigurationProperties(prefix = "secret.spark") | |||
public class XunFeiSensitiveConfig { | |||
private String appId; | |||
private String apiKey; | |||
private String apiSecret; | |||
private String sensitiveUrl; | |||
private String sensitiveCheckUrl; | |||
public static final String BLACK_LIB_NAME = "digimeta-black-lib"; | |||
public static final String WHITE_LIB_NAME = "digimeta-white-lib"; | |||
public static final String BLACK_LIB_ID = "2ee58a3c2d68411194d620bf846056af"; | |||
public static final String WHITE_LIB_ID = "3d6f1dbc6cad4843a7d8fa502d16eb29"; | |||
// 敏感词库 | |||
/** | |||
* pornDetection 色情 | |||
* violentTerrorism 暴恐 | |||
* political 涉政 | |||
* lowQualityIrrigation 低质量灌水 | |||
* contraband 违禁 | |||
* advertisement 广告 | |||
* uncivilizedLanguage 不文明用语 | |||
**/ | |||
public static final String SENSITIVE_TYPES_PORN_DETECTION = "pornDetection"; | |||
public static final String SENSITIVE_TYPES_VIOLENT_TERRORISM = "violentTerrorism"; | |||
public static final String SENSITIVE_TYPES_POLITICAL = "political"; | |||
public static final String SENSITIVE_TYPES_LOW_QUALITY_IRRIGATION = "lowQualityIrrigation"; | |||
public static final String SENSITIVE_TYPES_CONTRABAND = "contraband"; | |||
public static final String SENSITIVE_TYPES_ADVERTISEMENT = "advertisement"; | |||
public static final String SENSITIVE_TYPES_UNCIVILIZED_LANGUAGE = "uncivilizedLanguage"; | |||
} |
@@ -1,6 +1,8 @@ | |||
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; | |||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
@@ -33,6 +35,7 @@ import com.xueyi.nlt.api.nlt.feign.RemoteIntentService; | |||
import com.xueyi.nlt.api.nlt.feign.RemoteLandingLlmService; | |||
import com.xueyi.nlt.api.nlt.feign.RemoteQAService; | |||
import com.xueyi.nlt.netty.client.WebSocketClientManager; | |||
import com.xueyi.nlt.nlt.config.XunFeiSensitiveConfig; | |||
import com.xueyi.nlt.nlt.context.TerminalSecurityContextHolder; | |||
import com.xueyi.nlt.nlt.domain.LlmContext; | |||
import com.xueyi.nlt.nlt.domain.LlmParam; | |||
@@ -44,7 +47,9 @@ import com.xueyi.nlt.nlt.domain.vo.IntentTemplateVo; | |||
import com.xueyi.nlt.nlt.domain.vo.MarkRecordVo; | |||
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.template.*; | |||
import com.xueyi.system.api.digitalmans.domain.dto.DmManDeviceDto; | |||
import com.xueyi.system.api.digitalmans.domain.dto.DmSkillDto; | |||
@@ -69,6 +74,7 @@ import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.PutMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import org.springframework.web.bind.annotation.ResponseBody; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.io.Serializable; | |||
@@ -890,6 +896,53 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||
return response; | |||
} | |||
@Autowired | |||
private XunFeiSensitiveConfig xunFeiSensitiveConfig; | |||
@Autowired | |||
private ISensitiveService sensitiveService; | |||
@GetMapping("/api/create-sensitive-lib") | |||
public AjaxResult addSensitiveBlack(@RequestParam("name") String name, @RequestParam(value = "category" ,required = false) String category, @RequestParam("type") String type){ | |||
try { | |||
String res = ""; | |||
if ("black".equals(type)) { | |||
res = sensitiveService.createBlack(name, category); | |||
} else { | |||
res = sensitiveService.createWhite(name); | |||
} | |||
return AjaxResult.success(res); | |||
} catch (Exception e) { | |||
return AjaxResult.error(e.getMessage()); | |||
} | |||
} | |||
@GetMapping("/api/add-sensitive-word") | |||
public AjaxResult addSensitiveWord(@RequestParam("content") String content, @RequestParam("type") String type){ | |||
try { | |||
String res = ""; | |||
if ("black".equals(type)) { | |||
res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.BLACK_LIB_ID, new String[]{content}); | |||
} else { | |||
res = sensitiveService.addKeyWord(xunFeiSensitiveConfig.WHITE_LIB_ID, new String[]{content}); | |||
} | |||
return AjaxResult.success(JSON.parse(res)); | |||
} catch (Exception e) { | |||
return AjaxResult.error(e.getMessage()); | |||
} | |||
} | |||
@GetMapping("/api/check-sensitive-word") | |||
public AjaxResult addSensitiveWhite(@RequestParam("content") String content, @RequestParam(value = "useLib", required = false) Integer useLib){ | |||
String res = sensitiveService.checkSensitiveWord(content, useLib); | |||
logger.info("check-sensitive-word ,content:{}, res:{}",content, res); | |||
if (res.contains("suggest")){ | |||
return AjaxResult.success(JSONObject.parse(res).getObject("data", JSONObject.class)); | |||
} | |||
return AjaxResult.error(res); | |||
} | |||
interface Auth { | |||
/** 系统 - 意图管理 | |||
@@ -0,0 +1,18 @@ | |||
package com.xueyi.nlt.nlt.service; | |||
/** | |||
* @author yk | |||
* @description | |||
* @date 2024-01-15 17:38 | |||
*/ | |||
public interface ISensitiveService { | |||
public String createWhite(String name) throws Exception ; | |||
public String createBlack(String name, String category) throws Exception ; | |||
public String checkSensitiveWord(String content, Integer useLib) ; | |||
public String addKeyWord(String libId, String[] contents) throws Exception ; | |||
} |
@@ -0,0 +1,290 @@ | |||
package com.xueyi.nlt.nlt.service.impl; | |||
import com.alibaba.fastjson.JSONArray; | |||
import com.alibaba.fastjson2.JSONObject; | |||
import com.xueyi.nlt.nlt.config.XunFeiSensitiveConfig; | |||
import com.xueyi.nlt.nlt.service.ISensitiveService; | |||
import org.apache.http.client.methods.CloseableHttpResponse; | |||
import org.apache.http.client.methods.HttpUriRequest; | |||
import org.apache.http.client.methods.RequestBuilder; | |||
import org.apache.http.entity.ContentType; | |||
import org.apache.http.entity.StringEntity; | |||
import org.apache.http.impl.client.CloseableHttpClient; | |||
import org.apache.http.impl.client.HttpClients; | |||
import org.apache.http.util.EntityUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.context.annotation.Primary; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.PostConstruct; | |||
import javax.crypto.Mac; | |||
import javax.crypto.spec.SecretKeySpec; | |||
import java.io.IOException; | |||
import java.net.URI; | |||
import java.net.URLEncoder; | |||
import java.nio.charset.StandardCharsets; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Base64; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.TimeZone; | |||
import java.util.TreeMap; | |||
import java.util.UUID; | |||
/** | |||
* @author yk | |||
* @description | |||
* @date 2024-01-15 15:53 | |||
*/ | |||
@Service | |||
@Primary | |||
public class XunFeiSensitiveSeviceImpl implements ISensitiveService { | |||
Logger logger = LoggerFactory.getLogger(XunFeiSensitiveSeviceImpl.class); | |||
private String appid; | |||
private String APIKey; | |||
private String APISecret; | |||
@Autowired | |||
private XunFeiSensitiveConfig sensitiveConfig; | |||
@PostConstruct | |||
public void init() { | |||
this.appid = sensitiveConfig.getAppId(); | |||
this.APIKey = sensitiveConfig.getApiKey(); | |||
this.APISecret = sensitiveConfig.getApiSecret(); | |||
} | |||
/** | |||
* 1.拼接鉴权 | |||
*/ | |||
public Map<String, String> getAuth() throws Exception { | |||
// 1.获取时间 | |||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US); | |||
format.setTimeZone(TimeZone.getTimeZone("GMT")); | |||
String utc = format.format(new Date()); // 如果用postman验证,需要对utc进行urlEncode,然后发起请求 | |||
// 2.控制台关键信息 | |||
Map<String, String> urlParams = new HashMap<>(); | |||
urlParams.put("appId", appid); | |||
urlParams.put("accessKeyId", APIKey); | |||
urlParams.put("utc", utc); | |||
urlParams.put("uuid", UUID.randomUUID().toString()); // uuid有防重放的功能,如果调试,请注意更换uuid的值 | |||
// 3.获取signature | |||
String signature = this.signature(APISecret, urlParams); | |||
urlParams.put("signature", signature); | |||
return urlParams; | |||
} | |||
/** | |||
* 2.获取鉴权 | |||
*/ | |||
public String signature(String secret, Map<String, String> queryParam) throws Exception { | |||
//排序 | |||
TreeMap<String, String> treeMap = new TreeMap<>(queryParam); | |||
//剔除不参与签名运算的 signature | |||
treeMap.remove("signature"); | |||
//生成 baseString | |||
StringBuilder builder = new StringBuilder(); | |||
for (Map.Entry<String, String> entry : treeMap.entrySet()) { | |||
String value = entry.getValue(); | |||
//参数值为空的不参与签名, | |||
if (value != null && !value.isEmpty()) { | |||
//参数值需要 URLEncode | |||
String encode = URLEncoder.encode(value, StandardCharsets.UTF_8.name()); | |||
builder.append(entry.getKey()).append("=").append(encode).append("&"); | |||
} | |||
} | |||
//删除最后位的&符号 | |||
if (builder.length() > 0) { | |||
builder.deleteCharAt(builder.length() - 1); | |||
} | |||
String baseString = builder.toString(); | |||
Mac mac = Mac.getInstance("HmacSHA1"); | |||
SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8.name()); | |||
mac.init(keySpec); | |||
//得到签名 byte[] | |||
byte[] signBytes = mac.doFinal(baseString.getBytes(StandardCharsets.UTF_8)); | |||
//将 byte[]base64 编码 | |||
return Base64.getEncoder().encodeToString(signBytes); | |||
} | |||
/** | |||
* 3.发起post请求 | |||
*/ | |||
public String doPostJson(String url, Map<String, String> urlParams, String json) { | |||
String resultString = ""; | |||
try(CloseableHttpClient closeableHttpClient = HttpClients.createDefault()) { | |||
CloseableHttpResponse closeableHttpResponse = null; | |||
// 创建Http Post请求 | |||
String asciiUrl = URI.create(url).toASCIIString(); | |||
RequestBuilder builder = RequestBuilder.post(asciiUrl); | |||
builder.setCharset(StandardCharsets.UTF_8); | |||
if (urlParams != null) { | |||
for (Map.Entry<String, String> entry : urlParams.entrySet()) { | |||
builder.addParameter(entry.getKey(), entry.getValue()); | |||
} | |||
} | |||
// 创建请求内容 | |||
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); | |||
builder.setEntity(entity); | |||
HttpUriRequest request = builder.build(); | |||
// 执行http请求 | |||
closeableHttpResponse = closeableHttpClient.execute(request); | |||
resultString = EntityUtils.toString(closeableHttpResponse.getEntity(), StandardCharsets.UTF_8); | |||
} catch (IOException e) { | |||
throw new RuntimeException(e); | |||
} | |||
return resultString; | |||
} | |||
/** | |||
* 4.黑白名单具体操作方法 | |||
*/ | |||
public String deleteKeyWord(String libId, String[] wordList) throws Exception { | |||
JSONObject jsonBody = new JSONObject(); | |||
jsonBody.put("lib_id", libId); | |||
jsonBody.put("word_list", wordList); | |||
String json = JSONArray.toJSON(jsonBody).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/delWord", urlParams, json); | |||
logger.info("删除关键词返回的结果:{}", returnResult); | |||
return returnResult; | |||
} | |||
@Override | |||
public String addKeyWord(String libId, String[] wordList) throws Exception { | |||
JSONObject jsonBody = new JSONObject(); | |||
jsonBody.put("lib_id", libId); | |||
jsonBody.put("word_list", wordList); | |||
String json = JSONArray.toJSON(jsonBody).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/addWord", urlParams, json); | |||
logger.info("添加关键词返回的结果:{}" ,returnResult); | |||
return returnResult; | |||
} | |||
public void deleteLibrary(String libId) throws Exception { | |||
Map<String, String> bodyMap = new HashMap<>(); | |||
bodyMap.put("lib_id", libId); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/delete", urlParams, json); | |||
logger.info("删除词库返回的结果:{}" , returnResult); | |||
} | |||
public String selectLibrary(String libId) throws Exception { | |||
Map<String, String> bodyMap = new HashMap<>(); | |||
bodyMap.put("lib_id", libId); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/info", urlParams, json); | |||
logger.info("查询词库返回的结果:{}" , returnResult); | |||
return returnResult; | |||
} | |||
public String selectLibraryDetail(String libId) throws Exception { | |||
Map<String, Object> bodyMap = new HashMap<>(); | |||
bodyMap.put("lib_id", libId); | |||
bodyMap.put("return_word", true); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/info", urlParams, json); | |||
logger.info("查询词库关键词返回的结果:{}" , returnResult); | |||
return returnResult; | |||
} | |||
@Override | |||
public String createWhite(String name) throws Exception { | |||
Map<String, String> bodyMap = new HashMap<>(); | |||
bodyMap.put("name", name); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/createWhite", urlParams, json); | |||
logger.info("创建白名单返回的结果:{}" , returnResult); | |||
return returnResult; | |||
} | |||
@Override | |||
public String createBlack(String name, String category) throws Exception { | |||
Map<String, String> bodyMap = new HashMap<>(); | |||
bodyMap.put("name", name); | |||
bodyMap.put("suggestion", "block"); | |||
bodyMap.put("category", category); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/createBlack", urlParams, json); | |||
logger.info("创建黑名单返回的结果:{}" , returnResult); | |||
return returnResult; | |||
} | |||
@Override | |||
public String checkSensitiveWord(String content, Integer useLib) { | |||
String json = "{\n" + | |||
" \"is_match_all\": 1,\n" + | |||
" \"content\": \"" + content + "\"\n" + | |||
"}"; | |||
if (1 == useLib) {//用自定义库 | |||
json = "{\n" + | |||
" \"is_match_all\": 1,\n" + | |||
" \"content\": \"" + content + "\",\n" + | |||
" \"lib_ids\": [\n" + | |||
" \"" + XunFeiSensitiveConfig.BLACK_LIB_ID + "\",\n" + | |||
" \"" + XunFeiSensitiveConfig.WHITE_LIB_ID + "\"\n" + | |||
" ],\n" + | |||
" \"categories\": [\n" + | |||
" \"pornDetection\",\n" + | |||
" \"violentTerrorism\",\n" + | |||
" \"political\",\n" + | |||
" \"lowQualityIrrigation\",\n" + | |||
" \"contraband\",\n" + | |||
" \"advertisement\",\n" + | |||
" \"uncivilizedLanguage\"\n" + | |||
" ]\n" + | |||
"}"; | |||
} | |||
// 获取鉴权 | |||
Map<String, String> urlParams = null; | |||
try { | |||
urlParams = this.getAuth(); | |||
return this.doPostJson(sensitiveConfig.getSensitiveCheckUrl(), urlParams, json); | |||
} catch (Exception e) { | |||
return e.getMessage(); | |||
} | |||
} | |||
public void selectLibraryList() throws Exception { | |||
Map<String, String> bodyMap = new HashMap<>(); | |||
String json = JSONArray.toJSON(bodyMap).toString(); | |||
// 鉴权 | |||
Map<String, String> urlParams = this.getAuth(); | |||
// 发起请求 | |||
String returnResult = doPostJson(sensitiveConfig.getSensitiveUrl() + "v1/wordLib/list", urlParams, json); | |||
logger.info("查询词库列表返回的结果:{}" , returnResult); | |||
} | |||
} |
@@ -27,6 +27,7 @@ import com.xueyi.system.digitalmans.service.IDmDigitalmanExtService; | |||
import com.xueyi.system.digitalmans.service.impl.DmDigitalmanServiceImpl; | |||
import com.xueyi.system.meeting.domain.query.DmMeetingRoomsQuery; | |||
import com.xueyi.system.meeting.service.IDmMeetingRoomsService; | |||
import com.xueyi.system.organize.domain.po.SysDeptExtPo; | |||
import com.xueyi.system.organize.mapper.SysDeptExtMapper; | |||
import com.xueyi.system.organize.service.ISysDeptService; | |||
import com.xueyi.system.organize.service.ISysOrganizeService; | |||
@@ -70,6 +71,9 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
@Autowired | |||
private IDmMeetingRoomsService meetingRoomsService; | |||
@Autowired | |||
private SysDeptExtMapper deptExtMapper; | |||
/** 定义节点名称 */ | |||
@Override | |||
protected String getNodeName() { | |||
@@ -82,6 +86,12 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
@InnerAuth | |||
@PostMapping("/inner/add") | |||
public R<SysDeptDto> addInner(@RequestBody SysDeptDto dept) { | |||
Long deptId = IdUtil.getSnowflakeNextId(); | |||
dept.setId(deptId); | |||
SysDeptExtPo deptExt = new SysDeptExtPo(); | |||
deptExt.setDeptId(deptId); | |||
deptExt.initData(); | |||
deptExtMapper.insert(deptExt);//保存部门扩展表 | |||
return baseService.addInner(dept) > 0 ? R.ok(dept) : R.fail(); | |||
} | |||
@@ -149,9 +159,6 @@ public class SysDeptController extends TreeController<SysDeptQuery, SysDeptDto, | |||
} | |||
@Autowired | |||
protected SysDeptExtMapper deptExtMapper; | |||
/** | |||
* 部门新增 | |||
*/ | |||
@@ -15,4 +15,5 @@ public class SysDeptExtDto extends SysDeptExtPo { | |||
private static final long serialVersionUID = 1L; | |||
protected String nickName; | |||
} |
@@ -43,4 +43,13 @@ public class SysDeptExtPo extends TBaseEntity { | |||
protected String province; | |||
protected String city; | |||
//初始化上下班打卡时间 | |||
public SysDeptExtPo initData() { | |||
this.onDutyHourStart = "07:00:00"; | |||
this.onDutyHourEnd = "09:00:00"; | |||
this.offDutyHourStart = "17:00:00"; | |||
this.offDutyHourEnd = "19:00:00"; | |||
return this; | |||
} | |||
} |