xiaoyong931011
2022-06-15 6c82b0f944a0d3547659db5ec1f640a9ec7d3fd3
20220606
13 files added
14 files modified
577 ■■■■■ changed files
pom.xml 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/configurations/security/WebSecurityConfig.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/config/KaptchaConfig.java 46 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminCommonController.java 9 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminMessageBoardController.java 49 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddMessageDto.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminLoginDto.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminMessageBoardDto.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/entity/MessageBoardEntity.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/entity/ValidateCodeProperties.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/mapper/MessageBoardMapper.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/ICommonService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/IMessageBoardService.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CommonServiceImpl.java 55 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MessageBoardServiceImpl.java 98 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/UserServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/util/CaptchaUtil.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/util/UUIDUtil.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminMessageBoardVo.java 32 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 2 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/ArticleMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/ColumnMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/MessageBoardMapper.xml 25 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/NavigationBarMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/RoleMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/UserMapper.xml 4 ●●●● patch | view | raw | blame | history
pom.xml
@@ -30,6 +30,13 @@
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.github.penggle</groupId>
            <artifactId>kaptcha</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
src/main/java/com/xcong/farmer/cms/configurations/security/WebSecurityConfig.java
@@ -43,8 +43,10 @@
                .antMatchers("/webjars/**").permitAll()
                .antMatchers("/v2/**").permitAll()
                .antMatchers("/api/common/login").permitAll()
                .antMatchers("/api/common/captcha").permitAll()
                .antMatchers("/api/common/doUpload").permitAll()
                .antMatchers("/api/common/uploadFile").permitAll()
                .antMatchers("/api/messageBoard/addMessage").permitAll()
                .antMatchers("/image/**").permitAll()
                .anyRequest().authenticated()
                .and().apply(securityConfiguereAdapter());
