Browse Source

//personMould

private_deployment
xhxu 1 year ago
parent
commit
ef68186f52
11 changed files with 594 additions and 8 deletions
  1. +66
    -0
      suimangCApi/src/main/java/com/iformall/controller/PersonMouldController.java
  2. +3
    -0
      suimangService/src/main/java/com/iformall/domain/po/sm/MouldPatchSign.java
  3. +134
    -0
      suimangService/src/main/java/com/iformall/domain/po/sm/PersonMould.java
  4. +5
    -5
      suimangService/src/main/java/com/iformall/enums/EnumMouldPatchType.java
  5. +1
    -0
      suimangService/src/main/java/com/iformall/enums/EnumMouldSendType.java
  6. +51
    -0
      suimangService/src/main/java/com/iformall/enums/EnumVideoType.java
  7. +23
    -0
      suimangService/src/main/java/com/iformall/mapper/PersonMouldMapper.java
  8. +46
    -0
      suimangService/src/main/java/com/iformall/service/sm/PersonMouldService.java
  9. +121
    -0
      suimangService/src/main/java/com/iformall/service/sm/impl/PersonMouldServiceImpl.java
  10. +8
    -3
      suimangService/src/main/resources/mapper/MouldPatchSignMapper.xml
  11. +136
    -0
      suimangService/src/main/resources/mapper/PersonMouldMapper.xml

+ 66
- 0
suimangCApi/src/main/java/com/iformall/controller/PersonMouldController.java View File

@@ -0,0 +1,66 @@
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.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 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/personPatch")
@Api(description = "模板接口")
public class PersonMouldController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@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 PersonMould record, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] MouldPatchController::list");
if (record == null) record = new PersonMould();
record.setSendType(EnumMouldSendType.auto.getCode());
record.setStatus(EnumaMouldPatchStatus.put_on.getCode());
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<PersonMould> page = personMouldService.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");
PersonMould personMould = personMouldService.getDetailById(id);

return new ResultData(personMould);
}

}

+ 3
- 0
suimangService/src/main/java/com/iformall/domain/po/sm/MouldPatchSign.java View File

@@ -20,6 +20,9 @@ public class MouldPatchSign extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="",name="title")
private String title;

@io.swagger.annotations.ApiModelProperty(value="EnumMouldPatchType",name="type")
private String type;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")


+ 134
- 0
suimangService/src/main/java/com/iformall/domain/po/sm/PersonMould.java View File

@@ -0,0 +1,134 @@
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 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 = "person_mould")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class PersonMould 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="EnumVideoType",name="videotType")
private Integer videotType;
@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;
@io.swagger.annotations.ApiModelProperty(value="年龄",name="age")
private Integer age;
@io.swagger.annotations.ApiModelProperty(value="EnumColour",name="colour")
private Integer colour;

@TableField(exist = false)
private String colourStr;

@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="素材",name="material")
private String material;

@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="创建时间",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;
}
}

+ 5
- 5
suimangService/src/main/java/com/iformall/enums/EnumMouldPatchType.java View File

