Merge branch 'dev-V0.4.5' of https://gitee.com/iotkit-open-source/iotkit-parent into dev-V0.4.5

V0.5.x
xiwa 2023-07-09 18:00:28 +08:00
commit 1c15bdc354
17 changed files with 175 additions and 122 deletions

View File

@ -5,6 +5,7 @@ import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.common.utils.SpringUtils;
import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.web.filter.RepeatedlyRequestWrapper; import cc.iotkit.common.web.filter.RepeatedlyRequestWrapper;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.alibaba.ttl.TransmittableThreadLocal; import com.alibaba.ttl.TransmittableThreadLocal;
@ -19,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* web * web
@ -53,7 +55,10 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor {
Map<String, String[]> parameterMap = request.getParameterMap(); Map<String, String[]> parameterMap = request.getParameterMap();
if (MapUtil.isNotEmpty(parameterMap)) { if (MapUtil.isNotEmpty(parameterMap)) {
String parameters = JsonUtils.toJsonString(parameterMap); String parameters = JsonUtils.toJsonString(parameterMap);
MDC.put("requestId",parameterMap.get("requestId")[0]); String[] requestIds = parameterMap.get("requestId");
if(Objects.nonNull(requestIds) && requestIds.length> 0){
MDC.put("requestId",requestIds[0]);
}
log.debug("开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters); log.debug("开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters);
} else { } else {
log.debug("开始请求 => URL[{}],无参数", url); log.debug("开始请求 => URL[{}],无参数", url);

View File

@ -1,35 +1,33 @@
package cc.iotkit.contribution.controller; package cc.iotkit.contribution.controller;
import java.util.List;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.web.core.BaseController;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request; import cc.iotkit.common.api.Request;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup; import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.common.web.core.BaseController; import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.contribution.dto.bo.IotContributorBo; import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.contribution.dto.vo.IotContributorVo; import cc.iotkit.contribution.dto.vo.IotContributorVo;
import cc.iotkit.contribution.dto.bo.IotContributorBo;
import cc.iotkit.contribution.service.IIotContributorService; import cc.iotkit.contribution.service.IIotContributorService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* *
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor

View File

@ -1,5 +1,6 @@
package cc.iotkit.contribution.data; package cc.iotkit.contribution.data;
import cc.iotkit.data.ICommonData;
import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.model.IotContributor;
import cc.iotkit.data.ICommonData; import cc.iotkit.data.ICommonData;
@ -7,7 +8,7 @@ import cc.iotkit.data.ICommonData;
* *
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
public interface IIotContributorData extends ICommonData<IotContributor, Long> { public interface IIotContributorData extends ICommonData<IotContributor, Long> {

View File

@ -1,32 +1,36 @@
package cc.iotkit.contribution.data.impl; package cc.iotkit.contribution.data.impl;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.contribution.repository.IotContributorRepository;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.contribution.data.IIotContributorData; import cc.iotkit.contribution.data.IIotContributorData;
import cc.iotkit.contribution.data.model.TbIotContributor; import cc.iotkit.contribution.data.model.TbIotContributor;
import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.model.IotContributor;
import cc.iotkit.contribution.repository.IotContributorRepository; import java.util.List;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.data.util.PredicateBuilder;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.StringUtils;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.util.PageBuilder;
import static cc.iotkit.contribution.data.model.QTbIotContributor.tbIotContributor; import static cc.iotkit.contribution.data.model.QTbIotContributor.tbIotContributor;
/** /**
* *
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Primary @Primary
@Service @Service
@ -42,33 +46,19 @@ public class IotContributorDataImpl implements IIotContributorData {
return PageBuilder.toPaging(baseRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))).to(IotContributor.class); return PageBuilder.toPaging(baseRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))).to(IotContributor.class);
} }
@Override
public List<IotContributor> findAllByCondition(IotContributor data) {
Iterable<TbIotContributor> all = baseRepository.findAll(buildQueryCondition(data));
return MapstructUtils.convert(Lists.newArrayList(all), IotContributor.class);
}
@Override
public IotContributor findOneByCondition(IotContributor data) {
Optional<TbIotContributor> one = baseRepository.findOne(buildQueryCondition(data));
if(one.isPresent()){
return MapstructUtils.convert(one.get(), IotContributor.class);
}
return null;
}
private Predicate buildQueryCondition(IotContributor bo) { private Predicate buildQueryCondition(IotContributor bo) {
PredicateBuilder builder = PredicateBuilder.instance(); PredicateBuilder builder = PredicateBuilder.instance();
if(Objects.nonNull(bo)) {
builder.and(StringUtils.isNotBlank(bo.getContributor()), ()->tbIotContributor.contributor.eq(bo.getContributor())); builder.and(StringUtils.isNotBlank(bo.getContributor()), () -> tbIotContributor.contributor.eq(bo.getContributor()));
builder.and(bo.getPost() != null, ()->tbIotContributor.post.eq(bo.getPost())); builder.and(bo.getPost() != null, () -> tbIotContributor.post.eq(bo.getPost()));
builder.and(StringUtils.isNotBlank(bo.getStatus()), ()->tbIotContributor.status.eq(bo.getStatus())); }
return builder.build(); return builder.build();
} }
@Override @Override
public List<IotContributor> findByIds(Collection<Long> id) { public List<IotContributor> findByIds(Collection<Long> ids) {
List allById = baseRepository.findAllById(id); List<TbIotContributor> allById = baseRepository.findAllById(ids);
return MapstructUtils.convert(allById, IotContributor.class); return MapstructUtils.convert(allById, IotContributor.class);
} }
@ -93,6 +83,12 @@ public class IotContributorDataImpl implements IIotContributorData {
baseRepository.deleteAllById(ids); baseRepository.deleteAllById(ids);
} }
@Override
public IotContributor findById(Long id) {
TbIotContributor ret = jpaQueryFactory.select(tbIotContributor).from(tbIotContributor).where(tbIotContributor.id.eq(id)).fetchOne();
return MapstructUtils.convert(ret, IotContributor.class);
}
@Override @Override
public long count() { public long count() {
return baseRepository.count(); return baseRepository.count();
@ -104,8 +100,18 @@ public class IotContributorDataImpl implements IIotContributorData {
} }
@Override @Override
public IotContributor findById(Long id) { public List<IotContributor> findAllByCondition(IotContributor data) {
TbIotContributor ret = jpaQueryFactory.select(tbIotContributor).from(tbIotContributor).where(tbIotContributor.id.eq(id)).fetchOne(); Iterable<TbIotContributor> all = baseRepository.findAll(buildQueryCondition(data));
return MapstructUtils.convert(ret, IotContributor.class); return MapstructUtils.convert(Lists.newArrayList(all), IotContributor.class);
}
@Override
public IotContributor findOneByCondition(IotContributor data) {
Optional<TbIotContributor> one = baseRepository.findOne(buildQueryCondition(data));
if(one.isPresent()){
return MapstructUtils.convert(one.get(), IotContributor.class);
}
return null;
} }
} }

View File

@ -1,25 +1,25 @@
package cc.iotkit.contribution.data.model; package cc.iotkit.contribution.data.model;
import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.model.IotContributor;
import cc.iotkit.data.model.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import cc.iotkit.data.model.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Entity;
/** /**
* iot_contributor * iot_contributor
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -32,12 +32,12 @@ public class TbIotContributor extends BaseEntity {
/** /**
* *
*/ */
@Id @Id
@GeneratedValue(generator = "SnowflakeIdGenerator") @GeneratedValue(generator = "SnowflakeIdGenerator")
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator") @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "")
private Long id; private Long id;
/** /**
@ -56,7 +56,7 @@ public class TbIotContributor extends BaseEntity {
* (1,2,3,4,5ui,6,7) * (1,2,3,4,5ui,6,7)
*/ */
@ApiModelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)") @ApiModelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)")
private Integer post; private Long post;
/** /**
* *
@ -82,6 +82,12 @@ public class TbIotContributor extends BaseEntity {
@ApiModelProperty(value = "详情") @ApiModelProperty(value = "详情")
private String context; private String context;
/**
*
*/
@ApiModelProperty(value = "排序")
private Long score;
/** /**
* 0 1 * 0 1
*/ */

View File

@ -1,20 +1,21 @@
package cc.iotkit.contribution.dto.bo; package cc.iotkit.contribution.dto.bo;
import cc.iotkit.contribution.model.IotContributor;
import cc.iotkit.common.api.BaseDto; import cc.iotkit.common.api.BaseDto;
import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup; import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.contribution.model.IotContributor;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/** /**
* iot_contributor * iot_contributor
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -22,9 +23,10 @@ import lombok.EqualsAndHashCode;
public class IotContributorBo extends BaseDto { public class IotContributorBo extends BaseDto {
/** /**
* *
*/ */
@ApiModelProperty(value = "主键", required = false) @NotNull(message = "不能为空", groups = { EditGroup.class })
@ApiModelProperty(value = "", required = true)
private Long id; private Long id;
/** /**
@ -44,7 +46,7 @@ public class IotContributorBo extends BaseDto {
* (1,2,3,4,5ui,6,7) * (1,2,3,4,5ui,6,7)
*/ */
@ApiModelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)", required = false) @ApiModelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)", required = false)
private Integer post; private Long post;
/** /**
* *
@ -70,6 +72,13 @@ public class IotContributorBo extends BaseDto {
@ApiModelProperty(value = "详情", required = false) @ApiModelProperty(value = "详情", required = false)
private String context; private String context;
/**
*
*/
@NotNull(message = "排序不能为空", groups = { AddGroup.class, EditGroup.class })
@ApiModelProperty(value = "排序", required = true)
private Long score;
/** /**
* 0 1 * 0 1
*/ */

View File

@ -1,14 +1,17 @@
package cc.iotkit.contribution.dto.vo; package cc.iotkit.contribution.dto.vo;
import cc.iotkit.common.excel.annotation.ExcelDictFormat;
import cc.iotkit.common.excel.convert.ExcelDictConvert;
import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.model.IotContributor;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import cc.iotkit.common.excel.annotation.ExcelDictFormat;
import cc.iotkit.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data; import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
@ -16,7 +19,7 @@ import java.io.Serializable;
* iot_contributor * iot_contributor
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Data @Data
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
@ -27,58 +30,74 @@ public class IotContributorVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
@ExcelProperty(value = "主键") @ExcelProperty(value = "")
@ApiModelProperty(value = "")
private Long id; private Long id;
/** /**
* *
*/ */
@ExcelProperty(value = "贡献者名称") @ExcelProperty(value = "贡献者名称")
@ApiModelProperty(value = "贡献者名称")
private String contributor; private String contributor;
/** /**
* *
*/ */
@ExcelProperty(value = "头像") @ExcelProperty(value = "头像")
@ApiModelProperty(value = "头像")
private String avatar; private String avatar;
/** /**
* (1,2,3,4,5ui,6,7) * (1,2,3,4,5ui,6,7)
*/ */
@ExcelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)") @ExcelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)")
private Integer post; @ApiModelProperty(value = "岗位(1前端开发,2后端开发,3全栈开发,4测试,5ui设计师,6产品经理,7架构师)")
private Long post;
/** /**
* *
*/ */
@ExcelProperty(value = "简介") @ExcelProperty(value = "简介")
@ApiModelProperty(value = "简介")
private String intro; private String intro;
/** /**
* tag(,) * tag(,)
*/ */
@ExcelProperty(value = "tag列表(为了简单,逗号隔开)") @ExcelProperty(value = "tag列表(为了简单,逗号隔开)")
@ApiModelProperty(value = "tag列表(为了简单,逗号隔开)")
private String tags; private String tags;
/** /**
* *
*/ */
@ExcelProperty(value = "详情标题") @ExcelProperty(value = "详情标题")
@ApiModelProperty(value = "详情标题")
private String title; private String title;
/** /**
* *
*/ */
@ExcelProperty(value = "详情") @ExcelProperty(value = "详情")
@ApiModelProperty(value = "详情")
private String context; private String context;
/**
*
*/
@ExcelProperty(value = "排序")
@ApiModelProperty(value = "排序")
private Long score;
/** /**
* 0 1 * 0 1
*/ */
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=正常,1=停用") @ExcelDictFormat(readConverterExp = "0=正常,1=停用")
@ApiModelProperty(value = "帐号状态")
private String status; private String status;

View File

@ -1,7 +1,7 @@
package cc.iotkit.contribution.model; package cc.iotkit.contribution.model;
import cc.iotkit.model.BaseModel;
import cc.iotkit.model.Id; import cc.iotkit.model.Id;
import cc.iotkit.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -12,7 +12,7 @@ import java.io.Serializable;
* iot_contributor * iot_contributor
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -21,7 +21,7 @@ public class IotContributor extends BaseModel implements Id<Long>, Serializable{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
private Long id; private Long id;
@ -38,7 +38,7 @@ public class IotContributor extends BaseModel implements Id<Long>, Serializable{
/** /**
* (1,2,3,4,5ui,6,7) * (1,2,3,4,5ui,6,7)
*/ */
private Integer post; private Long post;
/** /**
* *
@ -60,6 +60,11 @@ public class IotContributor extends BaseModel implements Id<Long>, Serializable{
*/ */
private String context; private String context;
/**
*
*/
private Long score;
/** /**
* 0 1 * 0 1
*/ */

View File

@ -3,15 +3,13 @@ package cc.iotkit.contribution.repository;
import cc.iotkit.contribution.data.model.TbIotContributor; import cc.iotkit.contribution.data.model.TbIotContributor;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
/** /**
* iot_contributor * iot_contributor
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@Repository
public interface IotContributorRepository extends JpaRepository<TbIotContributor, Long>, QuerydslPredicateExecutor<TbIotContributor> { public interface IotContributorRepository extends JpaRepository<TbIotContributor, Long>, QuerydslPredicateExecutor<TbIotContributor> {
} }

View File

@ -1,9 +1,10 @@
package cc.iotkit.contribution.service; package cc.iotkit.contribution.service;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.contribution.dto.bo.IotContributorBo;
import cc.iotkit.contribution.dto.vo.IotContributorVo; import cc.iotkit.contribution.dto.vo.IotContributorVo;
import cc.iotkit.contribution.dto.bo.IotContributorBo;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.PageRequest;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.List;
* Service * Service
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
public interface IIotContributorService { public interface IIotContributorService {

View File

@ -1,26 +1,27 @@
package cc.iotkit.contribution.service.impl; package cc.iotkit.contribution.service.impl;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.exception.BizException; import lombok.RequiredArgsConstructor;
import cc.iotkit.common.utils.MapstructUtils; import org.springframework.stereotype.Service;
import cc.iotkit.contribution.data.IIotContributorData;
import cc.iotkit.contribution.dto.bo.IotContributorBo; import cc.iotkit.contribution.dto.bo.IotContributorBo;
import cc.iotkit.contribution.dto.vo.IotContributorVo; import cc.iotkit.contribution.dto.vo.IotContributorVo;
import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.model.IotContributor;
import cc.iotkit.contribution.service.IIotContributorService; import cc.iotkit.contribution.service.IIotContributorService;
import lombok.RequiredArgsConstructor; import cc.iotkit.contribution.data.IIotContributorData;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Collection;
import cc.iotkit.common.exception.BizException;
/** /**
* Service * Service
* *
* @author Lion Li * @author Lion Li
* @date 2023-07-04 * @date 2023-07-09
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
@ -75,7 +76,10 @@ public class IotContributorServiceImpl implements IIotContributorService {
IotContributor update = MapstructUtils.convert(bo, IotContributor.class); IotContributor update = MapstructUtils.convert(bo, IotContributor.class);
validEntityBeforeSave(update); validEntityBeforeSave(update);
IotContributor ret = baseData.save(update); IotContributor ret = baseData.save(update);
return ret != null; if(ret == null){
return false;
}
return true;
} }
/** /**

View File

@ -2,9 +2,6 @@ package ${packageName}.dto.bo;
import ${packageName}.model.${ClassName}; import ${packageName}.model.${ClassName};
import cc.iotkit.common.api.BaseDto; import cc.iotkit.common.api.BaseDto;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup; import cc.iotkit.common.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;

View File

@ -6,7 +6,6 @@ import java.util.List;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -49,7 +48,7 @@ public class ${ClassName}Controller extends BaseController {
return ${className}Service.queryPageList(pageQuery); return ${className}Service.queryPageList(pageQuery);
} }
#elseif($table.tree) #elseif($table.tree)
public List<${ClassName}Vo> list(Request<${ClassName}Bo> query) { public List<${ClassName}Vo> list(@RequestBody Request<${ClassName}Bo> query) {
List<${ClassName}Vo> list = ${className}Service.queryList(query.getData()); List<${ClassName}Vo> list = ${className}Service.queryList(query.getData());
return list; return list;
} }

View File

@ -5,13 +5,10 @@ import ${packageName}.data.I${ClassName}Data;
import ${packageName}.data.model.Tb${ClassName}; import ${packageName}.data.model.Tb${ClassName};
import ${packageName}.model.${ClassName}; import ${packageName}.model.${ClassName};
import java.util.List; import java.util.List;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.data.util.PredicateBuilder;
@ -19,6 +16,11 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.utils.StringUtils;
import java.util.Collection; import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import com.google.common.collect.Lists;
import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PageBuilder;
@ -46,33 +48,35 @@ public class ${ClassName}DataImpl implements I${ClassName}Data {
private Predicate buildQueryCondition(${ClassName} bo) { private Predicate buildQueryCondition(${ClassName} bo) {
PredicateBuilder builder = PredicateBuilder.instance(); PredicateBuilder builder = PredicateBuilder.instance();
if(Objects.nonNull(bo)) {
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($javaType=$column.javaType) #set($javaType=$column.javaType)
#set($columnName=$column.columnName) #set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($queryType != 'BETWEEN') #if($queryType != 'BETWEEN')
#if($javaType == 'String') #if($javaType == 'String')
#set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())') #set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())')
#else
#set($condition='bo.get'+$AttrName+'() != null')
#end
builder.and($condition, () -> tb${ClassName}.${javaField}.eq(bo.get${AttrName}()));
#else #else
#set($condition='bo.get'+$AttrName+'() != null') builder.and(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
() -> tb${ClassName}.${javaField}.bettwen(params.get("begin$AttrName"), params.get("end$AttrName")));
#end #end
builder.and($condition, ()->tb${ClassName}.${javaField}.eq(bo.get${AttrName}()));
#else
builder.and(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
()->tb${ClassName}.${javaField}.bettwen(params.get("begin$AttrName"), params.get("end$AttrName")));
#end #end
#end #end
#end }
return builder.build(); return builder.build();
} }
@Override @Override
public List<${ClassName}> findByIds(Collection<Long> id) { public List<${ClassName}> findByIds(Collection<Long> ids) {
List allById = baseRepository.findAllById(id); List<Tb${ClassName}> allById = baseRepository.findAllById(ids);
return MapstructUtils.convert(allById, ${ClassName}.class); return MapstructUtils.convert(allById, ${ClassName}.class);
} }
@ -100,8 +104,7 @@ public class ${ClassName}DataImpl implements I${ClassName}Data {
@Override @Override
public ${ClassName} findById(Long id) { public ${ClassName} findById(Long id) {
Tb${ClassName} ret = jpaQueryFactory.select(tb${ClassName}).from(tb${ClassName}).where(tb${ClassName}.id.eq(id)).fetchOne(); Tb${ClassName} ret = jpaQueryFactory.select(tb${ClassName}).from(tb${ClassName}).where(tb${ClassName}.id.eq(id)).fetchOne();
${ClassName} convert = MapstructUtils.convert(ret, ${ClassName}.class); return MapstructUtils.convert(ret, ${ClassName}.class);
return convert;
} }
@Override @Override

View File

@ -6,7 +6,6 @@ import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
#end #end
import cc.iotkit.common.api.Request;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ${packageName}.dto.bo.${ClassName}Bo; import ${packageName}.dto.bo.${ClassName}Bo;
@ -16,7 +15,6 @@ import ${packageName}.service.I${ClassName}Service;
import ${packageName}.data.I${ClassName}Data; import ${packageName}.data.I${ClassName}Data;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Collection; import java.util.Collection;
import cc.iotkit.common.exception.BizException; import cc.iotkit.common.exception.BizException;

View File

@ -113,7 +113,8 @@ public class SysProfileController extends BaseController {
@ApiOperation(value = "头像上传", notes = "头像上传") @ApiOperation(value = "头像上传", notes = "头像上传")
@Log(title = "用户头像", businessType = BusinessType.UPDATE) @Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public AvatarVo avatar(@RequestPart("avatarfile") MultipartFile avatarfile) { public AvatarVo avatar(@RequestPart("avatarfile") MultipartFile avatarfile,
@RequestParam("requestId") String requestId) {
if (!avatarfile.isEmpty()) { if (!avatarfile.isEmpty()) {
String extension = FileUtil.extName(avatarfile.getOriginalFilename()); String extension = FileUtil.extName(avatarfile.getOriginalFilename());
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {

View File

@ -273,7 +273,10 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
@Override @Override
public boolean updateUserAvatar(Long userId, Long avatar) { public boolean updateUserAvatar(Long userId, Long avatar) {
return false; SysUser oldUser = sysUserData.findById(userId);
oldUser.setAvatar(avatar);
sysUserData.save(oldUser);
return Boolean.TRUE;
} }
@Override @Override