创建仓库
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.yolo.backstageconfig.Account;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yolo.backstageconfig.Data.ResponseData;
|
||||
import com.yolo.backstageconfig.Data.ResponseInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("account")
|
||||
public class AccountController {
|
||||
|
||||
@Autowired
|
||||
private AccountDao accountDao;
|
||||
|
||||
@PostMapping("login")
|
||||
public ResponseData<Object> login(@RequestBody AccountModel accountModel) {
|
||||
QueryWrapper<AccountModel> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("account", accountModel.getAccount());
|
||||
wrapper.eq("pwd", accountModel.getPwd());
|
||||
Long count = accountDao.selectCount(wrapper);
|
||||
return count != 0 ? ResponseData.success("1") : ResponseData.error(ResponseInfo.ERROR, "用户名或密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yolo.backstageconfig.Account;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@DS("PK")
|
||||
@Mapper
|
||||
public interface AccountDao extends BaseMapper<AccountModel> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yolo.backstageconfig.Account;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("account")
|
||||
public class AccountModel {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private String account;
|
||||
private String pwd;
|
||||
}
|
||||
89
src/main/java/com/yolo/backstageconfig/Ai/AiController.java
Normal file
89
src/main/java/com/yolo/backstageconfig/Ai/AiController.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.yolo.backstageconfig.Ai;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yolo.backstageconfig.Ai.Language.AiLanguage;
|
||||
import com.yolo.backstageconfig.Ai.Language.AiLanguageMapper;
|
||||
import com.yolo.backstageconfig.Ai.Template.Template;
|
||||
import com.yolo.backstageconfig.Ai.Template.TemplateMapper;
|
||||
import com.yolo.backstageconfig.Data.ResponseData;
|
||||
import com.yolo.backstageconfig.Data.ResponseInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("ai")
|
||||
public class AiController {
|
||||
|
||||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
|
||||
@Autowired
|
||||
private AiLanguageMapper languageMapper;
|
||||
|
||||
// 获取话术列
|
||||
@PostMapping("templateList")
|
||||
public ResponseData<Object> templateList() {
|
||||
List<Template> templates = templateMapper.selectList(null);
|
||||
return ResponseData.success(templates);
|
||||
}
|
||||
|
||||
// 添加话术
|
||||
@PostMapping("addTemplate")
|
||||
public ResponseData<Object> addTemplate(@RequestBody Template template) {
|
||||
String content = template.getContent();
|
||||
int count = templateMapper.numberOfCurrentTemplate(content);
|
||||
if (count > 0) {
|
||||
return ResponseData.error(ResponseInfo.ERROR,"已存在相同话术");
|
||||
}
|
||||
return ResponseData.success(templateMapper.insert(template));
|
||||
}
|
||||
|
||||
// 编辑话术
|
||||
@PostMapping("editTemplate")
|
||||
public ResponseData<Object> editTemplate(@RequestBody Template template) {
|
||||
return ResponseData.success(templateMapper.updateById(template));
|
||||
}
|
||||
|
||||
// 删除话术
|
||||
@PostMapping("deleteTemplate")
|
||||
public ResponseData<Object> deleteTemplate(@RequestBody Template template) {
|
||||
return ResponseData.success(templateMapper.deleteById(template));
|
||||
}
|
||||
|
||||
/* 国 家 相 关 */
|
||||
@PostMapping("languageList")
|
||||
public ResponseData<Object> languageList() {
|
||||
QueryWrapper<AiLanguage> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("id");
|
||||
return ResponseData.success(languageMapper.selectList(queryWrapper));
|
||||
}
|
||||
|
||||
// 添加国家
|
||||
@PostMapping("addLanguage")
|
||||
public ResponseData<Object> addLanguage(@RequestBody AiLanguage language) {
|
||||
String name = language.getLanguage();
|
||||
int i = languageMapper.countForCountryName(name);
|
||||
if (i > 0) {
|
||||
return ResponseData.error(ResponseInfo.ERROR,"该名称已存在");
|
||||
}
|
||||
return ResponseData.success(languageMapper.insert(language));
|
||||
}
|
||||
|
||||
// 删除国家
|
||||
@PostMapping("updateLanguage")
|
||||
public ResponseData<Object> updateLanguage(@RequestBody AiLanguage language) {
|
||||
return ResponseData.success(languageMapper.updateById(language));
|
||||
}
|
||||
|
||||
// 删除国家
|
||||
@PostMapping("deleteLanguage")
|
||||
public ResponseData<Object> deleteLanguage(@RequestBody AiLanguage language) {
|
||||
return ResponseData.success(languageMapper.deleteById(language));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yolo.backstageconfig.Ai.Language;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AiLanguage {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private String language;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yolo.backstageconfig.Ai.Language;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@DS("AI")
|
||||
@Mapper
|
||||
public interface AiLanguageMapper extends BaseMapper<AiLanguage> {
|
||||
|
||||
// 根据国家名称查询数量
|
||||
@Select("select count(*) from ai_language where language = #{name}")
|
||||
int countForCountryName(@Param("name") String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yolo.backstageconfig.Ai.Template;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
// 话术类
|
||||
@Data
|
||||
@TableName("ai_template")
|
||||
public class Template {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private String language;
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yolo.backstageconfig.Ai.Template;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@DS("AI")
|
||||
@Mapper
|
||||
public interface TemplateMapper extends BaseMapper<Template> {
|
||||
|
||||
// 查询是否已存在相同的话术
|
||||
@Select("select count(*) from ai_template where content = #{content}")
|
||||
int numberOfCurrentTemplate(@Param("content") String content);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yolo.backstageconfig;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BackStageConfigApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BackStageConfigApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yolo.backstageconfig.Data;
|
||||
import lombok.Data;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@Data
|
||||
public class ResponseData<T> {
|
||||
|
||||
// 状态码
|
||||
T data = null;
|
||||
public String msg;
|
||||
public Integer code;
|
||||
|
||||
ResponseData() {}
|
||||
|
||||
// 成功的返回方法
|
||||
public static <T> ResponseData<T> success(@Nullable T param) {
|
||||
ResponseInfo info = ResponseInfo.SUCCESS;
|
||||
ResponseData<T> data = new ResponseData<>();
|
||||
data.setData(param);
|
||||
data.setCode(info.getCode());
|
||||
data.setMsg(info.getDesc());
|
||||
return data;
|
||||
}
|
||||
|
||||
// 返回错误的方法
|
||||
public static ResponseData<Object> error(ResponseInfo info, @Nullable String msg) {
|
||||
ResponseData<Object> data = new ResponseData<>();
|
||||
data.msg = msg != null ? msg : info.getDesc();
|
||||
data.code = info.getCode();
|
||||
data.data = null;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yolo.backstageconfig.Data;
|
||||
|
||||
public enum ResponseInfo {
|
||||
// 成功
|
||||
SUCCESS(200, "操作成功"),
|
||||
ERROR(1001, "操作失败");
|
||||
|
||||
private final int code; // 状态码
|
||||
private final String desc; // 描述
|
||||
|
||||
// 构造方法(默认是private)
|
||||
ResponseInfo(int code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
// Getter方法
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yolo.backstageconfig.PK.PkConfig;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("function_configuration")
|
||||
public class PkConfig {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private String functionName;
|
||||
private String functionValue;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yolo.backstageconfig.PK.PkConfig;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@DS("PK")
|
||||
@Mapper
|
||||
public interface PkConfigMapper extends BaseMapper<PkConfig> {
|
||||
|
||||
// 查询是否有存在的配置名称
|
||||
@Select("select count(*) from function_configuration where function_name = #{name}")
|
||||
int numberOfFunctionName(@Param("name") String name);
|
||||
|
||||
}
|
||||
49
src/main/java/com/yolo/backstageconfig/PK/PkController.java
Normal file
49
src/main/java/com/yolo/backstageconfig/PK/PkController.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.yolo.backstageconfig.PK;
|
||||
|
||||
import com.yolo.backstageconfig.Data.ResponseData;
|
||||
import com.yolo.backstageconfig.Data.ResponseInfo;
|
||||
import com.yolo.backstageconfig.PK.PkConfig.PkConfig;
|
||||
import com.yolo.backstageconfig.PK.PkConfig.PkConfigMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("pk")
|
||||
public class PkController {
|
||||
|
||||
@Autowired
|
||||
private PkConfigMapper configMapper;
|
||||
|
||||
// 获取配置列表
|
||||
@PostMapping("configList")
|
||||
public ResponseData<Object> configList() {
|
||||
return ResponseData.success(configMapper.selectList(null));
|
||||
}
|
||||
|
||||
// 添加新配置
|
||||
@PostMapping("addNewConfig")
|
||||
public ResponseData<Object> addNewConfig(@RequestBody PkConfig config) {
|
||||
String functionName = config.getFunctionName();
|
||||
int i = configMapper.numberOfFunctionName(functionName);
|
||||
if (i > 0) {
|
||||
return ResponseData.error(ResponseInfo.ERROR,"已存在的配置项");
|
||||
}
|
||||
return ResponseData.success(configMapper.insert(config));
|
||||
}
|
||||
|
||||
// 更新配置
|
||||
@PostMapping("updateConfig")
|
||||
public ResponseData<Object> updateConfig(@RequestBody PkConfig config) {
|
||||
return ResponseData.success(configMapper.updateById(config));
|
||||
}
|
||||
|
||||
// 删除配置
|
||||
@PostMapping("deleteConfig")
|
||||
public ResponseData<Object> deleteConfig(@RequestBody PkConfig config) {
|
||||
return ResponseData.success(configMapper.deleteById(config));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yolo.backstageconfig.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**") // 允许跨域的路径
|
||||
.allowedOrigins("*") // 允许跨域的域名,可以用具体域名代替 "*"
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的请求方法
|
||||
.allowedHeaders("*") // 允许的请求头
|
||||
.allowCredentials(false) // 是否允许携带 Cookie
|
||||
.maxAge(3600); // 预检请求的缓存时间(秒)
|
||||
}
|
||||
}
|
||||
19
src/main/resources/application-dev.yml
Normal file
19
src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
dynamic:
|
||||
datasource:
|
||||
# pk小程序
|
||||
PK:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: wfn53400
|
||||
url: jdbc:mysql://120.26.251.180:3326/vv_assistant?allowMultiQueries=true
|
||||
|
||||
# AI项目配置
|
||||
AI:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: wfn53400
|
||||
url: jdbc:mysql://120.26.251.180:3326/tkdata?allowMultiQueries=true
|
||||
primary: AI
|
||||
19
src/main/resources/application-prd.yml
Normal file
19
src/main/resources/application-prd.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
dynamic:
|
||||
datasource:
|
||||
# pk项目生产环境
|
||||
PK:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: niu995228
|
||||
url: jdbc:mysql://49.235.115.212:3336/vv_assistant?allowMultiQueries=true
|
||||
|
||||
# AI项目生产环境
|
||||
AI:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: wfn53400
|
||||
url: jdbc:mysql://47.79.98.113:3326/ruoyi-vue-pro?allowMultiQueries=true
|
||||
primary: AI
|
||||
7
src/main/resources/application.yml
Normal file
7
src/main/resources/application.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
server:
|
||||
port: 12025
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
active: prd
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yolo.backstageconfig;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class BackStageConfigApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user