@@ -10,11 +10,11 @@ public enum EnumMouldPatchType {

// 1:人物模板,2:声音模板,3:身体模板,4:背景模板

person_mould(1, "人物模板"),
voice_mould(2, "声音模板"),
body_mould(3, "身体模板"),
background_mould(4, "背景模板"),
material_mould(5, "素材模板"),
person_mould(1, "数字人"),
voice_mould(2, "声音"),
// body_mould(3, "身体模板"),
background_mould(4, "背景"),
material_mould(5, "素材"),
;

public static EnumMouldPatchType getEnum(Integer code) {


+ 1
- 0
suimangService/src/main/java/com/iformall/enums/EnumMouldSendType.java View File

@@ -7,6 +7,7 @@ public enum EnumMouldSendType {

auto(1,"系统模板"),
buy(2, "收费模板"),
build(3, "自建模板"),
;

public static EnumMouldSendType getEnum(Integer code) {


+ 51
- 0
suimangService/src/main/java/com/iformall/enums/EnumVideoType.java View File

@@ -0,0 +1,51 @@
package com.iformall.enums;

import java.util.ArrayList;
import java.util.List;

/**
*
*/
public enum EnumVideoType {

// 1:竖版
// 2:横版

VERTICAL_PLATE(1, "竖版"),
HORIZONTAL_PLATE(2, "横版"),
;

public static EnumVideoType getEnum(Integer code) {
for (EnumVideoType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

public static List<Integer> getAllCodes(){
List<Integer> codes = new ArrayList<>();
for (EnumVideoType value : values()) {
codes.add(value.getCode());
}
return codes;
}

private Integer code;
private String message;

EnumVideoType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}

}

+ 23
- 0
suimangService/src/main/java/com/iformall/mapper/PersonMouldMapper.java View File

@@ -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.PersonMould;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface PersonMouldMapper extends CommonMapper<PersonMould, Long> {

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

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

}

+ 46
- 0
suimangService/src/main/java/com/iformall/service/sm/PersonMouldService.java View File

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

public interface PersonMouldService {

/**
* 根据实体查询分页列表
*
* @param record
* @param pageIndex
* @param pageSize
* @return
*/
PageInfo<PersonMould> listAsPage(PersonMould record, Integer pageIndex, Integer pageSize);
PageInfo<PersonMould> cListAsPage(PersonMould record, Integer pageIndex, Integer pageSize);

/**
* 根据Id获得实体
*
* @param id
* @return
*/
PersonMould getById(Long id);
PersonMould getDetailById(Long id);

/**
* 保存或更新实体
*
* @param record
*/
ResultData saveOrUpdate(PersonMould record);

/**
* 根据Id删除实体
*
* @param id
*/
void deleteById(Long id);

void updateOnline(PersonMould record);

}

+ 121
- 0
suimangService/src/main/java/com/iformall/service/sm/impl/PersonMouldServiceImpl.java View File

@@ -0,0 +1,121 @@
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.PersonMould;
import com.iformall.enums.EnumColour;
import com.iformall.enums.EnumMouldSendType;
import com.iformall.enums.EnumaMouldPatchStatus;
import com.iformall.mapper.MouldPatchMapper;
import com.iformall.mapper.PersonMouldMapper;
import com.iformall.service.sm.MouldPatchService;
import com.iformall.service.sm.MouldPatchSignService;
import com.iformall.service.sm.PersonMouldService;
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 PersonMouldServiceImpl implements PersonMouldService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
PersonMouldMapper personMouldMapper;

@Autowired
MouldPatchSignService mouldPatchSignService;


@Override
public PageInfo<PersonMould> listAsPage(PersonMould record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> personMouldMapper.findList(record));
}

@Override
public PageInfo<PersonMould> cListAsPage(PersonMould record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> personMouldMapper.findCList(record));
}
@Override
public PersonMould getById(Long id) {
return personMouldMapper.selectById(id);
}

@Override
public PersonMould getDetailById(Long id) {
PersonMould personMould = getById(id);
if(personMould.getSceneSignList() != null && !personMould.getSceneSignList().isEmpty()){
MouldPatchSign signQ = new MouldPatchSign();
signQ.setIds(personMould.getSceneSignList());
List<MouldPatchSign> signList = mouldPatchSignService.getList(signQ);
personMould.setMouldPatchSign(signList);
}
if(personMould.getColour() != null){
personMould.setColourStr(EnumColour.getEnum(personMould.getColour()).getMessage());
}
return personMould;
}

@Override
public ResultData saveOrUpdate(PersonMould 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);
personMouldMapper.insert(record);
} else {
record.setUpdateDate(now);
personMouldMapper.updateById(record);
}
return new ResultData();
}

@Override
public void deleteById(Long id) {
personMouldMapper.deleteById(id);
}

@Override
public void updateOnline(PersonMould record) {
Date now = new Date();
PersonMould personMouldUpd = new PersonMould();
personMouldUpd.setId(record.getId());
personMouldUpd.setStatus(record.getStatus());
if(EnumaMouldPatchStatus.put_on.getCode().equals(personMouldUpd.getStatus())){
personMouldUpd.setPutonDate(now);
}
personMouldUpd.setUpdateDate(now);
personMouldMapper.updateById(personMouldUpd);
}

}

+ 8
- 3
suimangService/src/main/resources/mapper/MouldPatchSignMapper.xml View File

@@ -3,11 +3,12 @@
<mapper namespace="com.iformall.mapper.MouldPatchSignMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.MouldPatchSign">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="title" jdbcType="VARCHAR" property="title" />
</resultMap>
<sql id="allColumns">
`id`,`title`
`id`,`type` ,`title`
</sql>

<sql id="dynamicWhereConditions">
@@ -16,8 +17,12 @@
<if test=" null != id ">
and `id` = #{id}
</if>
</if>
<if test=" null != type ">
and `type` = #{type}

</if>

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


+ 136
- 0
suimangService/src/main/resources/mapper/PersonMouldMapper.xml View File

@@ -0,0 +1,136 @@
<?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.PersonMouldMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.PersonMould">
<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="video_type" jdbcType="INTEGER" property="videoType"/>
<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" jdbcType="INTEGER" property="age"/>
<result column="colour" jdbcType="INTEGER" property="colour"/>
<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="material" jdbcType="VARCHAR" property="material"/>
<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`, `video_type`, `cover_img`, `cover_picture`, `detail_picture`,
`title`, `sub_title`, `sex`, `age`, `colour`, `languages`, `scene_sign`, `sale_price`, `price`,
`send_type`, `detail`, `remark`, `mould_sm_id`,`material`, `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 != videoType ">
and `video_type` = #{videoType}
</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 != age ">
and `age` = #{age}
</if>

<if test=" null != colour ">
and `colour` = #{colour}
</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 != 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.PersonMould" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from person_mould
<include refid="dynamicWhereConditions"/>
</select>

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

<select id="findCList" parameterType="com.iformall.domain.po.sm.PersonMould" resultMap="BaseResultMap">
select
`id`, `video_type`, `cover_img`, `cover_picture`,
`title`, `sub_title`, `sex`, `age`, `colour`, `languages`, `scene_sign`, `sale_price`, `price`,
`send_type`, `mould_sm_id`,`material`, `status`, `create_date`, `update_date`
from person_mould
<include refid="dynamicWhereConditions"/>
</select>

</mapper>

Loading…
Cancel
Save