diff --git a/src/main/java/com/pixelai/api/component/controller/CpLabelController.java b/src/main/java/com/pixelai/api/component/controller/CpLabelController.java index 49ea6ca..990f69e 100644 --- a/src/main/java/com/pixelai/api/component/controller/CpLabelController.java +++ b/src/main/java/com/pixelai/api/component/controller/CpLabelController.java @@ -134,6 +134,9 @@ public class CpLabelController extends BaseController { String errorMsg = map.entrySet().iterator().next().getValue(); return new Result(false, "保存标签失败", errorMsg, map); } else { + if (entity.getParentid()==null){ + entity.setParentid(0); + } entity.setCreatetime(new Date()); entity.setState("t"); entityService.save(entity); @@ -188,13 +191,19 @@ public class CpLabelController extends BaseController { List moudleTrees=new ArrayList<>(); for (CpModule cpModule:cpModules){ MoudleTree moudleTree=new MoudleTree(); - moudleTree.setCpModule(cpModule); + moudleTree.setId(cpModule.getId()); + moudleTree.setModuleName(cpModule.getModuleName()); + moudleTree.setState(cpModule.getState()); + moudleTree.setModuleLevel(cpModule.getModuleLevel()); + moudleTree.setModuleRemark(cpModule.getModuleRemark()); + List cpLabelTree =new ArrayList<>(); for (CpLabelTree cpLabeltree:collect){ if (cpLabeltree.getModuleid()==cpModule.getId()){ cpLabelTree.add(cpLabeltree); } } + moudleTree.setCpLabelTree(cpLabelTree); moudleTrees.add(moudleTree); } diff --git a/src/main/java/com/pixelai/api/component/vo/MoudleTree.java b/src/main/java/com/pixelai/api/component/vo/MoudleTree.java index dfc6eee..121cff3 100644 --- a/src/main/java/com/pixelai/api/component/vo/MoudleTree.java +++ b/src/main/java/com/pixelai/api/component/vo/MoudleTree.java @@ -12,7 +12,6 @@ import java.util.List; */ @Data @ApiModel -public class MoudleTree { - CpModule cpModule; +public class MoudleTree extends CpModule { List cpLabelTree; } diff --git a/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java b/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java index 09aefcc..da2085a 100644 --- a/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java +++ b/src/main/java/com/pixelai/api/pa/controller/PaCollectionController.java @@ -104,7 +104,9 @@ public class PaCollectionController extends BaseController { } Integer count=entityService.lambdaQuery() .eq(PaCollection::getUserId,userid) - .eq(PaCollection::getCreationId,entity.getCreationId()).count(); + .eq(PaCollection::getCreationId,entity.getCreationId()) + .eq(PaCollection::getState,"t") + .count(); if(count>0){ return new Result(false, "请勿重复收藏作品"); } diff --git a/src/main/java/com/pixelai/api/pa/controller/PaCreationReleaseController.java b/src/main/java/com/pixelai/api/pa/controller/PaCreationReleaseController.java index cf4c928..e95055d 100644 --- a/src/main/java/com/pixelai/api/pa/controller/PaCreationReleaseController.java +++ b/src/main/java/com/pixelai/api/pa/controller/PaCreationReleaseController.java @@ -126,7 +126,10 @@ public class PaCreationReleaseController extends BaseController { // if(entity.getCreationId()==null){ // return new Result(false, "", "作品id为空"); // } - Integer count=entityService.lambdaQuery().eq(PaCreationRelease::getCreationId, entity.getCreationId()).count(); + Integer count=entityService.lambdaQuery() + .eq(PaCreationRelease::getCreationId, entity.getCreationId()) + .eq(PaCreationRelease::getState,"t") + .count(); if(count>0){ return new Result(false, "", "请勿重复共享作品"); } @@ -175,7 +178,7 @@ public class PaCreationReleaseController extends BaseController { paRecommend.setState("t"); paRecommend.setPhotoSourceId(entity.getPhotoSourceId()); paRecommend.setPhotoTargetId(entity.getPhotoTargetId()); - paRecommend.setServiceName(paServices.getName()); + paRecommend.setServiceId(paServices.getId()); paRecommendService.save(paRecommend); entity.setRecommendId(paRecommend.getId()); entityService.updateById(entity); diff --git a/src/main/java/com/pixelai/api/pa/controller/PaRecommendController.java b/src/main/java/com/pixelai/api/pa/controller/PaRecommendController.java index 948a48d..42a6ae1 100644 --- a/src/main/java/com/pixelai/api/pa/controller/PaRecommendController.java +++ b/src/main/java/com/pixelai/api/pa/controller/PaRecommendController.java @@ -4,10 +4,13 @@ import com.base.annotation.Unsecured; import com.pixelai.api.component.entity.CpPhoto; import com.pixelai.api.component.service.CpPhotoService; import com.pixelai.api.pa.dao.PaCreationMapper; +import com.pixelai.api.pa.entity.PaServices; +import com.pixelai.api.pa.service.PaServicesService; import com.pixelai.api.pa.vo.PaCreationReleaseVo; import com.pixelai.api.pa.vo.PaCreationVo; import com.pixelai.api.pa.vo.PaRecommendVo; import com.pixelai.api.user.service.AcUserService; +import com.pixelai.utils.StringUtil; import org.springframework.web.bind.annotation.RequestMapping; import com.base.annotation.SysLog; import org.springframework.web.bind.annotation.RestController; @@ -53,6 +56,8 @@ public class PaRecommendController extends BaseController { private PaCreationMapper paCreationMapper; @Autowired private AcUserService acUserService; + @Autowired + private PaServicesService paServicesService; @Unsecured @SysLog(action = "findByPage", value = "分页查询推荐作品") @@ -75,6 +80,10 @@ public class PaRecommendController extends BaseController { CpPhoto cpPhoto=cpPhotoService.getById(paRecommendVo.getPhotoTargetId()); paRecommendVo.setPath(cpPhoto.getPath()); } + if(StringUtil.isBlank(paRecommendVo.getServiceName())){ + PaServices paServices=paServicesService.getById(paRecommendVo.getServiceId()); + paRecommendVo.setServiceName(paServices.getName()); + } } return new Result(true, records); } @@ -122,7 +131,6 @@ public class PaRecommendController extends BaseController { } else { entity.setUserId(acUserService.getUserId()); entity.setState("t"); - entity.setNumber(0); entity.setCreatetime(new Date()); entityService.save(entity); return new Result(true, "成功保存推荐作品", null); diff --git a/src/main/java/com/pixelai/api/pa/entity/PaRecommend.java b/src/main/java/com/pixelai/api/pa/entity/PaRecommend.java index b8c9f55..545b148 100644 --- a/src/main/java/com/pixelai/api/pa/entity/PaRecommend.java +++ b/src/main/java/com/pixelai/api/pa/entity/PaRecommend.java @@ -41,7 +41,7 @@ public class PaRecommend implements Serializable { private String state; - String serviceName; + private Integer serviceId; @ApiModelProperty(value = "原图") private Integer photoSourceId; diff --git a/src/main/java/com/pixelai/api/pa/service/MbConsumptionService.java b/src/main/java/com/pixelai/api/pa/service/MbConsumptionService.java index 9686d7f..5be28af 100644 --- a/src/main/java/com/pixelai/api/pa/service/MbConsumptionService.java +++ b/src/main/java/com/pixelai/api/pa/service/MbConsumptionService.java @@ -1,34 +1,34 @@ -//package com.pixelai.api.pa.service; -// -//import com.baomidou.mybatisplus.core.metadata.IPage; -//import com.pixelai.api.pa.entity.MbConsumption; -//import com.baomidou.mybatisplus.extension.service.IService; -// -//import java.util.List; -// -///** -// *

-// * 服务类 -// *

-// * -// * @author gjj -// * @since 2024-12-23 -// */ -//public interface MbConsumptionService extends IService { -// -// /** -// * 条件查询 -// * @param example -// * @return -// */ -// List list(MbConsumption example); -// -// /** -// * 分页查询 -// * @param example -// * @param page -// * @return -// */ -// IPage page(MbConsumption example,IPage page); -// -//} +package com.pixelai.api.pa.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.pixelai.api.pa.entity.MbConsumption; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author gjj + * @since 2024-12-23 + */ +public interface MbConsumptionService extends IService { + + /** + * 条件查询 + * @param example + * @return + */ + List list(MbConsumption example); + + /** + * 分页查询 + * @param example + * @param page + * @return + */ + IPage page(MbConsumption example,IPage page); + +} diff --git a/src/main/java/com/pixelai/api/pa/service/impl/PaRecommendServiceImpl.java b/src/main/java/com/pixelai/api/pa/service/impl/PaRecommendServiceImpl.java index 7ef1ef0..fbc0d03 100644 --- a/src/main/java/com/pixelai/api/pa/service/impl/PaRecommendServiceImpl.java +++ b/src/main/java/com/pixelai/api/pa/service/impl/PaRecommendServiceImpl.java @@ -59,7 +59,7 @@ public class PaRecommendServiceImpl extends ServiceImpl buildPaCreationVoWrapper(PaRecommendVo example) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper - .like(example.getServiceName()!=null,"service_name", example.getServiceName()) + .eq(example.getServiceId()!=null,"service_id", example.getServiceId()) .eq("state", "t"); if(example.getIsBackend()!=null && example.getIsBackend()==1){ wrapper.orderByDesc("createtime"); diff --git a/src/main/java/com/pixelai/api/pa/vo/PaRecommendVo.java b/src/main/java/com/pixelai/api/pa/vo/PaRecommendVo.java index 62d8cd7..795d4a6 100644 --- a/src/main/java/com/pixelai/api/pa/vo/PaRecommendVo.java +++ b/src/main/java/com/pixelai/api/pa/vo/PaRecommendVo.java @@ -7,7 +7,7 @@ import lombok.Data; public class PaRecommendVo extends PaRecommend { String path; String sourcePath; - Integer serviceId; + String serviceName; //1后台查询,2前台查询 Integer isBackend; diff --git a/src/main/java/com/pixelai/api/picture/controller/AiPictureController.java b/src/main/java/com/pixelai/api/picture/controller/AiPictureController.java index 34fb4fa..42170b7 100644 --- a/src/main/java/com/pixelai/api/picture/controller/AiPictureController.java +++ b/src/main/java/com/pixelai/api/picture/controller/AiPictureController.java @@ -113,7 +113,7 @@ public class AiPictureController { case "CharacterAnime" : aiPictureService.CharacterAnime(aiPictureVo,paCreation); break; - //百度:更换图片风格 + //百度:图像风格转换 case "styleTrans" : aiPictureService.styleTrans(aiPictureVo,paCreation); break; diff --git a/src/main/java/com/pixelai/api/picture/service/impl/AiPictureServiceImpl.java b/src/main/java/com/pixelai/api/picture/service/impl/AiPictureServiceImpl.java index a3f1d3b..c6498a9 100644 --- a/src/main/java/com/pixelai/api/picture/service/impl/AiPictureServiceImpl.java +++ b/src/main/java/com/pixelai/api/picture/service/impl/AiPictureServiceImpl.java @@ -192,6 +192,15 @@ public class AiPictureServiceImpl implements AiPictureService { req.put ("model_version", "general_v2.1_L"); req.put ("return_url", true); req.put ("use_pre_llm", true); + if (StringUtil.isNotBlank(aiPictureVo.getSize())){ + String str=aiPictureVo.getSize(); + String[] strlist=str.split("\\*"); + if (strlist.length==2){ + req.put ("width",Integer.parseInt(strlist[0]) ); + req.put ("height", Integer.parseInt(strlist[1])); + } + } + JSONObject response =VolcengineUtil.CVSubmitTask(paCreation,req); if (response==null) return; @@ -601,7 +610,6 @@ public class AiPictureServiceImpl implements AiPictureService { public Map text2Images(AiPictureVo aiPictureVo, PaCreation paCreation) { try { - HttpHeaders headers = new HttpHeaders(); headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);//固定,返回类型,只有json headers.set("Authorization", API_KEY);//固定,api密钥 @@ -609,10 +617,10 @@ public class AiPictureServiceImpl implements AiPictureService { String url="https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis";//文生图url Map input = new HashMap<>();//放到request中 input.put("prompt", aiPictureVo.getText());//////////文本描述 - input.put("size", aiPictureVo.getSize());//////////尺寸 Map parameters = new HashMap<>();//放到request中 parameters.put("style", aiPictureVo.getOption());//////////类型 parameters.put("n", 1);//////////数量 + parameters.put("size", aiPictureVo.getSize());//////////尺寸 Map request = new HashMap<>();//请求体 request.put("model", "wanx-v1");/////////选择模型wanx-v1,一个apikey可以冲所有模型,详情看文档介绍 request.put("input", input);/////////文本描述和尺寸 diff --git a/src/main/resources/mapper/PaRecommendMapper.xml b/src/main/resources/mapper/PaRecommendMapper.xml index 7563a46..c3dc809 100644 --- a/src/main/resources/mapper/PaRecommendMapper.xml +++ b/src/main/resources/mapper/PaRecommendMapper.xml @@ -27,21 +27,23 @@ service_id, path, service_name, + service_id, photo_source_id, photo_target_id from (select - pa_recommend.id as id, - pa_recommend."number" as "number", - pa_recommend.createtime as createtime, - pa_recommend."state" as "state", - pa_creation.service_id as "service_id", - cp_attachment.path as "path", - pa_recommend.service_name as service_name, - pa_recommend.photo_source_id as photo_source_id, - pa_recommend.photo_target_id as photo_target_id - from pa_recommend - left join pa_creation on pa_recommend.creation_id=pa_creation.id - left join cp_attachment on pa_creation.photo_id=cp_attachment.id + pa_recommend.id as id, + pa_recommend."number" as "number", + pa_recommend.createtime as createtime, + pa_recommend."state" as "state", + pa_recommend.service_id as "service_id", + cp_attachment.path as "path", + pa_recommend.photo_source_id as photo_source_id, + pa_recommend.photo_target_id as photo_target_id, + pa_services."name" as service_name + from pa_recommend + left join pa_creation on pa_recommend.creation_id=pa_creation.id + left join cp_attachment on pa_creation.photo_id=cp_attachment.id + left join pa_services on pa_creation.service_id=pa_services.id ) t ${ew.customSqlSegment}