diff --git a/suimangCApi/src/main/java/com/iformall/controller/VoiceMouldController.java b/suimangCApi/src/main/java/com/iformall/controller/VoiceMouldController.java new file mode 100644 index 0000000..eb74ee0 --- /dev/null +++ b/suimangCApi/src/main/java/com/iformall/controller/VoiceMouldController.java @@ -0,0 +1,108 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.sm.MouldPatch; +import com.iformall.domain.po.sm.PersonMould; +import com.iformall.domain.po.sm.UserMouldVideo; +import com.iformall.domain.po.sm.VoiceMould; +import com.iformall.enums.EnumLanguages; +import com.iformall.enums.EnumMouldPatchType; +import com.iformall.enums.EnumMouldSendType; +import com.iformall.enums.EnumaMouldPatchStatus; +import com.iformall.language.LanguageDetect; +import com.iformall.service.sm.MouldPatchService; +import com.iformall.service.sm.MouldPatchSignService; +import com.iformall.service.sm.PersonMouldService; +import com.iformall.service.sm.VoiceMouldService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +@RestController +@RequestMapping("/api/voiceMould") +@Api(description = "模板接口") +public class VoiceMouldController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private VoiceMouldService voiceMouldService; + + @Autowired + private PersonMouldService personMouldService; + + @Autowired + private MouldPatchSignService mouldPatchSignService; + + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute VoiceMould record, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] MouldPatchController::list"); + if (record == null) record = new VoiceMould(); + record.setSendType(EnumMouldSendType.auto.getCode()); + record.setStatus(EnumaMouldPatchStatus.put_on.getCode()); + record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); + final PageInfo page = voiceMouldService.cListAsPage(record, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData findById(Long id) { + logger.debug("[" + getIpAddr() + "] MouldPatchController::findById"); + VoiceMould voiceMould = voiceMouldService.getDetailById(id); + + return new ResultData(voiceMould); + } + + @ApiOperation("根据输入文案获取音色") + @PostMapping("voiceList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData voiceList(@RequestBody UserMouldVideo record, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] MouldPatchController::voiceList"); + if (record == null || StringUtils.isBlank(record.getPaperwork())) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + Integer sex = null; + if(record.getPersonMouldId() != null){ + PersonMould personMode = personMouldService.getDetailById(record.getPersonMouldId()); + if(personMode == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"选择模板不存在"); + } + sex = personMode.getSex(); + } + String detect = LanguageDetect.detect(record.getPaperwork()); + if(StringUtils.isBlank(detect)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"语种识别失败"); + } + EnumLanguages anEnum = EnumLanguages.getEnum(detect); + if(anEnum == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"暂不支持该语种"); + } + + VoiceMould voiceMould = new VoiceMould(); + voiceMould.setSex(sex); + voiceMould.setSendType(EnumMouldSendType.auto.getCode()); + voiceMould.setStatus(EnumaMouldPatchStatus.put_on.getCode()); + voiceMould.setLanguages(anEnum.getCode()); + voiceMould.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); + final PageInfo page = voiceMouldService.cListAsPage(voiceMould, pageNum, pageSize); + return new ResultData(page); + } + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/sm/VoiceMould.java b/suimangService/src/main/java/com/iformall/domain/po/sm/VoiceMould.java new file mode 100644 index 0000000..8bd264a --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/sm/VoiceMould.java @@ -0,0 +1,180 @@ +package com.iformall.domain.po.sm; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.common.SortColumn; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumAgeType; +import com.iformall.enums.EnumPersonaType; +import com.iformall.enums.EnumSex; +import com.iformall.enums.EnumSpeakType; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@TableName(value = "voice_patch") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class VoiceMould extends TenantEntity { + + protected Long id; + + @TableField(exist = false) + @SortColumn(column = "sale_price") + private String salePriceStr; + + @TableField(exist = false) + @SortColumn(column = "price") + private String priceStr; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="查询-起始时间",name="startDate") + private Date startDate; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="endDate") + private Date endDate; + + @io.swagger.annotations.ApiModelProperty(value="",name="parentId") + private Long parentId; + @io.swagger.annotations.ApiModelProperty(value="",name="countSub") + private Integer countSub; + @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") + private String coverImg; + @io.swagger.annotations.ApiModelProperty(value="多封面图",name="coverPicture") + private String coverPicture; + @io.swagger.annotations.ApiModelProperty(value="详情多图",name="detailPicture") + private String detailPicture; + @io.swagger.annotations.ApiModelProperty(value="名称",name="title") + @Excel(name="名称",width = 20,orderNum = "1") + private String title; + @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle") + private String subTitle; + + @io.swagger.annotations.ApiModelProperty(value="EnumSex",name="sex") + private Integer sex; + @TableField(exist = false) + private String sexStr; + public String getSexStr(){ + EnumSex anEnum = EnumSex.getEnum(this.sex); + if(anEnum != null){ + sexStr = anEnum.getMessage(); + } + return sexStr; + } + + @io.swagger.annotations.ApiModelProperty(value="EnumAgeType",name="age") + private Integer ageType; + @TableField(exist = false) + private String ageTypeStr; + public String getAgeTypeStr(){ + EnumAgeType anEnum = EnumAgeType.getEnum(this.ageType); + if(anEnum != null){ + ageTypeStr = anEnum.getMessage(); + } + return ageTypeStr; + } + + @io.swagger.annotations.ApiModelProperty(value="EnumLanguages",name="languages") + private Integer languages; + + @io.swagger.annotations.ApiModelProperty(value="标签",name="sceneSign") + private String sceneSign; + + @TableField(exist = false) + private List sceneSignList; + + public List getSceneSignList(){ + if(StringUtils.isNotBlank(this.getSceneSign())){ + try{ + List longs = JSONObject.parseArray(this.getSceneSign(), Long.class); + if(longs != null && longs.size() > 0){ + return longs; + } + }catch(Exception e){ + } + } + return null; + } + + @TableField(exist = false) + private List mouldPatchSign; + + @io.swagger.annotations.ApiModelProperty(value="售价",name="salePrice") + @Excel(name="售价(分)",width = 20,orderNum = "3") + private Integer salePrice; + + @io.swagger.annotations.ApiModelProperty(value="须知",name="detail") + private String detail; + @io.swagger.annotations.ApiModelProperty(value="原价",name="price") + @Excel(name="原价(分)",width = 20,orderNum = "2") + private Integer price; + + @io.swagger.annotations.ApiModelProperty(value="EnumMouldSendType 1.系统模板",name="sendType") + private Integer sendType; + + @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") + private String remark; + + @io.swagger.annotations.ApiModelProperty(value="模板第三方Id",name="mouldSmId") + private String mouldSmId; + + @io.swagger.annotations.ApiModelProperty(value="EnumPersonaType",name="personaType") + private Integer personaType; + @TableField(exist = false) + private String personaTypeStr; + public String getPersonaTypeStr(){ + EnumPersonaType anEnum = EnumPersonaType.getEnum(this.personaType); + if(anEnum != null){ + personaTypeStr = anEnum.getMessage(); + } + return personaTypeStr; + } + + @io.swagger.annotations.ApiModelProperty(value="EnumSpeakType",name="speakType") + private Integer speakType; + @TableField(exist = false) + private String speakTypeStr; + public String getSpeakTypeStr(){ + EnumSpeakType anEnum = EnumSpeakType.getEnum(this.personaType); + if(anEnum != null){ + speakTypeStr = anEnum.getMessage(); + } + return speakTypeStr; + } + + @io.swagger.annotations.ApiModelProperty(value="EnumaMouldPatchStatus 状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)",name="status") + private Integer status; + @io.swagger.annotations.ApiModelProperty(value="上架时间",name="putonDate") + private Date putonDate; + @io.swagger.annotations.ApiModelProperty(value="样例videoid",name="exampleVideoId") + private String exampleVideoId; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + + public String getSalePriceStr() { + if(salePrice!=null) { + salePriceStr = new BigDecimal(salePrice).divide(new BigDecimal(100)).toString(); + } + return salePriceStr; + } + + public String getPriceStr() { + if(price!=null) { + priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString(); + } + return priceStr; + } + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumAgeType.java b/suimangService/src/main/java/com/iformall/enums/EnumAgeType.java new file mode 100644 index 0000000..28bad76 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumAgeType.java @@ -0,0 +1,48 @@ +package com.iformall.enums; + +public enum EnumAgeType { + + UNKNOWN(0, "保密"), + children(1, "儿童"), + early_youth(2,"少年"), + youth(3,"青年"), + middle_age(4,"中年"), + old_age(5,"老年"), + ; + + public static EnumAgeType getEnum(Integer code) { + for (EnumAgeType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private EnumAgeType(Integer code, String message) { + this.code = code; + this.message = message; + } + + private Integer code; + private String message; + + + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumPersonaType.java b/suimangService/src/main/java/com/iformall/enums/EnumPersonaType.java new file mode 100644 index 0000000..3d6fcc5 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumPersonaType.java @@ -0,0 +1,72 @@ +package com.iformall.enums; + +public enum EnumPersonaType { + /** + * | Boy | 角色风格 | 男孩 | 声音模仿男孩 | + * | Girl | 角色风格 | 女孩 | 声音模仿女孩 | + * | OlderAdultFemale | 角色风格 | 女老年 | 声音模仿年长的成年女性 | + * | OlderAdultMale | 角色风格 | 男老年 | 声音模仿年长的成年男性 | + * | SeniorFemale | 角色风格 | 女中年 | 声音模仿年老女性 | + * | SeniorMale | 角色风格 | 男中年 | 声音模仿年老男性 | + * | YoungAdultFemale | 角色风格 | 女青年 | 声音模仿年轻的成年女性 | + * | YoungAdultMale | 角色风格 | 男青年 | 声音模仿年轻的成年男性 | + * | | | | | + * | default | 默认风格 | | 默认的语音风格,没做任何风格转换 + */ + + default_0(0, "默认风格","default"), + Boy(1, "男孩","Boy"), + Girl(2,"女孩","Girl"), + OlderAdultFemale(3,"女老年","OlderAdultFemale"), + OlderAdultMale(4,"男老年","OlderAdultMale"), + SeniorFemale(5,"女中年","SeniorFemale"), + SeniorMale(6,"男中年","SeniorMale"), + YoungAdultFemale(7,"女青年","YoungAdultFemale"), + YoungAdultMale(8,"男青年","YoungAdultMale"), + ; + + public static EnumPersonaType getEnum(Integer code) { + for (EnumPersonaType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private EnumPersonaType(Integer code, String message, String type) { + this.code = code; + this.message = message; + this.type = type; + } + + private Integer code; + private String message; + private String type; + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumSex.java b/suimangService/src/main/java/com/iformall/enums/EnumSex.java index 5fe68a5..c79af5d 100644 --- a/suimangService/src/main/java/com/iformall/enums/EnumSex.java +++ b/suimangService/src/main/java/com/iformall/enums/EnumSex.java @@ -8,6 +8,15 @@ public enum EnumSex { ; + public static EnumSex getEnum(Integer code) { + for (EnumSex value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + private EnumSex(Integer code, String message) { this.code = code; this.message = message; diff --git a/suimangService/src/main/java/com/iformall/enums/EnumSpeakType.java b/suimangService/src/main/java/com/iformall/enums/EnumSpeakType.java new file mode 100644 index 0000000..c2208a3 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumSpeakType.java @@ -0,0 +1,125 @@ +package com.iformall.enums; + +public enum EnumSpeakType { + + /** + * | advertisement-upbeat | 说话风格 | 广告-欢快 | 用兴奋和精力充沛的语气推广产品或服务 | + * | affectionate | 说话风格 | 撒娇 | 以较高的音调和音量表达温暖而亲切的语气。 说话者处于吸引听众注意力的状态。 说话者的个性往往是讨喜的 | + * | angry | 说话风格 | 愤怒 | 表达生气和厌恶的语气 | + * | assistant | 说话风格 | 助理 | 数字助理用的是热情而轻松的语气 | + * | calm | 说话风格 | 平静 | 以沉着冷静的态度说话。 语气、音调和韵律与其他语音类型相比要统一得多 | + * | chat | 说话风格 | 聊天 | 表达轻松随意的语气 | + * | cheerful | 说话风格 | 愉悦 | 表达积极愉快的语气 | + * | customerservice | 说话风格 | 客服 | 以友好热情的语气为客户提供支持 | + * | depressed | 说话风格 | 沮丧 | 调低音调和音量来表达忧郁、沮丧的语气 | + * | disgruntled | 说话风格 | 不满 | 表达轻蔑和抱怨的语气。 这种情绪的语音表现出不悦和蔑视 | + * | documentary-narration | 说话风格 | 纪录片-旁白 | 用一种轻松、感兴趣和信息丰富的风格讲述纪录片,适合配音纪录片、专家评论和类似内容 | + * | embarrassed | 说话风格 | 尴尬 | 在说话者感到不舒适时表达不确定、犹豫的语气 | + * | empathetic | 说话风格 | 同理心 | 表达关心和理解 | + * | envious | 说话风格 | 羡慕 | 当你渴望别人拥有的东西时,表达一种钦佩的语气 | + * | excited | 说话风格 | 兴奋 | 表达乐观和充满希望的语气。 似乎发生了一些美好的事情,说话人对此非常满意 | + * | fearful | 说话风格 | 害怕 | 以较高的音调、较高的音量和较快的语速来表达恐惧、紧张的语气。 说话人处于紧张和不安的状态 | + * | friendly | 说话风格 | 友好 | 表达一种愉快、怡人且温暖的语气。 听起来很真诚且满怀关切 | + * | gentle | 说话风格 | 温柔 | 以较低的音调和音量表达温和、礼貌和愉快的语气 | + * | hopeful | 说话风格 | 期待 | 表达一种温暖且渴望的语气。 听起来像是会有好事发生在说话人身上 | + * | lyrical | 说话风格 | 抒情 | 以优美又带感伤的方式表达情感 | + * | narration-professional | 说话风格 | 旁白 - 专业 | 以专业、客观的语气朗读内容 | + * | narration-relaxed | 说话风格 | 旁白-放松 | 为内容阅读表达一种舒缓而悦耳的语气 | + * | newscast | 说话风格 | 新闻 | 以正式专业的语气叙述新闻 | + * | newscast-casual | 说话风格 | 新闻 - 休闲 | 以通用、随意的语气发布一般新闻 | + * | newscast-formal | 说话风格 | 新闻 - 正式 | 以正式、自信和权威的语气发布新闻 | + * | poetry-reading | 说话风格 | 诗歌朗诵 | 在读诗时表达出带情感和节奏的语气 | + * | sad | 说话风格 | 悲伤 | 表达悲伤语气 | + * | serious | 说话风格 | 严厉 | 表达严肃和命令的语气。 说话者的声音通常比较僵硬,节奏也不那么轻松 | + * | shouting | 说话风格 | 喊叫 | 就像从遥远的地方说话或在外面说话,但能让自己清楚地听到 | + * | sports-commentary | 说话风格 | 体育解说 | 用轻松有趣的语气播报体育赛事 | + * | sports-commentary-excited | 说话风格 | 体育解说-兴奋 | 用快速且充满活力的语气播报体育赛事精彩瞬间 | + * | whispering | 说话风格 | 低语 | 说话非常柔和,发出的声音小且温柔 | + * | terrified | 说话风格 | 恐惧 | 表达一种非常害怕的语气,语速快且声音颤抖。 听起来说话人处于不稳定的疯狂状态 | + * | unfriendly | 说话风格 | 不友好 | 表达一种冷淡无情的语气 | + * | | | | | + * | default | 默认风格 | | 默认的语音风格,没做任何风格转换 + */ + + default_0(0, "默认风格","default"), + advertisement_upbeat(1, "广告-欢快","advertisement-upbeat"), + affectionate(2,"撒娇","affectionate"), + angry(3,"愤怒","angry"), + assistant(4,"助理","assistant"), + calm(5,"平静","calm"), + chat(6,"聊天","chat"), + cheerful(7,"愉悦","cheerful"), + customerservice(8,"客服","customerservice"), + depressed(9,"沮丧","depressed"), + disgruntled(10,"不满","disgruntled"), + documentary_narration(11, "纪录片-旁白","documentary-narration"), + embarrassed(12,"尴尬","embarrassed"), + empathetic(13,"同理心","empathetic"), + envious(14,"羡慕","envious"), + excited(15,"兴奋","excited"), + fearful(16,"害怕","fearful"), + friendly(17,"友好","friendly"), + gentle(18,"温柔","gentle"), + hopeful(19,"期待","hopeful"), + lyrical(20,"抒情","lyrical"), + narration_professional(21, "旁白-专业","narration-professional"), + narration_relaxed(22,"旁白-放松","narration-relaxed"), + newscast(23,"新闻","newscast"), + newscast_casual(24,"新闻-休闲","newscast-casual"), + newscast_formal(25,"新闻-正式","newscast-formal"), + poetry_reading(26,"诗歌朗诵","poetry-reading"), + sad(27,"悲伤","sad"), + serious(28,"严厉","serious"), + shouting(29,"喊叫","shouting"), + sports_commentary(30,"体育解说","sports-commentary"), + sports_commentary_excited(31, "体育解说-兴奋","sports-commentary-excited"), + whispering(32,"低语","whispering"), + terrified(33,"恐惧","terrified"), + unfriendly(34,"不友好","unfriendly"), + ; + + public static EnumSpeakType getEnum(Integer code) { + for (EnumSpeakType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private EnumSpeakType(Integer code, String message, String type) { + this.code = code; + this.message = message; + this.type = type; + } + + private Integer code; + private String message; + private String type; + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + +} diff --git a/suimangService/src/main/java/com/iformall/mapper/VoiceMouldMapper.java b/suimangService/src/main/java/com/iformall/mapper/VoiceMouldMapper.java new file mode 100644 index 0000000..4ffb97d --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/VoiceMouldMapper.java @@ -0,0 +1,23 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.sm.MouldPatch; +import com.iformall.domain.po.sm.VoiceMould; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface VoiceMouldMapper extends CommonMapper { + + List findList(VoiceMould record); + + int deleteById(@Param("id")Long id); + + /** + * c端列表查询,尽量减少字段 + * @param record + * @return + */ + List findCList(VoiceMould record); + +} diff --git a/suimangService/src/main/java/com/iformall/service/sm/VoiceMouldService.java b/suimangService/src/main/java/com/iformall/service/sm/VoiceMouldService.java new file mode 100644 index 0000000..3d3273e --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/sm/VoiceMouldService.java @@ -0,0 +1,46 @@ +package com.iformall.service.sm; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.sm.MouldPatch; +import com.iformall.domain.po.sm.VoiceMould; + +public interface VoiceMouldService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(VoiceMould record, Integer pageIndex, Integer pageSize); + PageInfo cListAsPage(VoiceMould record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + VoiceMould getById(Long id); + VoiceMould getDetailById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + ResultData saveOrUpdate(VoiceMould record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + void updateOnline(VoiceMould record); + +} diff --git a/suimangService/src/main/java/com/iformall/service/sm/impl/VoiceMouldServiceImpl.java b/suimangService/src/main/java/com/iformall/service/sm/impl/VoiceMouldServiceImpl.java new file mode 100644 index 0000000..e519f2d --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/sm/impl/VoiceMouldServiceImpl.java @@ -0,0 +1,118 @@ +package com.iformall.service.sm.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.IdWorker; +import com.iformall.common.ResultData; +import com.iformall.domain.po.sm.MouldPatch; +import com.iformall.domain.po.sm.MouldPatchSign; +import com.iformall.domain.po.sm.VoiceMould; +import com.iformall.enums.EnumColour; +import com.iformall.enums.EnumMouldSendType; +import com.iformall.enums.EnumaMouldPatchStatus; +import com.iformall.mapper.MouldPatchMapper; +import com.iformall.mapper.VoiceMouldMapper; +import com.iformall.service.sm.MouldPatchService; +import com.iformall.service.sm.MouldPatchSignService; +import com.iformall.service.sm.VoiceMouldService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + + +@Service +public class VoiceMouldServiceImpl implements VoiceMouldService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + VoiceMouldMapper voiceMouldMapper; + + @Autowired + MouldPatchSignService mouldPatchSignService; + + + @Override + public PageInfo listAsPage(VoiceMould record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> voiceMouldMapper.findList(record)); + } + + @Override + public PageInfo cListAsPage(VoiceMould record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> voiceMouldMapper.findCList(record)); + } + + @Override + public VoiceMould getById(Long id) { + return voiceMouldMapper.selectById(id); + } + + @Override + public VoiceMould getDetailById(Long id) { + VoiceMould voiceMould = getById(id); + if(voiceMould.getSceneSignList() != null && !voiceMould.getSceneSignList().isEmpty()){ + MouldPatchSign signQ = new MouldPatchSign(); + signQ.setIds(voiceMould.getSceneSignList()); + List signList = mouldPatchSignService.getList(signQ); + voiceMould.setMouldPatchSign(signList); + } + return voiceMould; + } + + @Override + public ResultData saveOrUpdate(VoiceMould record) { + //金额处理 + if (StringUtils.isNotEmpty(record.getSalePriceStr())) { + record.setSalePrice(new BigDecimal(record.getSalePriceStr()).multiply(new BigDecimal(100)).intValue()); + } + if(record.getSalePrice() > 0){ + record.setSendType(EnumMouldSendType.buy.getCode()); + }else{ + record.setSendType(EnumMouldSendType.auto.getCode()); + } + if (StringUtils.isNotEmpty(record.getPriceStr())) { + record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).intValue()); + } + + Date now = new Date(); + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + if(record.getStatus() == null){ + record.setStatus(EnumaMouldPatchStatus.draft.getCode()); + } + record.setCreateDate(now); + record.setUpdateDate(now); + voiceMouldMapper.insert(record); + } else { + record.setUpdateDate(now); + voiceMouldMapper.updateById(record); + } + return new ResultData(); + } + + @Override + public void deleteById(Long id) { + voiceMouldMapper.deleteById(id); + } + + @Override + public void updateOnline(VoiceMould record) { + Date now = new Date(); + VoiceMould voiceMouldUpd = new VoiceMould(); + voiceMouldUpd.setId(record.getId()); + voiceMouldUpd.setStatus(record.getStatus()); + if(EnumaMouldPatchStatus.put_on.getCode().equals(voiceMouldUpd.getStatus())){ + voiceMouldUpd.setPutonDate(now); + } + voiceMouldUpd.setUpdateDate(now); + voiceMouldMapper.updateById(voiceMouldUpd); + } + +} diff --git a/suimangService/src/main/resources/mapper/VoiceMouldMapper.xml b/suimangService/src/main/resources/mapper/VoiceMouldMapper.xml new file mode 100644 index 0000000..5e497a2 --- /dev/null +++ b/suimangService/src/main/resources/mapper/VoiceMouldMapper.xml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`, `tenant_id`, `parent_tenant_id`, `parent_id`, `count_sub`, `cover_img`, `cover_picture`, `detail_picture`, + `title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`, + `send_type`, `detail`, `remark`, `mould_sm_id`,`persona_type`,`speak_type`, `example_video_id`, `status`, `puton_date`, `create_date`, `update_date` + + + + where `is_del` = 0 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `parent_id` = #{parentId} + + + + and `count_sub` = #{countSub} + + + + and `title` like concat('%', #{title},'%') + + + + and `sub_title` like concat('%', #{subTitle},'%') + + + + and `sex` = #{sex} + + + + and `age_type` = #{ageType} + + + + and `languages` = #{languages} + + + + and JSON_CONTAINS(scene_sign,json_array(#{sceneSign})) + + + + and `sale_price` = #{salePrice} + + + + and `send_type` = #{sendType} + + + + and `price` = #{price} + + + + and `status` = #{status} + + + + and `persona_type` = #{personaType} + + + + and `speak_type` = #{speakType} + + + + and create_date >= #{startDate} + + + and create_date < #{endDate} + + + + and id in + + #{idItem} + + + + order by ${sortColumns} + + + + + + update voice_mould set is_del = 1,update_date = now() where id = #{id} + + + + +