src/main/java/com/xcong/farmer/cms/modules/system/config/KaptchaConfig.java
New file
@@ -0,0 +1,46 @@
package com.xcong.farmer.cms.modules.system.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
@Configuration
public class KaptchaConfig {
    @Bean
    public DefaultKaptcha producer() {
        //Properties类
        Properties properties = new Properties();
        // 图片边框
        properties.setProperty("kaptcha.border", "no");
        // 边框颜色
//        properties.setProperty("kaptcha.border.color", "105,179,90");
        // 字体颜色
        properties.setProperty("kaptcha.textproducer.font.color", "black");
        // 图片宽
        properties.setProperty("kaptcha.image.width", "160");
        // 图片高
        properties.setProperty("kaptcha.image.height", "58");
        // 文字间隔
        properties.setProperty("kaptcha.textproducer.font.space", "5");
        // 字体大小
        properties.setProperty("kaptcha.textproducer.font.size", "38");
        // session key
        properties.setProperty("kaptcha.session.key", "code");
        // 验证码长度
        properties.setProperty("kaptcha.textproducer.char.length", "4");
        // 字体
        properties.setProperty("kaptcha.textproducer.font.names", "Arial, Courier");
        //图片干扰
//        properties.setProperty("kaptcha.noise.impl","com.google.code.kaptcha.impl.DefaultNoise");
        //去除Kaptcha方法得到验证码的干扰线
        properties.setProperty("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
        //Kaptcha 使用上述配置
        Config config = new Config(properties);
        //DefaultKaptcha对象使用上述配置, 并返回这个Bean
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminCommonController.java
@@ -1,7 +1,6 @@
package com.xcong.farmer.cms.modules.system.controller;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.xcong.farmer.cms.common.contants.AppContants;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminLoginDto;
@@ -18,6 +17,8 @@
import java.io.File;
import java.io.IOException;
import java.util.Map;
@RestController
@RequestMapping(value = "/api/common")
@@ -34,6 +35,12 @@
        return iCommonService.login(adminLoginDto);
    }
    @ApiOperation(value = "获取验证码", notes = "获取验证码")
    @GetMapping("/captcha")
    public Result captcha() throws IOException {
        return iCommonService.captchaCreator();
    }
    /**
     * 用户退出登录
     * @return
src/main/java/com/xcong/farmer/cms/modules/system/controller/AdminMessageBoardController.java
New file
@@ -0,0 +1,49 @@
package com.xcong.farmer.cms.modules.system.controller;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminAddMessageDto;
import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
import com.xcong.farmer.cms.modules.system.dto.AdminMessageBoardDto;
import com.xcong.farmer.cms.modules.system.service.IMessageBoardService;
import com.xcong.farmer.cms.modules.system.vo.AdminMessageBoardVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@RestController
@RequestMapping(value = "/api/messageBoard")
@Slf4j
@Api(value = "留言板", tags = "留言板")
public class AdminMessageBoardController {
    @Resource
    private IMessageBoardService iMessageBoardService;
    @ApiOperation(value = "留言板分页列表", notes = "留言板分页列表")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = AdminMessageBoardVo.class)})
    @PostMapping(value = "/messageInPage")
    public Result getMessageInPage(@RequestBody @Valid AdminMessageBoardDto adminMessageBoardDto) {
        return iMessageBoardService.getMessageInPage(adminMessageBoardDto);
    }
    @ApiOperation(value = "删除留言", notes = "删除留言")
    @PostMapping(value = "/delObjs")
    public Result delObjs(@RequestBody @Valid AdminDeleteDto adminDeleteDto) {
        return iMessageBoardService.delObjs(adminDeleteDto);
    }
    @ApiOperation(value = "新增留言", notes = "新增留言")
    @PostMapping(value = "/addMessage")
    public Result addMessage(HttpServletRequest request,@RequestBody @Valid AdminAddMessageDto adminAddMessageDto) {
        return iMessageBoardService.addMessage(request,adminAddMessageDto);
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminAddMessageDto.java
New file
@@ -0,0 +1,35 @@
package com.xcong.farmer.cms.modules.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "AdminAddMessageDto", description = "参数接收类")
public class AdminAddMessageDto {
    @ApiModelProperty(value = "姓名")
    @NotNull(message = "请输入姓名")
    private String name;
    @ApiModelProperty(value = "联系方式")
    @NotNull(message = "请输入联系方式")
    private String contactValue;
    @ApiModelProperty(value = "留言标题")
    @NotNull(message = "请输入留言标题")
    private String title;
    @ApiModelProperty(value = "留言描述")
    @NotNull(message = "请输入留言描述")
    private String remark;
    @ApiModelProperty(value = "备注1")
    private String paramOne;
    @ApiModelProperty(value = "备注2")
    private String paramTwo;
}
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminLoginDto.java
@@ -15,4 +15,11 @@
    @NotBlank(message = "请输入密码")
    private String password;
    private String codeToken;
    @NotBlank(message = "请输入验证码")
    private String codeValue;
}
src/main/java/com/xcong/farmer/cms/modules/system/dto/AdminMessageBoardDto.java
New file
@@ -0,0 +1,19 @@
package com.xcong.farmer.cms.modules.system.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "AdminMessageBoardDto", description = "参数接收类")
public class AdminMessageBoardDto {
    @ApiModelProperty(value = "查询条件", example = "张三")
    private String queryKey;
    @ApiModelProperty(value = "每页条数", example = "10")
    private Integer pageSize;
    @ApiModelProperty(value = "第几页", example = "1")
    private Integer pageNum;
}
src/main/java/com/xcong/farmer/cms/modules/system/entity/MessageBoardEntity.java
New file
@@ -0,0 +1,34 @@
package com.xcong.farmer.cms.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Data;
/**
 * 留言板表
 */
@Data
@TableName("t_message_board")
public class MessageBoardEntity {
    //ID
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    //姓名
    private String name;
    //联系方式
    private String contactValue;
    //留言标题
    private String title;
    //留言描述
    private String remark;
    //所属公司ID
    private Long companyId;
    //创建时间
    private Date createTime;
    private String paramOne;
    private String paramTwo;
}
src/main/java/com/xcong/farmer/cms/modules/system/entity/ValidateCodeProperties.java
New file
@@ -0,0 +1,35 @@
package com.xcong.farmer.cms.modules.system.entity;
import lombok.Data;
@Data
public class ValidateCodeProperties {
    /**
     * 验证码有效时间,单位秒
     */
    private Long time = 120L;
    /**
     * 验证码类型,可选值 png和 gif
     */
    private String type = "png";
    /**
     * 图片宽度,px
     */
    private Integer width = 130;
    /**
     * 图片高度,px
     */
    private Integer height = 48;
    /**
     * 验证码位数
     */
    private Integer length = 4;
    /**
     * 验证码值的类型
     * 1. 数字加字母
     * 2. 纯数字
     * 3. 纯字母
     */
    private Integer charType = 2;
}
src/main/java/com/xcong/farmer/cms/modules/system/mapper/MessageBoardMapper.java
New file
@@ -0,0 +1,13 @@
package com.xcong.farmer.cms.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xcong.farmer.cms.modules.system.entity.MessageBoardEntity;
import com.xcong.farmer.cms.modules.system.vo.AdminMessageBoardVo;
import org.apache.ibatis.annotations.Param;
public interface MessageBoardMapper extends BaseMapper<MessageBoardEntity> {
    IPage<AdminMessageBoardVo> selectAdminMessageBoardInPage(Page<AdminMessageBoardVo> page, @Param("record") MessageBoardEntity messageBoardEntity);
}
src/main/java/com/xcong/farmer/cms/modules/system/service/ICommonService.java
@@ -4,10 +4,17 @@
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminLoginDto;
import com.xcong.farmer.cms.modules.system.entity.UserEntity;
import java.io.IOException;
import java.util.Map;
public interface ICommonService  extends IService<UserEntity> {
    Result login(AdminLoginDto adminLoginDto);
    Result memberLogout();
    //生成token
    Map<String, Object> createToken(String captcha);
    //生成captcha验证码
    Result captchaCreator() throws IOException;
}
src/main/java/com/xcong/farmer/cms/modules/system/service/IMessageBoardService.java
New file
@@ -0,0 +1,19 @@
package com.xcong.farmer.cms.modules.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminAddMessageDto;
import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
import com.xcong.farmer.cms.modules.system.dto.AdminMessageBoardDto;
import com.xcong.farmer.cms.modules.system.entity.MessageBoardEntity;
import javax.servlet.http.HttpServletRequest;
public interface IMessageBoardService extends IService<MessageBoardEntity> {
    Result getMessageInPage(AdminMessageBoardDto adminMessageBoardDto);
    Result delObjs(AdminDeleteDto adminDeleteDto);
    Result addMessage(HttpServletRequest request, AdminAddMessageDto adminAddMessageDto);
}
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -133,10 +133,7 @@
            return Result.fail("文章不存在");
        }
        Integer releaseStatus = adminUpdateArticleDto.getReleaseStatus();
        if(!ArticleEntity.RELEASE_STATUS_YES.equals(releaseStatus)){
            return Result.fail("请先取消文章的发布状态");
        }
        articleEntity.getReleaseStatus();
        articleEntity.setReleaseStatus(releaseStatus);
        String title = adminUpdateArticleDto.getTitle();
        articleEntity.setTitle(title);
        String childTitle = adminUpdateArticleDto.getChildTitle();
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CommonServiceImpl.java
@@ -8,17 +8,24 @@
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.configurations.properties.ApplicationProperties;
import com.xcong.farmer.cms.configurations.properties.SecurityProperties;
import com.xcong.farmer.cms.modules.member.entity.MemberEntity;
import com.xcong.farmer.cms.modules.system.dto.AdminLoginDto;
import com.xcong.farmer.cms.modules.system.entity.UserEntity;
import com.xcong.farmer.cms.modules.system.mapper.UserMapper;
import com.xcong.farmer.cms.modules.system.service.ICommonService;
import com.xcong.farmer.cms.modules.system.util.CaptchaUtil;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
import com.xcong.farmer.cms.utils.MessageSourceUtils;
import com.xcong.farmer.cms.modules.system.util.UUIDUtil;
import com.xcong.farmer.cms.utils.RedisUtils;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -40,9 +47,33 @@
    private ApplicationProperties applicationProperties;
    @Resource
    private SecurityProperties securityProperties;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    @Autowired
    private UUIDUtil uuidUtil;
    @Autowired
    private CaptchaUtil captchaUtil;
    //从SpringBoot的配置文件中取出过期时间
    @Value("${server.servlet.session.timeout}")
    private Integer timeout;
    @Override
    public Result login(AdminLoginDto adminLoginDto) {
        //根据前端传回的token在redis中找对应的value
        ValueOperations<String, Object> valueOperations = redisTemplate.opsForValue();
        String codeToken = adminLoginDto.getCodeToken();
        String codeValue = adminLoginDto.getCodeValue();
        if (redisTemplate.hasKey(codeToken)) {
            //验证通过, 删除对应的key
            if (valueOperations.get(codeToken).equals(codeValue)) {
                redisTemplate.delete(codeToken);
            } else {
                return Result.fail("请输入正确验证码");
            }
        } else {
            return Result.fail("验证码已过期,请刷新当前页面");
        }
        String username = adminLoginDto.getUsername();
        String password = adminLoginDto.getPassword();
        UserEntity userEntity = userMapper.selectByUserNameAndPassword(username, SecureUtil.md5(password));
@@ -93,6 +124,26 @@
        return Result.ok("退出成功");
    }
    @Override
    public Map<String, Object> createToken(String captcha) {
        //生成一个token
        String key = uuidUtil.getUUID32();
        //生成验证码对应的token  以token为key  验证码为value存在redis中
        ValueOperations<String, Object> valueOperations = redisTemplate.opsForValue();
        valueOperations.set(key, captcha);
        //设置验证码过期时间
        redisTemplate.expire(key, timeout, TimeUnit.MINUTES);
        Map<String, Object> map = new HashMap<>();
        map.put("token", key);
        map.put("expire", timeout);
        return map;
    }
    @Override
    public Result captchaCreator() throws IOException {
        return captchaUtil.catchaImgCreator();
    }
    public String generateAsaToken(String token) {
        RSA rsa = new RSA(null, securityProperties.getPublicKey());
        return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey);
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/MessageBoardServiceImpl.java
New file
@@ -0,0 +1,98 @@
package com.xcong.farmer.cms.modules.system.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminAddMessageDto;
import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
import com.xcong.farmer.cms.modules.system.dto.AdminMessageBoardDto;
import com.xcong.farmer.cms.modules.system.entity.CompanyEntity;
import com.xcong.farmer.cms.modules.system.entity.MessageBoardEntity;
import com.xcong.farmer.cms.modules.system.entity.UserEntity;
import com.xcong.farmer.cms.modules.system.mapper.CompanyMapper;
import com.xcong.farmer.cms.modules.system.mapper.MessageBoardMapper;
import com.xcong.farmer.cms.modules.system.service.IMessageBoardService;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
import com.xcong.farmer.cms.modules.system.vo.AdminMessageBoardVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.collection.CollUtil;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
@Slf4j
public class MessageBoardServiceImpl extends ServiceImpl<MessageBoardMapper, MessageBoardEntity> implements IMessageBoardService {
    @Resource
    private CompanyMapper companyMapper;
    @Override
    public Result getMessageInPage(AdminMessageBoardDto adminMessageBoardDto) {
        MessageBoardEntity messageBoardEntity = new MessageBoardEntity();
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        Long companyId = userlogin.getCompanyId();
        if(UserEntity.USER_BELONG_TOP != companyId){
            messageBoardEntity.setCompanyId(companyId);
        }
        String queryKey = adminMessageBoardDto.getQueryKey();
        if(StrUtil.isNotEmpty(queryKey)){
            messageBoardEntity.setName(queryKey);
            messageBoardEntity.setRemark(queryKey);
        }
        Page<AdminMessageBoardVo> page = new Page<>(adminMessageBoardDto.getPageNum(), adminMessageBoardDto.getPageSize());
        IPage<AdminMessageBoardVo> list = this.baseMapper.selectAdminMessageBoardInPage(page, messageBoardEntity);
        return Result.ok(list);
    }
    @Override
    @Transactional
    public Result delObjs(AdminDeleteDto adminDeleteDto) {
        String ids = adminDeleteDto.getIds();
        if(StrUtil.isNotEmpty(ids)){
            String[] messageIds = ids.split(StringPool.COMMA);
            for(String messageIdStr : messageIds){
                Long messageId = Long.valueOf(messageIdStr);
                this.baseMapper.deleteById(messageId);
            }
        }
        return Result.ok("删除成功");
    }
    @Override
    public Result addMessage(HttpServletRequest request, AdminAddMessageDto adminAddMessageDto) {
        StringBuffer requestURL = request.getRequestURL();
        List<CompanyEntity> companyEntities = companyMapper.selectList(new QueryWrapper<>());
        Long companyId = 0L;
        if(CollUtil.isNotEmpty(companyEntities)){
            for(CompanyEntity companyEntity : companyEntities){
                boolean contains = StrUtil.contains(requestURL, companyEntity.getWebAddress());
                if(contains){
                    companyId = companyEntity.getId();
                }
            }
        }
        MessageBoardEntity messageBoardEntity = new MessageBoardEntity();
        messageBoardEntity.setName(adminAddMessageDto.getName());
        messageBoardEntity.setContactValue(adminAddMessageDto.getContactValue());
        messageBoardEntity.setTitle(adminAddMessageDto.getTitle());
        messageBoardEntity.setRemark(adminAddMessageDto.getRemark());
        messageBoardEntity.setCreateTime(DateUtil.date());
        messageBoardEntity.setParamOne(adminAddMessageDto.getParamOne());
        messageBoardEntity.setParamTwo(adminAddMessageDto.getParamTwo());
        if(companyId > 0L){
            messageBoardEntity.setCompanyId(companyId);
        }
        this.baseMapper.insert(messageBoardEntity);
        return Result.ok("留言成功");
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/UserServiceImpl.java
@@ -251,6 +251,14 @@
        List<UserRoleEntity> userRoleEntities = userRoleMapper.selectList(userRoleQueryWrapper);
        if(CollUtil.isNotEmpty(userRoleEntities)){
            List menuIds = new ArrayList<Long>();
            if(UserEntity.USERNAME_DEFAULT.equals(loginUser.getUsername())){
                List<MenuEntity> menuEntities = menuMapper.selectList(new QueryWrapper<>());
                if(CollUtil.isNotEmpty(menuEntities)){
                    for(MenuEntity menuEntity : menuEntities){
                        menuIds.add(menuEntity.getId());
                    }
                }
            }else{
            for(UserRoleEntity userRoleEntity : userRoleEntities){
                List<RoleMenuEntity> roleMenuEntities = roleMenuMapper.selectListByRoleId(userRoleEntity.getRoleId());
                if(CollUtil.isNotEmpty(roleMenuEntities)){
@@ -259,6 +267,7 @@
                    }
                }
            }
            }
            if(CollUtil.isNotEmpty(menuIds)){
                HashSet hashSet = CollUtil.newHashSet(menuIds);
                List<Long> parentMenuIds = new ArrayList<>();
src/main/java/com/xcong/farmer/cms/modules/system/util/CaptchaUtil.java
New file
@@ -0,0 +1,38 @@
package com.xcong.farmer.cms.modules.system.util;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.service.ICommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
@Component
public class CaptchaUtil {
    @Autowired
    private DefaultKaptcha producer;
    @Autowired
    private ICommonService iCommonService;
    //生成catchCreator的map
    public Result catchaImgCreator() throws IOException {
        //生成文字验证码
        String text = producer.createText();
        //生成文字对应的图片验证码
        BufferedImage image = producer.createImage(text);
        //将图片写出
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "jpg", outputStream);
        //对写出的字节数组进行Base64编码 ==> 用于传递8比特字节码
        BASE64Encoder encoder = new BASE64Encoder();
        //生成token
        Map<String, Object> token = iCommonService.createToken(text);
        token.put("img", encoder.encode(outputStream.toByteArray()));
        return Result.ok(token);
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/util/UUIDUtil.java
New file
@@ -0,0 +1,11 @@
package com.xcong.farmer.cms.modules.system.util;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component public class UUIDUtil {
    /** * 生成32位的随机UUID * @return 字符形式的小写UUID */
    @Bean public String getUUID32() {
        return UUID.randomUUID().toString() .replace("-", "").toLowerCase();
    }
}
src/main/java/com/xcong/farmer/cms/modules/system/vo/AdminMessageBoardVo.java
New file
@@ -0,0 +1,32 @@
package com.xcong.farmer.cms.modules.system.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.google.type.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "AdminMessageBoardVo", description = "留言板列表返回")
public class AdminMessageBoardVo {
    //ID
    private Long id;
    @ApiModelProperty(value = "姓名")
    private String name;
    @ApiModelProperty(value = "联系方式")
    private String contactValue;
    @ApiModelProperty(value = "留言标题")
    private String title;
    @ApiModelProperty(value = "留言描述")
    private String remark;
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
}
src/main/resources/application.yml
@@ -2,6 +2,8 @@
  port: 8878
  servlet:
    context-path: /
    session:
      timeout: 1
spring:
  datasource:
src/main/resources/mapper/ArticleMapper.xml
@@ -15,8 +15,8 @@
                <if test="record.columnId != null">
                    and a.column_id = #{record.columnId}
                </if>
                <if test="record.belongId != null">
                    and a.company_id = #{record.belongId}
                <if test="record.companyId != null">
                    and a.company_id = #{record.companyId}
                </if>
                <if test="record.title!=null">
                    and a.title like concat ('%',#{record.title},'%')
src/main/resources/mapper/ColumnMapper.xml
@@ -12,8 +12,8 @@
                <if test="record.parentId != null">
                    and a.parent_id = #{record.parentId}
                </if>
                <if test="record.belongId != null">
                    and a.company_id = #{record.belongId}
                <if test="record.companyId != null">
                    and a.company_id = #{record.companyId}
                </if>
            </if>
        </where>
src/main/resources/mapper/MessageBoardMapper.xml
New file
@@ -0,0 +1,25 @@
<?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.xcong.farmer.cms.modules.system.mapper.MessageBoardMapper">
    <select id="selectAdminMessageBoardInPage" resultType="com.xcong.farmer.cms.modules.system.vo.AdminMessageBoardVo">
        SELECT
        a.*
        FROM
        t_message_board a
        <where>
            <if test="record != null" >
                <if test="record.name!=null">
                    and a.name like concat ('%',#{record.name},'%')
                </if>
                <if test="record.remark!=null">
                    and a.remark like concat ('%',#{record.remark},'%')
                </if>
                <if test="record.companyId!=null">
                    and a.company_id = #{record.companyId}
                </if>
            </if>
        </where>
    </select>
</mapper>
src/main/resources/mapper/NavigationBarMapper.xml
@@ -12,8 +12,8 @@
                <if test="record.parentId != null">
                    and a.parent_id = #{record.parentId}
                </if>
                <if test="record.belongId != null">
                    and a.company_id = #{record.belongId}
                <if test="record.companyId != null">
                    and a.company_id = #{record.companyId}
                </if>
            </if>
        </where>
src/main/resources/mapper/RoleMapper.xml
@@ -12,8 +12,8 @@
                <if test="record.roleName!=null">
                    and a.role_name like concat ('%',#{record.roleName},'%')
                </if>
                <if test="record.belongId!=null">
                    and a.company_id = #{record.belongId}
                <if test="record.companyId!=null">
                    and a.company_id = #{record.companyId}
                </if>
            </if>
        </where>
src/main/resources/mapper/UserMapper.xml
@@ -17,8 +17,8 @@
                <if test="record.username!=null">
                    and a.username like concat ('%',#{record.username},'%')
                </if>
                <if test="record.belongId!=null">
                    and a.company_id = #{record.belongId}
                <if test="record.companyId!=null">
                    and a.company_id = #{record.companyId}
                </if>
            </if>
        </where>