| | |
| | | import opennlp.tools.dictionary.serializer.Entry; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.io.ByteArrayResource; |
| | | import org.springframework.http.*; |
| | |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory; |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @RestController |
| | | @RequestMapping("/copywriting/copywriting") |
| | | @Slf4j |
| | | @EnableAsync |
| | | public class CopywritingController extends JeecgController<Copywriting, ICopywritingService> { |
| | | @Autowired |
| | | private ICopywritingService copywritingService; |
| | | @Autowired |
| | | public ICopywritingService copywritingService; |
| | | @Autowired |
| | | private ISemanticWordService semanticWordService;; |
| | | @Autowired |
| | |
| | | } |
| | | if (StringUtils.isNotBlank(copywriting.getWordLike())){ |
| | | queryWrapper.exists("SELECT 1 FROM semantic_word WHERE semantic_word.id = copywriting.word_id " + |
| | | "AND semantic_word.word LIKE '%" + copywriting.getWordLike() + "%'"); |
| | | "AND semantic_word.word LIKE '%" + copywriting.getWordLike() + "%'"); |
| | | |
| | | } |
| | | if (StringUtils.isNotBlank(copywriting.getContractId())) { |
| | | // 1. 拼接关联 contact 表的 EXISTS 子查询,使用 contact.id 作为外键关联 |
| | | // 2. 使用 MyBatis-Plus 的参数占位符避免 SQL 注入,而不是直接字符串拼接 |
| | | String existsSql = "SELECT 1 FROM semantic_word " + |
| | | "LEFT JOIN contract ON semantic_word.contract_id = contract.id " + // 关联 contact 表(外键关联) |
| | | "WHERE semantic_word.id = copywriting.word_id " + |
| | | "AND contract.id = " + copywriting.getContractId(); // 使用 contact 表的 id 作为条件 |
| | | |
| | | // 给 QueryWrapper 设置参数,避免 SQL 注入 |
| | | queryWrapper.exists(existsSql); |
| | | } |
| | | Page<Copywriting> page = new Page<Copywriting>(pageNo, pageSize); |
| | | IPage<Copywriting> pageList = copywritingService.page(page, queryWrapper); |
| | |
| | | @RequestParam String youshang, |
| | | @RequestParam String wenti, |
| | | @RequestParam String user) { |
| | | if (jianli == null || jianli.equals("")) { |
| | | return Result.error("请选择文件"); |
| | | } |
| | | return getResult(jianli, wenanyaoqiu, louchu, youshang, wenti, user); |
| | | } |
| | | |
| | | public Result<?> getResult(String jianli, String wenanyaoqiu, String louchu, String youshang, String wenti, String user) { |
| | | if (jianli == null || jianli.equals("")) { |
| | | return Result.error("请选择文件"); |
| | | } |
| | | // 配置信息 |
| | | String serverFileRoot = uploadPath; |
| | | String workflowUrl = "http://14.103.174.44/v1/workflows/run"; |
| | |
| | | } |
| | | |
| | | // 添加其他文本参数 |
| | | inputs.put("wenanyaoqiu", wenanyaoqiu); |
| | | inputs.put("benchmarkUrl", wenanyaoqiu); |
| | | inputs.put("louchu", louchu); |
| | | inputs.put("youshang", youshang); |
| | | inputs.put("wenti", wenti); |
| | |
| | | |
| | | } catch (NullPointerException e) { |
| | | e.printStackTrace(); |
| | | return Result.error("不支持的文件格式:"+jianli.split("\\.")[jianli.split("\\.").length-1]); |
| | | return Result.error("不支持的文件格式:" + jianli.split("\\.")[jianli.split("\\.").length - 1]); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error("生成文案异常:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增的生成标题接口方法 |
| | | */ |
| | |
| | | @RequestParam String endTime, |
| | | @RequestParam String user) { // 保留user参数,用于接口鉴权/归属 |
| | | |
| | | return getResult(louchu, yuyici, startTime, endTime, user); |
| | | } |
| | | |
| | | public static Result<?> getResult(String louchu, String yuyici, String startTime, String endTime, String user) { |
| | | // 2. 配置固定参数(和原有方法保持一致,可根据实际情况调整) |
| | | String workflowUrl = "http://14.103.174.44/v1/workflows/run"; // 标题生成的工作流地址,若和文案不同需修改 |
| | | String authToken = "app-F09iyl3p5448JoKufR2CRpWG"; |