Kaynağa Gözat

//voiceMould

private_deployment
xhxu 1 yıl önce
ebeveyn
işleme
82a3ba48ed
10 değiştirilmiş dosya ile 876 ekleme ve 0 silme
  1. +108
    -0
      suimangCApi/src/main/java/com/iformall/controller/VoiceMouldController.java
  2. +180
    -0
      suimangService/src/main/java/com/iformall/domain/po/sm/VoiceMould.java
  3. +48
    -0
      suimangService/src/main/java/com/iformall/enums/EnumAgeType.java
  4. +72
    -0
      suimangService/src/main/java/com/iformall/enums/EnumPersonaType.java
  5. +9
    -0
      suimangService/src/main/java/com/iformall/enums/EnumSex.java
  6. +125
    -0
      suimangService/src/main/java/com/iformall/enums/EnumSpeakType.java
  7. +23
    -0
      suimangService/src/main/java/com/iformall/mapper/VoiceMouldMapper.java
  8. +46
    -0
      suimangService/src/main/java/com/iformall/service/sm/VoiceMouldService.java
  9. +118
    -0
      suimangService/src/main/java/com/iformall/service/sm/impl/VoiceMouldServiceImpl.java
  10. +147
    -0
      suimangService/src/main/resources/mapper/VoiceMouldMapper.xml

+ 108
- 0
suimangCApi/src/main/java/com/iformall/controller/VoiceMouldController.java Dosyayı Görüntüle

@@ -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<VoiceMould> 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<VoiceMould> page = voiceMouldService.cListAsPage(voiceMould, pageNum, pageSize);
return new ResultData(page);
}

}

+ 180
- 0
suimangService/src/main/java/com/iformall/domain/po/sm/VoiceMould.java Dosyayı Görüntüle

@@ -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<Long> sceneSignList;

public List<Long> getSceneSignList(){
if(StringUtils.isNotBlank(this.getSceneSign())){
try{
List<Long> 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> 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;
}
}

+ 48
- 0
suimangService/src/main/java/com/iformall/enums/EnumAgeType.java Dosyayı Görüntüle

@@ -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;
}
}

+ 72
- 0
suimangService/src/main/java/com/iformall/enums/EnumPersonaType.java Dosyayı Görüntüle

@@ -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;
}
}

+ 9
- 0
suimangService/src/main/java/com/iformall/enums/EnumSex.java Dosyayı Görüntüle

@@ -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;


+ 125
- 0
suimangService/src/main/java/com/iformall/enums/EnumSpeakType.java Dosyayı Görüntüle

@@ -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;
}
}

+ 23
- 0
suimangService/src/main/java/com/iformall/mapper/VoiceMouldMapper.java Dosyayı Görüntüle

@@ -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<VoiceMould, Long> {

List<VoiceMould> findList(VoiceMould record);
int deleteById(@Param("id")Long id);

/**
* c端列表查询,尽量减少字段
* @param record
* @return
*/
List<VoiceMould> findCList(VoiceMould record);

}

+ 46
- 0
suimangService/src/main/java/com/iformall/service/sm/VoiceMouldService.java Dosyayı Görüntüle

@@ -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<VoiceMould> listAsPage(VoiceMould record, Integer pageIndex, Integer pageSize);
PageInfo<VoiceMould> 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);

}

+ 118
- 0
suimangService/src/main/java/com/iformall/service/sm/impl/VoiceMouldServiceImpl.java Dosyayı Görüntüle

@@ -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<VoiceMould> listAsPage(VoiceMould record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> voiceMouldMapper.findList(record));
}

@Override
public PageInfo<VoiceMould> 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<MouldPatchSign> 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);
}

}

+ 147
- 0
suimangService/src/main/resources/mapper/VoiceMouldMapper.xml Dosyayı Görüntüle

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.VoiceMouldMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.VoiceMould">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="parent_id" jdbcType="INTEGER" property="parentId"/>
<result column="count_sub" jdbcType="BIGINT" property="countSub"/>
<result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
<result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
<result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
<result column="sex" jdbcType="INTEGER" property="sex"/>
<result column="age_type" jdbcType="INTEGER" property="ageType"/>
<result column="languages" jdbcType="INTEGER" property="languages"/>
<result column="scene_sign" jdbcType="VARCHAR" property="sceneSign"/>
<result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
<result column="price" jdbcType="INTEGER" property="price"/>
<result column="send_type" jdbcType="INTEGER" property="sendType"/>
<result column="detail" jdbcType="VARCHAR" property="detail"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="mould_sm_id" jdbcType="VARCHAR" property="mouldSmId"/>
<result column="persona_type" jdbcType="INTEGER" property="personaType"/>
<result column="speak_type" jdbcType="INTEGER" property="speakType"/>
<result column="example_video_id" jdbcType="VARCHAR" property="exampleVideoId"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="puton_date" jdbcType="TIMESTAMP" property="putonDate"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
</resultMap>

<sql id="allColumns">
`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`
</sql>

<sql id="dynamicWhereConditions">
where `is_del` = 0

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != parentId ">
and `parent_id` = #{parentId}
</if>

<if test=" null != countSub ">
and `count_sub` = #{countSub}
</if>

<if test=" null != title and ''!=title">
and `title` like concat('%', #{title},'%')
</if>

<if test=" null != subTitle ">
and `sub_title` like concat('%', #{subTitle},'%')
</if>

<if test=" null != sex ">
and `sex` = #{sex}
</if>

<if test=" null != ageType ">
and `age_type` = #{ageType}
</if>

<if test=" null != languages ">
and `languages` = #{languages}
</if>

<if test=" null != sceneSign and '' != sceneSign">
and JSON_CONTAINS(scene_sign,json_array(#{sceneSign}))
</if>

<if test=" null != salePrice ">
and `sale_price` = #{salePrice}
</if>

<if test=" null != sendType ">
and `send_type` = #{sendType}
</if>

<if test=" null != price ">
and `price` = #{price}
</if>

<if test=" null != status">
and `status` = #{status}
</if>

<if test=" null != personaType ">
and `persona_type` = #{personaType}
</if>

<if test=" null != speakType ">
and `speak_type` = #{speakType}
</if>

<if test=" null != startDate ">
and create_date &gt;= #{startDate}
</if>
<if test=" null != endDate">
and create_date &lt; #{endDate}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>

<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.sm.VoiceMould" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from voice_mould
<include refid="dynamicWhereConditions"/>
</select>

<delete id="deleteById" parameterType="java.util.HashMap">
update voice_mould set is_del = 1,update_date = now() where id = #{id}
</delete>

<select id="findCList" parameterType="com.iformall.domain.po.sm.VoiceMould" resultMap="BaseResultMap">
select
`id`, `parent_tenant_id`, `parent_id`, `cover_img`, `cover_picture`,
`title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`,
`send_type`, `mould_sm_id`,`persona_type`,`speak_type`, `status`,`example_video_id`, `create_date`, `update_date`
from voice_mould
<include refid="dynamicWhereConditions"/>
</select>

</mapper>

Yükleniyor…
İptal
Kaydet