28 changed files with 983 additions and 1 deletions
@ -0,0 +1,58 @@ |
|||||
|
package com.bnyer.common.core.domain; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.*; |
||||
|
|
||||
|
/** |
||||
|
* 绘画-模型风格表 |
||||
|
*/ |
||||
|
@ApiModel(value="com-bnyer-common-core-domain-PaintStyle") |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ToString |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
@TableName(value = "img_paint_style") |
||||
|
public class PaintStyle extends BaseDomain { |
||||
|
/** |
||||
|
* 主键id |
||||
|
*/ |
||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 模型风格名称 |
||||
|
*/ |
||||
|
@TableField(value = "`name`") |
||||
|
@ApiModelProperty(value="模型风格名称") |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
*/ |
||||
|
@TableField(value = "model_name") |
||||
|
@ApiModelProperty(value="模型名称") |
||||
|
private String modelName; |
||||
|
|
||||
|
/** |
||||
|
* 模型风格图片 |
||||
|
*/ |
||||
|
@TableField(value = "img_url") |
||||
|
@ApiModelProperty(value="模型风格图片") |
||||
|
private String imgUrl; |
||||
|
|
||||
|
/** |
||||
|
* 是否热门(0->正常;1->热门) |
||||
|
*/ |
||||
|
@TableField(value = "is_hot") |
||||
|
@ApiModelProperty(value="是否热门(0->正常;1->热门)") |
||||
|
private String isHot; |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
package com.bnyer.common.core.domain; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.*; |
||||
|
|
||||
|
/** |
||||
|
* 绘画-提示词表 |
||||
|
*/ |
||||
|
@ApiModel(value="com-bnyer-common-core-domain-Prompt") |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ToString |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
@TableName(value = "img_prompt") |
||||
|
public class Prompt extends BaseDomain { |
||||
|
/** |
||||
|
* 主键id |
||||
|
*/ |
||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 提示词 |
||||
|
*/ |
||||
|
@TableField(value = "`text`") |
||||
|
@ApiModelProperty(value="提示词") |
||||
|
private String text; |
||||
|
|
||||
|
/** |
||||
|
* 类型(0->绘画;1->gpt) |
||||
|
*/ |
||||
|
@TableField(value = "`type`") |
||||
|
@ApiModelProperty(value="类型(0->绘画;1->gpt)") |
||||
|
private String type; |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package com.bnyer.common.core.dto; |
||||
|
|
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.common.core.utils.bean.BeanUtils; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("绘画风格入参接收类") |
||||
|
public class PaintStyleDto implements Serializable { |
||||
|
|
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
@ApiModelProperty(value="模型风格名称") |
||||
|
private String name; |
||||
|
|
||||
|
@ApiModelProperty(value="模型名称") |
||||
|
private String modelName; |
||||
|
|
||||
|
@ApiModelProperty(value="模型风格图片") |
||||
|
private String imgUrl; |
||||
|
|
||||
|
@ApiModelProperty(value="是否热门(0->正常;1->热门)") |
||||
|
private String isHot; |
||||
|
|
||||
|
@ApiModelProperty(value="排序") |
||||
|
private Integer sort; |
||||
|
|
||||
|
public PaintStyle extractParam(){ |
||||
|
PaintStyle paintStyle = new PaintStyle(); |
||||
|
BeanUtils.copyProperties(this,paintStyle); |
||||
|
return paintStyle; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.bnyer.common.core.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("绘画风格分页接收类") |
||||
|
public class PaintStylePageDto extends BasePageDto { |
||||
|
|
||||
|
@ApiModelProperty(value="模型风格名称") |
||||
|
private String name; |
||||
|
|
||||
|
@ApiModelProperty(value="是否热门(0->正常;1->热门)") |
||||
|
private String isHot; |
||||
|
|
||||
|
@ApiModelProperty(value="是否显示 (0->隐藏;1->显示)") |
||||
|
private String isShow; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.bnyer.common.core.dto; |
||||
|
|
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import com.bnyer.common.core.utils.bean.BeanUtils; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("提示词入参接收类") |
||||
|
public class PromptDto implements Serializable { |
||||
|
|
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
@ApiModelProperty(value="提示词") |
||||
|
private String text; |
||||
|
|
||||
|
@ApiModelProperty(value="类型(0->绘画;1->gpt)") |
||||
|
private String type; |
||||
|
|
||||
|
public Prompt extractParam(){ |
||||
|
Prompt prompt = new Prompt(); |
||||
|
BeanUtils.copyProperties(this,prompt); |
||||
|
return prompt; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.bnyer.common.core.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("提示词分页接收类") |
||||
|
public class PromptPageDto extends BasePageDto { |
||||
|
|
||||
|
@ApiModelProperty(value="提示词") |
||||
|
private String text; |
||||
|
|
||||
|
@ApiModelProperty(value="类型(0->绘画;1->gpt)") |
||||
|
private String type; |
||||
|
|
||||
|
@ApiModelProperty(value="是否显示 (0->隐藏;1->显示)") |
||||
|
private String isShow; |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
package com.bnyer.img.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.img.vo.PaintStyleVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface PaintStyleMapper extends BaseMapper<PaintStyle> { |
||||
|
|
||||
|
/** |
||||
|
* 获取绘画风格列表 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<PaintStyleVo> queryList(); |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
package com.bnyer.img.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import com.bnyer.img.vo.PromptVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface PromptMapper extends BaseMapper<Prompt> { |
||||
|
/** |
||||
|
* 获取提示词列表 |
||||
|
* @param type 类型 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<PromptVo> queryList(String type); |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.bnyer.img.service; |
||||
|
|
||||
|
import com.bnyer.img.vo.PaintStyleVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface PaintStyleService { |
||||
|
|
||||
|
/** |
||||
|
* 获取绘画风格列表 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<PaintStyleVo> queryPaintStyleList(); |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.bnyer.img.service; |
||||
|
|
||||
|
import com.bnyer.img.vo.PromptVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface PromptService { |
||||
|
|
||||
|
/** |
||||
|
* 随机获取8条提示词列表 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<PromptVo> queryPromptList(); |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.bnyer.img.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.img.mapper.PaintStyleMapper; |
||||
|
import com.bnyer.img.service.PaintStyleService; |
||||
|
import com.bnyer.img.vo.PaintStyleVo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class PaintStyleServiceImpl implements PaintStyleService { |
||||
|
|
||||
|
@Autowired |
||||
|
private PaintStyleMapper paintStyleMapper; |
||||
|
|
||||
|
@Override |
||||
|
public List<PaintStyleVo> queryPaintStyleList() { |
||||
|
return paintStyleMapper.queryList(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
package com.bnyer.img.service.impl; |
||||
|
|
||||
|
import com.bnyer.img.mapper.PromptMapper; |
||||
|
import com.bnyer.img.service.PromptService; |
||||
|
import com.bnyer.img.vo.PromptVo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class PromptServiceimpl implements PromptService { |
||||
|
|
||||
|
@Autowired |
||||
|
private PromptMapper promptMapper; |
||||
|
|
||||
|
@Override |
||||
|
public List<PromptVo> queryPromptList() { |
||||
|
//type:0->绘画;1->gpt
|
||||
|
List<PromptVo> promptVos = promptMapper.queryList("0"); |
||||
|
List<PromptVo> news = new ArrayList<>(); |
||||
|
Map<Integer,String> map = new HashMap<>(); |
||||
|
//随机抽10条数据展示在页面上
|
||||
|
if (promptVos.size() <= 30) { |
||||
|
return promptVos; |
||||
|
}else{ |
||||
|
while (map.size() < 30) { |
||||
|
int random = (int)(Math.random() * promptVos.size()); |
||||
|
if (!map.containsKey(random)) { |
||||
|
map.put(random, ""); |
||||
|
news.add(promptVos.get(random)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return news; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package com.bnyer.img.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("绘画风格响应体") |
||||
|
public class PaintStyleVo implements Serializable { |
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
@ApiModelProperty(value="模型风格名称") |
||||
|
private String name; |
||||
|
|
||||
|
@ApiModelProperty(value="模型名称") |
||||
|
private String modelName; |
||||
|
|
||||
|
@ApiModelProperty(value="模型风格图片") |
||||
|
private String imgUrl; |
||||
|
|
||||
|
@ApiModelProperty(value="是否热门(0->正常;1->热门)") |
||||
|
private String isHot; |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package com.bnyer.img.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ApiModel("提示词响应体") |
||||
|
public class PromptVo implements Serializable { |
||||
|
|
||||
|
@ApiModelProperty(value="主键id") |
||||
|
private Long id; |
||||
|
|
||||
|
@ApiModelProperty(value="提示词") |
||||
|
private String text; |
||||
|
|
||||
|
@ApiModelProperty(value="类型(0->绘画;1->gpt)") |
||||
|
private String type; |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
<?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.bnyer.img.mapper.PaintStyleMapper"> |
||||
|
<resultMap id="BaseResultMap" type="com.bnyer.common.core.domain.PaintStyle"> |
||||
|
<!--@mbg.generated--> |
||||
|
<!--@Table img_paint_style--> |
||||
|
<id column="id" jdbcType="BIGINT" property="id" /> |
||||
|
<result column="name" jdbcType="VARCHAR" property="name" /> |
||||
|
<result column="model_name" jdbcType="VARCHAR" property="modelName" /> |
||||
|
<result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> |
||||
|
<result column="is_show" jdbcType="CHAR" property="isShow" /> |
||||
|
<result column="is_hot" jdbcType="CHAR" property="isHot" /> |
||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
||||
|
<result column="sort" jdbcType="INTEGER" property="sort" /> |
||||
|
</resultMap> |
||||
|
<sql id="Base_Column_List"> |
||||
|
<!--@mbg.generated--> |
||||
|
id, `name`, model_name, img_url, is_show, is_hot, create_time, update_time, sort |
||||
|
</sql> |
||||
|
|
||||
|
<select id="queryList" resultType="com.bnyer.img.vo.PaintStyleVo"> |
||||
|
select |
||||
|
id, name, model_name, img_url,is_hot |
||||
|
from img_paint_style where is_show = '1' |
||||
|
order by sort desc |
||||
|
</select> |
||||
|
</mapper> |
||||
@ -0,0 +1,27 @@ |
|||||
|
<?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.bnyer.img.mapper.PromptMapper"> |
||||
|
<resultMap id="BaseResultMap" type="com.bnyer.common.core.domain.Prompt"> |
||||
|
<!--@mbg.generated--> |
||||
|
<!--@Table img_prompt--> |
||||
|
<id column="id" jdbcType="BIGINT" property="id" /> |
||||
|
<result column="text" jdbcType="LONGVARCHAR" property="text" /> |
||||
|
<result column="type" jdbcType="CHAR" property="type" /> |
||||
|
<result column="is_show" jdbcType="CHAR" property="isShow" /> |
||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
||||
|
<result column="sort" jdbcType="INTEGER" property="sort" /> |
||||
|
</resultMap> |
||||
|
<sql id="Base_Column_List"> |
||||
|
<!--@mbg.generated--> |
||||
|
id, `text`, `type`, is_show, create_time, update_time, sort |
||||
|
</sql> |
||||
|
|
||||
|
<select id="queryList" resultType="com.bnyer.img.vo.PromptVo"> |
||||
|
select |
||||
|
id, text, type |
||||
|
from img_prompt where is_show = '1' and type = #{type} |
||||
|
order by sort desc |
||||
|
|
||||
|
</select> |
||||
|
</mapper> |
||||
@ -0,0 +1,87 @@ |
|||||
|
package com.bnyer.system.controller; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.common.core.dto.PaintStyleDto; |
||||
|
import com.bnyer.common.core.dto.PaintStylePageDto; |
||||
|
import com.bnyer.common.core.dto.StatusDto; |
||||
|
import com.bnyer.common.core.web.controller.BaseController; |
||||
|
import com.bnyer.common.core.web.domain.AjaxResult; |
||||
|
import com.bnyer.common.core.web.page.TableDataInfo; |
||||
|
import com.bnyer.common.security.annotation.RequiresPermissions; |
||||
|
import com.bnyer.system.service.IPaintStyleService; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Api(value = "【图文平台】绘画风格接口",tags = "【图文平台】绘画风格接口") |
||||
|
@RestController |
||||
|
@RequestMapping("/img/paintStyle") |
||||
|
@Slf4j |
||||
|
public class PaintStyleController extends BaseController { |
||||
|
|
||||
|
@Autowired |
||||
|
private IPaintStyleService paintStyleService; |
||||
|
|
||||
|
@ApiOperation(value="查询绘画风格分页") |
||||
|
@PostMapping("/page") |
||||
|
public TableDataInfo pagePaintStyle(@RequestBody @ApiParam("分页对象") PaintStylePageDto dto){ |
||||
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); |
||||
|
List<PaintStyle> paintStyles = paintStyleService.queryPage(dto); |
||||
|
return getDataTable(paintStyles); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:paintStyle:add") |
||||
|
@ApiOperation(value="新增绘画风格") |
||||
|
@PostMapping(value = "/insert") |
||||
|
public AjaxResult insertPaintStyle(@Validated @RequestBody @ApiParam("绘画风格对象") PaintStyleDto dto){ |
||||
|
log.debug("【图文平台后台】新增绘画风格参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(paintStyleService.insert(dto.extractParam())); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:paintStyle:edit") |
||||
|
@ApiOperation(value="修改绘画风格") |
||||
|
@PostMapping(value = "/update") |
||||
|
public AjaxResult updatePaintStyle(@Validated @RequestBody @ApiParam("绘画风格对象") PaintStyleDto dto){ |
||||
|
log.debug("【图文平台后台】修改绘画风格参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(paintStyleService.update(dto.extractParam())); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:paintStyle:delete") |
||||
|
@ApiOperation(value="删除绘画风格") |
||||
|
@DeleteMapping(value = "/delete/{ids}") |
||||
|
public AjaxResult deletePaintStyle(@PathVariable @ApiParam("主键ids") List<Long> ids){ |
||||
|
log.debug("【图文平台后台】删除绘画风格参数为:{}", JSON.toJSONString(ids)); |
||||
|
return AjaxResult.success(paintStyleService.delete(ids)); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value="查询绘画风格详情") |
||||
|
@GetMapping(value = "/details/{id}") |
||||
|
public AjaxResult detailsPaintStyle(@PathVariable @ApiParam("主键id") Long id){ |
||||
|
log.debug("【图文平台后台】查询绘画风格详情参数为:{}", id); |
||||
|
return AjaxResult.success(paintStyleService.queryDetails(id)); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:paintStyle:edit") |
||||
|
@ApiOperation(value="变更显示状态") |
||||
|
@PostMapping(value = "/changeStatus") |
||||
|
public AjaxResult changeStatus(@Validated @RequestBody @ApiParam("显示状态对象") StatusDto dto){ |
||||
|
log.debug("【图文平台后台】变更显示状态参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(paintStyleService.changeStatus(dto.getId(),dto.getStatus())); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:paintStyle:edit") |
||||
|
@ApiOperation(value="变更是否热门状态") |
||||
|
@PostMapping(value = "/changeHot") |
||||
|
public AjaxResult changeHot(@Validated @RequestBody @ApiParam("热门状态对象") StatusDto dto){ |
||||
|
log.debug("【图文平台后台】变更是否热门参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(paintStyleService.changeHot(dto.getId(),dto.getStatus())); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,79 @@ |
|||||
|
package com.bnyer.system.controller; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import com.bnyer.common.core.dto.PromptDto; |
||||
|
import com.bnyer.common.core.dto.PromptPageDto; |
||||
|
import com.bnyer.common.core.dto.StatusDto; |
||||
|
import com.bnyer.common.core.web.controller.BaseController; |
||||
|
import com.bnyer.common.core.web.domain.AjaxResult; |
||||
|
import com.bnyer.common.core.web.page.TableDataInfo; |
||||
|
import com.bnyer.common.security.annotation.RequiresPermissions; |
||||
|
import com.bnyer.system.service.IPromptService; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Api(value = "【图文平台】提示词接口",tags = "【图文平台】提示词接口") |
||||
|
@RestController |
||||
|
@RequestMapping("/img/prompt") |
||||
|
@Slf4j |
||||
|
public class PromptController extends BaseController { |
||||
|
|
||||
|
@Autowired |
||||
|
private IPromptService promptService; |
||||
|
|
||||
|
@ApiOperation(value="查询提示词分页") |
||||
|
@PostMapping("/page") |
||||
|
public TableDataInfo pagePrompt(@RequestBody @ApiParam("分页对象") PromptPageDto dto){ |
||||
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); |
||||
|
List<Prompt> prompts = promptService.queryPage(dto); |
||||
|
return getDataTable(prompts); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:prompt:add") |
||||
|
@ApiOperation(value="新增提示词") |
||||
|
@PostMapping(value = "/insert") |
||||
|
public AjaxResult insertPrompt(@Validated @RequestBody @ApiParam("提示词对象") PromptDto dto){ |
||||
|
log.debug("【图文平台后台】新增提示词参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(promptService.insert(dto.extractParam())); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:prompt:edit") |
||||
|
@ApiOperation(value="修改提示词") |
||||
|
@PostMapping(value = "/update") |
||||
|
public AjaxResult updatePrompt(@Validated @RequestBody @ApiParam("提示词对象") PromptDto dto){ |
||||
|
log.debug("【图文平台后台】修改prompt参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(promptService.update(dto.extractParam())); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:prompt:delete") |
||||
|
@ApiOperation(value="删除提示词") |
||||
|
@DeleteMapping(value = "/delete/{ids}") |
||||
|
public AjaxResult deletePrompt(@PathVariable @ApiParam("主键ids") List<Long> ids){ |
||||
|
log.debug("【图文平台后台】删除提示词参数为:{}", JSON.toJSONString(ids)); |
||||
|
return AjaxResult.success(promptService.delete(ids)); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation(value="查询提示词详情") |
||||
|
@GetMapping(value = "/details/{id}") |
||||
|
public AjaxResult detailsPrompt(@PathVariable @ApiParam("主键id") Long id){ |
||||
|
log.debug("【图文平台后台】查询提示词详情参数为:{}", id); |
||||
|
return AjaxResult.success(promptService.queryDetails(id)); |
||||
|
} |
||||
|
|
||||
|
@RequiresPermissions("img:prompt:edit") |
||||
|
@ApiOperation(value="变更type显示状态") |
||||
|
@PostMapping(value = "/changeStatus") |
||||
|
public AjaxResult changeStatus(@Validated @RequestBody @ApiParam("type状态对象") StatusDto dto){ |
||||
|
log.debug("【图文平台后台】变更type参数为:{}", JSON.toJSONString(dto)); |
||||
|
return AjaxResult.success(promptService.changeStatus(dto.getId(),dto.getStatus())); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.bnyer.system.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface PaintStyleMapper extends BaseMapper<PaintStyle> { |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.bnyer.system.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface PromptMapper extends BaseMapper<Prompt> { |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
package com.bnyer.system.service; |
||||
|
|
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.common.core.dto.PaintStylePageDto; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface IPaintStyleService { |
||||
|
|
||||
|
/** |
||||
|
* 新增绘画风格 |
||||
|
* @param paintStyle 绘画风格 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int insert(PaintStyle paintStyle); |
||||
|
|
||||
|
/** |
||||
|
* 修改绘画风格 |
||||
|
* @param paintStyle 绘画风格 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int update(PaintStyle paintStyle); |
||||
|
|
||||
|
/** |
||||
|
* 删除绘画风格 |
||||
|
* @param ids 主键ids |
||||
|
* @return - |
||||
|
*/ |
||||
|
int delete(List<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 查询绘画风格分页 |
||||
|
* @param params 分页参数 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<PaintStyle> queryPage(PaintStylePageDto params); |
||||
|
|
||||
|
/** |
||||
|
* 获取绘画风格详情 |
||||
|
* @param id 主键id |
||||
|
* @return - |
||||
|
*/ |
||||
|
PaintStyle queryDetails(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 变更显示状态 |
||||
|
* @param id 主键id |
||||
|
* @param status 状态 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int changeStatus(Long id, String status); |
||||
|
|
||||
|
/** |
||||
|
* 变更热门状态 |
||||
|
* @param id 主键id |
||||
|
* @param status 状态 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int changeHot(Long id, String status); |
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
package com.bnyer.system.service; |
||||
|
|
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import com.bnyer.common.core.dto.PromptPageDto; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface IPromptService { |
||||
|
|
||||
|
/** |
||||
|
* 新增提示词 |
||||
|
* @param prompt 提示词 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int insert(Prompt prompt); |
||||
|
|
||||
|
/** |
||||
|
* 更新提示词 |
||||
|
* @param prompt 提示词 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int update(Prompt prompt); |
||||
|
|
||||
|
/** |
||||
|
* 删除提示词 |
||||
|
* @param ids id列表 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int delete(List<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 变更显示状态 |
||||
|
* @param id 主键id |
||||
|
* @param status 状态 |
||||
|
* @return - |
||||
|
*/ |
||||
|
int changeStatus(Long id, String status); |
||||
|
|
||||
|
/** |
||||
|
* 查询提示词分页 |
||||
|
* @param params 分页参数 |
||||
|
* @return - |
||||
|
*/ |
||||
|
List<Prompt> queryPage(PromptPageDto params); |
||||
|
|
||||
|
/** |
||||
|
* 获取提示词详情 |
||||
|
* @param id 主键id |
||||
|
* @return - |
||||
|
*/ |
||||
|
Prompt queryDetails(Long id); |
||||
|
} |
||||
@ -0,0 +1,85 @@ |
|||||
|
package com.bnyer.system.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.bnyer.common.core.domain.PaintStyle; |
||||
|
import com.bnyer.common.core.dto.PaintStylePageDto; |
||||
|
import com.bnyer.common.core.utils.StringUtils; |
||||
|
import com.bnyer.system.mapper.PaintStyleMapper; |
||||
|
import com.bnyer.system.service.IPaintStyleService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class PaintStyleServiceImpl implements IPaintStyleService { |
||||
|
|
||||
|
@Autowired |
||||
|
private PaintStyleMapper paintStyleMapper; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int insert(PaintStyle paintStyle) { |
||||
|
paintStyle.setCreateTime(new Date()); |
||||
|
paintStyle.setUpdateTime(new Date()); |
||||
|
paintStyle.setIsShow("1"); |
||||
|
return paintStyleMapper.insert(paintStyle); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int update(PaintStyle paintStyle) { |
||||
|
paintStyle.setUpdateTime(new Date()); |
||||
|
return paintStyleMapper.updateById(paintStyle); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int delete(List<Long> ids) { |
||||
|
return paintStyleMapper.deleteBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<PaintStyle> queryPage(PaintStylePageDto params) { |
||||
|
LambdaQueryWrapper<PaintStyle> wrapper = new LambdaQueryWrapper<>(); |
||||
|
if(StringUtils.isNotEmpty(params.getName())){ |
||||
|
wrapper.like(PaintStyle::getName, params.getName()); |
||||
|
} |
||||
|
if(StringUtils.isNotEmpty(params.getIsShow())){ |
||||
|
wrapper.eq(PaintStyle::getIsShow, params.getIsShow()); |
||||
|
} |
||||
|
if(StringUtils.isNotEmpty(params.getIsHot())){ |
||||
|
wrapper.eq(PaintStyle::getIsHot, params.getIsHot()); |
||||
|
} |
||||
|
wrapper.orderByDesc(PaintStyle::getSort); |
||||
|
return paintStyleMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PaintStyle queryDetails(Long id) { |
||||
|
return paintStyleMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int changeStatus(Long id, String status) { |
||||
|
LambdaUpdateWrapper<PaintStyle> wrapper = new LambdaUpdateWrapper<>(); |
||||
|
wrapper.eq(PaintStyle::getId, id); |
||||
|
PaintStyle paintStyle = new PaintStyle(); |
||||
|
paintStyle.setIsShow(status); |
||||
|
return paintStyleMapper.update(paintStyle,wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int changeHot(Long id, String status) { |
||||
|
LambdaUpdateWrapper<PaintStyle> wrapper = new LambdaUpdateWrapper<>(); |
||||
|
wrapper.eq(PaintStyle::getId, id); |
||||
|
PaintStyle paintStyle = new PaintStyle(); |
||||
|
paintStyle.setIsHot(status); |
||||
|
return paintStyleMapper.update(paintStyle,wrapper); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
package com.bnyer.system.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.bnyer.common.core.domain.Prompt; |
||||
|
import com.bnyer.common.core.dto.PromptPageDto; |
||||
|
import com.bnyer.common.core.utils.StringUtils; |
||||
|
import com.bnyer.system.mapper.PromptMapper; |
||||
|
import com.bnyer.system.service.IPromptService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class PromptServiceImpl implements IPromptService { |
||||
|
|
||||
|
@Autowired |
||||
|
private PromptMapper promptMapper; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int insert(Prompt prompt) { |
||||
|
prompt.setCreateTime(new Date()); |
||||
|
prompt.setUpdateTime(new Date()); |
||||
|
prompt.setIsShow("1"); |
||||
|
prompt.setSort(0); |
||||
|
return promptMapper.insert(prompt); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int update(Prompt prompt) { |
||||
|
prompt.setUpdateTime(new Date()); |
||||
|
return promptMapper.updateById(prompt); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int delete(List<Long> ids) { |
||||
|
return promptMapper.deleteBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public int changeStatus(Long id, String status) { |
||||
|
LambdaUpdateWrapper<Prompt> wrapper = new LambdaUpdateWrapper<>(); |
||||
|
wrapper.eq(Prompt::getId, id); |
||||
|
Prompt prompt = new Prompt(); |
||||
|
prompt.setIsShow(status); |
||||
|
return promptMapper.update(prompt,wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Prompt> queryPage(PromptPageDto params) { |
||||
|
LambdaQueryWrapper<Prompt> wrapper = new LambdaQueryWrapper<>(); |
||||
|
if(StringUtils.isNotEmpty(params.getType())){ |
||||
|
wrapper.eq(Prompt::getType, params.getType()); |
||||
|
} |
||||
|
if(StringUtils.isNotEmpty(params.getIsShow())){ |
||||
|
wrapper.eq(Prompt::getIsShow, params.getIsShow()); |
||||
|
} |
||||
|
if(StringUtils.isNotEmpty(params.getText())){ |
||||
|
wrapper.like(Prompt::getText, params.getText()); |
||||
|
} |
||||
|
wrapper.orderByDesc(Prompt::getSort); |
||||
|
return promptMapper.selectList(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Prompt queryDetails(Long id) { |
||||
|
return promptMapper.selectById(id); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue