mirror of https://gitee.com/stylefeng/roses
标题图片管理
parent
bec3356659
commit
3397662754
|
@ -24,6 +24,7 @@
|
|||
<module>system-business-role</module>
|
||||
<module>system-business-menu</module>
|
||||
<module>system-business-notice</module>
|
||||
<module>system-business-title</module>
|
||||
<module>system-integration-beetl</module>
|
||||
<module>system-integration-rest</module>
|
||||
<module>system-spring-boot-starter</module>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package cn.stylefeng.roses.kernel.system.api;
|
||||
|
||||
/**
|
||||
* 标题图片配置api
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:20
|
||||
*/
|
||||
public interface TitleServiceApi {
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package cn.stylefeng.roses.kernel.system.api.exception.enums.title;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.constants.SystemConstants;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum SysTitleExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 标题图片配置不存在
|
||||
*/
|
||||
TITLE_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "101", "标题图片配置不存在,id为:{}"),
|
||||
|
||||
/**
|
||||
* 启用的配置不允许被删除
|
||||
*/
|
||||
ENABLE_NOT_ALLOW_DELETE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "102", "启用的配置不允许被删除,id为:{}"),
|
||||
|
||||
/**
|
||||
* 未启用的配置不允许被编辑
|
||||
*/
|
||||
DISABLE_NOT_ALLOW_EDIT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "103", "未启用的配置不允许被编辑,id为:{}"),
|
||||
|
||||
/**
|
||||
* 唯一启用的配置不允许被删除
|
||||
*/
|
||||
UNIQUE_ENABLE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "104", "唯一启用的配置不允许禁用,id为:{}");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
SysTitleExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package cn.stylefeng.roses.kernel.system.api.pojo.title;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.field.ChineseDescription;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 标题图片配置信息参数
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:01
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysTitleRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 标题id
|
||||
*/
|
||||
@NotNull(message = "titleId不能为空", groups = {edit.class, delete.class, detail.class})
|
||||
@ChineseDescription("标题id")
|
||||
private Long titleId;
|
||||
|
||||
/**
|
||||
* 标题名称
|
||||
*/
|
||||
@NotNull(message = "标题名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("标题名称")
|
||||
private String titleName;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@NotNull(message = "公司名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("公司名称")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@NotNull(message = "平台名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("平台名称")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台英文名称
|
||||
*/
|
||||
@NotNull(message = "平台英文名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("平台英文名称")
|
||||
private String platformEnglishName;
|
||||
|
||||
/**
|
||||
* 背景图片
|
||||
*/
|
||||
@NotNull(message = "背景图片不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("背景图片")
|
||||
private MultipartFile backgroundImage;
|
||||
|
||||
/**
|
||||
* 公司logo
|
||||
*/
|
||||
@NotNull(message = "公司logo不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("公司logo")
|
||||
private MultipartFile companyLogo;
|
||||
|
||||
/**
|
||||
* 浏览器icon
|
||||
*/
|
||||
@NotNull(message = "浏览器icon不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("浏览器icon")
|
||||
private MultipartFile browserIcon;
|
||||
|
||||
/**
|
||||
* 首页名称
|
||||
*/
|
||||
@NotNull(message = "首页名称不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("首页名称")
|
||||
private String pageName;
|
||||
|
||||
/**
|
||||
* 首页图标
|
||||
*/
|
||||
@NotNull(message = "首页图标不能为空", groups = {add.class, edit.class})
|
||||
@ChineseDescription("首页图标")
|
||||
private MultipartFile pageImage;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
标题图片管理
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kernel-s-system</artifactId>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<version>7.1.6</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>system-business-title</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!--系统管理的api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--参数校验模块-->
|
||||
<!--用在控制器,参数校验-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>validator-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库sdk-->
|
||||
<!--数据库dao框架-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>db-sdk-mp</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--web模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>file-business</artifactId>
|
||||
<version>7.1.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,100 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.title.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.title.SysTitleRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.entity.SysTitle;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.service.SysTitleService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 标题图片配置管理控制器
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:29
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "标题图片配置管理")
|
||||
public class SysTitleController {
|
||||
|
||||
@Resource
|
||||
private SysTitleService sysTitleService;
|
||||
|
||||
/**
|
||||
* 添加标题图片配置
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 9:26
|
||||
*/
|
||||
@PostResource(name = "添加标题图片配置", path = "/sysTitle/add")
|
||||
public ResponseData add(@RequestBody @Validated(SysTitleRequest.add.class) SysTitleRequest sysTitleParam) {
|
||||
sysTitleService.add(sysTitleParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标题图片配置
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 9:28
|
||||
*/
|
||||
@PostResource(name = "删除标题图片配置", path = "/sysTitle/del")
|
||||
public ResponseData del(@RequestBody @Validated(SysTitleRequest.delete.class) SysTitleRequest sysTitleParam) {
|
||||
sysTitleService.del(sysTitleParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标题图片配置
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 9:53
|
||||
*/
|
||||
@PostResource(name = "修改标题图片配置", path = "/sysTitle/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(SysTitleRequest.edit.class) SysTitleRequest sysTitleParam) {
|
||||
sysTitleService.edit(sysTitleParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称查询标题图片配置
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 10:26
|
||||
*/
|
||||
@GetResource(name = "查询标题图片配置", path = "/sysTitle/find", responseClass = SysTitle.class)
|
||||
public ResponseData findPage(SysTitleRequest sysTitleParam) {
|
||||
return new SuccessResponseData(sysTitleService.findPage(sysTitleParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制标题
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 11:29
|
||||
*/
|
||||
@PostResource(name = "复制标题", path = "/sysTitle/copy")
|
||||
public ResponseData copyTitle(@RequestBody @Validated(SysTitleRequest.add.class) SysTitleRequest sysTitleRequest) {
|
||||
sysTitleService.copyTitle(sysTitleRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改启用状态
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 11:43
|
||||
*/
|
||||
@PostResource(name = "修改启用状态", path = "/sysTitle/updateStatus")
|
||||
public ResponseData updateStatus(@RequestBody @Validated(SysTitleRequest.edit.class) SysTitleRequest sysTitleRequest) {
|
||||
sysTitleService.updateStatus(sysTitleRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.title.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.field.ChineseDescription;
|
||||
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 lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 标题图片配置信息表
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 15:49
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("sys_title")
|
||||
public class SysTitle extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 标题id
|
||||
*/
|
||||
@TableId(value = "title_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("标题id")
|
||||
private Long titleId;
|
||||
|
||||
/**
|
||||
* 标题名称
|
||||
*/
|
||||
@TableField("title_name")
|
||||
@ChineseDescription("标题名称")
|
||||
private String titleName;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@TableField("company_name")
|
||||
@ChineseDescription("公司名称")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@TableField("platform_name")
|
||||
@ChineseDescription("平台名称")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 平台英文名称
|
||||
*/
|
||||
@TableField("platform_english_name")
|
||||
@ChineseDescription("平台英文名称")
|
||||
private String platformEnglishName;
|
||||
|
||||
/**
|
||||
* 背景图片
|
||||
*/
|
||||
@TableField("background_image")
|
||||
@ChineseDescription("背景图片")
|
||||
private String backgroundImage;
|
||||
|
||||
/**
|
||||
* 公司logo
|
||||
*/
|
||||
@TableField("company_logo")
|
||||
@ChineseDescription("公司logo")
|
||||
private String companyLogo;
|
||||
|
||||
/**
|
||||
* 浏览器icon
|
||||
*/
|
||||
@TableField("browser_icon")
|
||||
@ChineseDescription("浏览器icon")
|
||||
private String browserIcon;
|
||||
|
||||
/**
|
||||
* 首页名称
|
||||
*/
|
||||
@TableField("page_name")
|
||||
@ChineseDescription("首页名称")
|
||||
private String pageName;
|
||||
|
||||
/**
|
||||
* 首页图标
|
||||
*/
|
||||
@TableField("page_image")
|
||||
@ChineseDescription("首页图标")
|
||||
private String pageImage;
|
||||
|
||||
/**
|
||||
* 启用状态:Y、启用 N、未启用
|
||||
*/
|
||||
@TableField("status")
|
||||
@ChineseDescription("启用状态")
|
||||
private Character status;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.title.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.entity.SysTitle;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 标题图片基本信息mapper接口
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 16:37
|
||||
*/
|
||||
public interface SysTitleMapper extends BaseMapper<SysTitle> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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="cn.stylefeng.roses.kernel.system.modular.title.mapper.SysTitleMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,80 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.title.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.system.api.TitleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.title.SysTitleRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.entity.SysTitle;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 标题图片配置服务类
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:22
|
||||
*/
|
||||
public interface SysTitleService extends IService<SysTitle>, TitleServiceApi {
|
||||
|
||||
/**
|
||||
* 添加标题图片配置
|
||||
*
|
||||
* @param sysTitleRequest 添加参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:45
|
||||
*/
|
||||
void add(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 删除标题图片配置
|
||||
*
|
||||
* @param sysTitleRequest 删除参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 18:39
|
||||
*/
|
||||
void del(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 修改标题图片配置
|
||||
*
|
||||
* @param sysTitleRequest 修改参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 9:32
|
||||
*/
|
||||
void edit(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 查询单个标题配置信息
|
||||
*
|
||||
* @param sysTitleRequest 查询参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 11:38
|
||||
*/
|
||||
SysTitle detail(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 查询标题列表
|
||||
*
|
||||
* @param sysTitleRequest 查询参数
|
||||
* @return 查询分页结果
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 10:00
|
||||
*/
|
||||
PageResult<SysTitle> findPage(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 复制标题
|
||||
*
|
||||
* @param sysTitleRequest 复制参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 10:47
|
||||
*/
|
||||
void copyTitle(SysTitleRequest sysTitleRequest);
|
||||
|
||||
/**
|
||||
* 修改启用状态
|
||||
*
|
||||
* @param sysTitleRequest 修改参数
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 11:32
|
||||
*/
|
||||
void updateStatus(SysTitleRequest sysTitleRequest);
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.title.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.request.SysFileInfoRequest;
|
||||
import cn.stylefeng.roses.kernel.file.api.pojo.response.SysFileInfoResponse;
|
||||
import cn.stylefeng.roses.kernel.file.modular.service.SysFileInfoService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.enums.title.SysTitleExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.title.SysTitleRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.entity.SysTitle;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.mapper.SysTitleMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.title.service.SysTitleService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 标题图片配置服务实现类
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/13 17:28
|
||||
*/
|
||||
@Service
|
||||
public class SysTitleServiceImpl extends ServiceImpl<SysTitleMapper, SysTitle> implements SysTitleService {
|
||||
|
||||
private static final Long DEFAULT_FILE_UPLOAD = null;
|
||||
|
||||
@Resource
|
||||
private SysFileInfoService sysFileInfoService;
|
||||
|
||||
@Override
|
||||
public void add(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = new SysTitle();
|
||||
|
||||
// 拷贝属性
|
||||
BeanUtil.copyProperties(sysTitleRequest, sysTitle);
|
||||
|
||||
// 启用状态默认为未启用 N
|
||||
sysTitle.setStatus(YesOrNotEnum.N.getCode().charAt(0));
|
||||
|
||||
// 保存图片信息
|
||||
SysFileInfoResponse backgroundImageResponse = this.uploadFile(sysTitleRequest.getBackgroundImage(), DEFAULT_FILE_UPLOAD);
|
||||
sysTitle.setBackgroundImage(backgroundImageResponse.getFileId().toString());
|
||||
SysFileInfoResponse browserIconResponse = this.uploadFile(sysTitleRequest.getBrowserIcon(), DEFAULT_FILE_UPLOAD);
|
||||
sysTitle.setBrowserIcon(browserIconResponse.getFileId().toString());
|
||||
SysFileInfoResponse companyLogoResponse = this.uploadFile(sysTitleRequest.getCompanyLogo(), DEFAULT_FILE_UPLOAD);
|
||||
sysTitle.setCompanyLogo(companyLogoResponse.getFileId().toString());
|
||||
SysFileInfoResponse pageImageResponse = this.uploadFile(sysTitleRequest.getPageImage(), DEFAULT_FILE_UPLOAD);
|
||||
sysTitle.setPageImage(pageImageResponse.getFileId().toString());
|
||||
|
||||
// 保存配置信息
|
||||
this.save(sysTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param multipartFile 上传的图片
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 14:40
|
||||
*/
|
||||
private SysFileInfoResponse uploadFile(MultipartFile multipartFile, Long fileCode) {
|
||||
SysFileInfoRequest sysFileInfoRequest = new SysFileInfoRequest();
|
||||
sysFileInfoRequest.setFileId(IdWorker.getId());
|
||||
if (fileCode != null) {
|
||||
sysFileInfoRequest.setFileCode(fileCode);
|
||||
}
|
||||
sysFileInfoRequest.setSecretFlag(YesOrNotEnum.N.getCode());
|
||||
sysFileInfoRequest.setFileLocation(4);
|
||||
sysFileInfoRequest.setFilePath("D:\\test");
|
||||
sysFileInfoRequest.setFileOriginName(multipartFile.getOriginalFilename());
|
||||
return sysFileInfoService.uploadFile(multipartFile, sysFileInfoRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = this.querySysTitleById(sysTitleRequest);
|
||||
|
||||
// 启用状态不允许删除
|
||||
if (Character.valueOf(YesOrNotEnum.Y.getCode().charAt(0)).equals(sysTitle.getStatus())) {
|
||||
throw new SystemModularException(SysTitleExceptionEnum.ENABLE_NOT_ALLOW_DELETE, sysTitleRequest.getTitleId());
|
||||
}
|
||||
|
||||
// 删除配置
|
||||
this.removeById(sysTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标题图片配置
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 9:18
|
||||
*/
|
||||
private SysTitle querySysTitleById(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = this.getById(sysTitleRequest.getTitleId());
|
||||
if (ObjectUtil.isEmpty(sysTitle)) {
|
||||
throw new SystemModularException(SysTitleExceptionEnum.TITLE_NOT_EXIST, sysTitleRequest.getTitleId());
|
||||
}
|
||||
return sysTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = this.querySysTitleById(sysTitleRequest);
|
||||
|
||||
// 未启用状态不允许编辑
|
||||
if (Character.valueOf(YesOrNotEnum.N.getCode().charAt(0)).equals(sysTitle.getStatus())) {
|
||||
throw new SystemModularException(SysTitleExceptionEnum.DISABLE_NOT_ALLOW_EDIT, sysTitleRequest.getTitleId());
|
||||
}
|
||||
|
||||
// 图片修改
|
||||
sysTitle.setBackgroundImage(this.updateFile(sysTitleRequest.getBackgroundImage(), sysTitle.getBackgroundImage()));
|
||||
sysTitle.setBrowserIcon(this.updateFile(sysTitleRequest.getBrowserIcon(), sysTitle.getBrowserIcon()));
|
||||
sysTitle.setCompanyLogo(this.updateFile(sysTitleRequest.getCompanyLogo(), sysTitle.getCompanyLogo()));
|
||||
sysTitle.setPageImage(this.updateFile(sysTitleRequest.getPageImage(), sysTitle.getPageImage()));
|
||||
|
||||
// 更新属性
|
||||
BeanUtil.copyProperties(sysTitleRequest, sysTitle);
|
||||
|
||||
// 修改配置
|
||||
this.updateById(sysTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新图片
|
||||
*
|
||||
* @param multipartFile 新图片
|
||||
* @param fileId 旧图片Id
|
||||
* @return 新图片Id
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 15:21
|
||||
*/
|
||||
private String updateFile(MultipartFile multipartFile, String fileId) {
|
||||
SysFileInfoResponse fileInfoResult = sysFileInfoService.getFileInfoResult(Long.parseLong(fileId));
|
||||
|
||||
// 上传图片
|
||||
SysFileInfoResponse sysFileInfoResponse = this.uploadFile(multipartFile, fileInfoResult.getFileCode());
|
||||
|
||||
return sysFileInfoResponse.getFileId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTitle detail(SysTitleRequest sysTitleRequest) {
|
||||
return this.querySysTitleById(sysTitleRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysTitle> findPage(SysTitleRequest sysTitleRequest) {
|
||||
LambdaQueryWrapper<SysTitle> wrapper = this.createWrapper(sysTitleRequest);
|
||||
Page<SysTitle> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Wrapper
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 10:04
|
||||
*/
|
||||
private LambdaQueryWrapper<SysTitle> createWrapper(SysTitleRequest sysTitleRequest) {
|
||||
LambdaQueryWrapper<SysTitle> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 按照创建时间倒序
|
||||
wrapper.orderByDesc(BaseEntity::getCreateTime);
|
||||
|
||||
// 如果标题不为空,根据标题名称模糊查询;如果标题为空,查询全部
|
||||
wrapper.like(StrUtil.isNotBlank(sysTitleRequest.getTitleName()), SysTitle::getTitleName, sysTitleRequest.getTitleName());
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTitle(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = this.querySysTitleById(sysTitleRequest);
|
||||
|
||||
SysTitle title = new SysTitle();
|
||||
// 拷贝属性
|
||||
BeanUtil.copyProperties(sysTitle, title);
|
||||
// 修改标题名称
|
||||
title.setTitleName(sysTitle.getTitleName() + "复制");
|
||||
// 标题状态设为默认状态 未启用 N
|
||||
title.setStatus(YesOrNotEnum.N.getCode().charAt(0));
|
||||
|
||||
// 保存配置信息
|
||||
this.save(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(SysTitleRequest sysTitleRequest) {
|
||||
SysTitle sysTitle = this.querySysTitleById(sysTitleRequest);
|
||||
|
||||
// 如果状态为唯一启用状态不允许被禁用, 如果为未启用状态则可以启用该配置同时禁用已启用的标题配置
|
||||
if (Character.valueOf(YesOrNotEnum.Y.getCode().charAt(0)).equals(sysTitle.getStatus())) {
|
||||
throw new SystemModularException(SysTitleExceptionEnum.UNIQUE_ENABLE, sysTitleRequest.getTitleId());
|
||||
} else {
|
||||
// 设置为启用状态
|
||||
sysTitle.setStatus(YesOrNotEnum.Y.getCode().charAt(0));
|
||||
// 修改已启用的标题配置
|
||||
if (this.updateEnableToDisableStatus()) {
|
||||
updateById(sysTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改已启用的标题配置为禁用状态
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2021/12/14 14:00
|
||||
*/
|
||||
private Boolean updateEnableToDisableStatus() {
|
||||
// 查询已启用的标题配置
|
||||
LambdaQueryWrapper<SysTitle> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysTitle::getStatus, YesOrNotEnum.Y.getCode().charAt(0));
|
||||
SysTitle sysTitle = getOne(wrapper);
|
||||
|
||||
// 修改状态
|
||||
sysTitle.setStatus(YesOrNotEnum.N.getCode().charAt(0));
|
||||
return updateById(sysTitle);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue