一号库模块

master
chenken 4 years ago
parent 83b512789b
commit 0af908b25b

@ -0,0 +1,95 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://el-admin.vip
* @description /
* @author x
* @date 2020-09-10
**/
@Entity
@Data
@Table(name="tb_build_record")
public class BuildRecord implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "gmt_create")
@ApiModelProperty(value = "创建时间")
private Timestamp gmtCreate;
@Column(name = "gmt_modified")
@ApiModelProperty(value = "修改时间")
private Timestamp gmtModified;
@Column(name = "task_name")
@ApiModelProperty(value = "任务名称")
private String taskName;
@Column(name = "time_period")
@ApiModelProperty(value = "任务保存周期")
private Integer timePeriod;
@Column(name = "is_build")
@ApiModelProperty(value = "任务是否建立成功")
private Integer isBuild;
@Column(name = "is_send")
@ApiModelProperty(value = "发送状态记录")
private Integer isSend;
@Column(name = "opration_name")
@ApiModelProperty(value = "操作人")
private String oprationName;
@Column(name = "description")
@ApiModelProperty(value = "自定义内容补充")
private String description;
@Column(name = "local_file_path")
@ApiModelProperty(value = "本地生成待发送文件路径")
private String localFilePath;
@Column(name = "params")
@ApiModelProperty(value = "查询参数暂存")
private String params;
@Column(name = "total")
@ApiModelProperty(value = "该任务生成总记录数")
private Long total;
@Column(name = "send_total")
@ApiModelProperty(value = "上次发送总记录数")
private Long sendTotal;
public void copy(BuildRecord source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

@ -0,0 +1,28 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.repository;
import me.zhengjie.modules.buildrecord.domain.BuildRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-10
**/
public interface BuildRecordRepository extends JpaRepository<BuildRecord, Integer>, JpaSpecificationExecutor<BuildRecord> {
}

@ -0,0 +1,87 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.buildrecord.domain.BuildRecord;
import me.zhengjie.modules.buildrecord.service.BuildRecordService;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-10
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "buildRecord管理")
@RequestMapping("/api/buildRecord")
public class BuildRecordController {
private final BuildRecordService buildRecordService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('buildRecord:list')")
public void download(HttpServletResponse response, BuildRecordQueryCriteria criteria) throws IOException {
buildRecordService.download(buildRecordService.queryAll(criteria), response);
}
@GetMapping
@Log("查询buildRecord")
@ApiOperation("查询buildRecord")
@PreAuthorize("@el.check('buildRecord:list')")
public ResponseEntity<Object> query(BuildRecordQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(buildRecordService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增buildRecord")
@ApiOperation("新增buildRecord")
@PreAuthorize("@el.check('buildRecord:add')")
public ResponseEntity<Object> create(@Validated @RequestBody BuildRecord resources){
return new ResponseEntity<>(buildRecordService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改buildRecord")
@ApiOperation("修改buildRecord")
@PreAuthorize("@el.check('buildRecord:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody BuildRecord resources){
buildRecordService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除buildRecord")
@ApiOperation("删除buildRecord")
@PreAuthorize("@el.check('buildRecord:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
buildRecordService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

@ -0,0 +1,83 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.service;
import me.zhengjie.modules.buildrecord.domain.BuildRecord;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordDto;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://el-admin.vip
* @description
* @author x
* @date 2020-09-10
**/
public interface BuildRecordService {
/**
*
* @param criteria
* @param pageable
* @return Map<String,Object>
*/
Map<String,Object> queryAll(BuildRecordQueryCriteria criteria, Pageable pageable);
/**
*
* @param criteria
* @return List<BuildRecordDto>
*/
List<BuildRecordDto> queryAll(BuildRecordQueryCriteria criteria);
/**
* ID
* @param id ID
* @return BuildRecordDto
*/
BuildRecordDto findById(Integer id);
/**
*
* @param resources /
* @return BuildRecordDto
*/
BuildRecordDto create(BuildRecord resources);
/**
*
* @param resources /
*/
void update(BuildRecord resources);
/**
*
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
*
* @param all
* @param response /
* @throws IOException /
*/
void download(List<BuildRecordDto> all, HttpServletResponse response) throws IOException;
}

@ -0,0 +1,69 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://el-admin.vip
* @description /
* @author x
* @date 2020-09-10
**/
@Data
public class BuildRecordDto implements Serializable {
/** id */
private Integer id;
/** 创建时间 */
private Timestamp gmtCreate;
/** 修改时间 */
private Timestamp gmtModified;
/** 任务名称 */
private String taskName;
/** 任务保存周期 */
private Integer timePeriod;
/** 任务是否建立成功 */
private Integer isBuild;
/** 发送状态记录 */
private Integer isSend;
/** 操作人 */
private String oprationName;
/** 自定义内容补充 */
private String description;
/** 本地生成待发送文件路径 */
private String localFilePath;
/** 查询参数暂存 */
private String params;
/** 该任务生成总记录数 */
private Long total;
/** 上次发送总记录数 */
private Long sendTotal;
}

@ -0,0 +1,29 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.service.dto;
import lombok.Data;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-10
**/
@Data
public class BuildRecordQueryCriteria{
}

@ -0,0 +1,115 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.service.impl;
import me.zhengjie.modules.buildrecord.domain.BuildRecord;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.buildrecord.repository.BuildRecordRepository;
import me.zhengjie.modules.buildrecord.service.BuildRecordService;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordDto;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordQueryCriteria;
import me.zhengjie.modules.buildrecord.service.mapstruct.BuildRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://el-admin.vip
* @description
* @author x
* @date 2020-09-10
**/
@Service
@RequiredArgsConstructor
public class BuildRecordServiceImpl implements BuildRecordService {
private final BuildRecordRepository buildRecordRepository;
private final BuildRecordMapper buildRecordMapper;
@Override
public Map<String,Object> queryAll(BuildRecordQueryCriteria criteria, Pageable pageable){
Page<BuildRecord> page = buildRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(buildRecordMapper::toDto));
}
@Override
public List<BuildRecordDto> queryAll(BuildRecordQueryCriteria criteria){
return buildRecordMapper.toDto(buildRecordRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public BuildRecordDto findById(Integer id) {
BuildRecord buildRecord = buildRecordRepository.findById(id).orElseGet(BuildRecord::new);
ValidationUtil.isNull(buildRecord.getId(),"BuildRecord","id",id);
return buildRecordMapper.toDto(buildRecord);
}
@Override
@Transactional(rollbackFor = Exception.class)
public BuildRecordDto create(BuildRecord resources) {
return buildRecordMapper.toDto(buildRecordRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(BuildRecord resources) {
BuildRecord buildRecord = buildRecordRepository.findById(resources.getId()).orElseGet(BuildRecord::new);
ValidationUtil.isNull( buildRecord.getId(),"BuildRecord","id",resources.getId());
buildRecord.copy(resources);
buildRecordRepository.save(buildRecord);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
buildRecordRepository.deleteById(id);
}
}
@Override
public void download(List<BuildRecordDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (BuildRecordDto buildRecord : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("创建时间", buildRecord.getGmtCreate());
map.put("修改时间", buildRecord.getGmtModified());
map.put("任务名称", buildRecord.getTaskName());
map.put("任务保存周期", buildRecord.getTimePeriod());
map.put("任务是否建立成功", buildRecord.getIsBuild());
map.put("发送状态记录", buildRecord.getIsSend());
map.put("操作人", buildRecord.getOprationName());
map.put("自定义内容补充", buildRecord.getDescription());
map.put("本地生成待发送文件路径", buildRecord.getLocalFilePath());
map.put("查询参数暂存", buildRecord.getParams());
map.put("该任务生成总记录数", buildRecord.getTotal());
map.put("上次发送总记录数", buildRecord.getSendTotal());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

@ -0,0 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.buildrecord.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.buildrecord.domain.BuildRecord;
import me.zhengjie.modules.buildrecord.service.dto.BuildRecordDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://el-admin.vip
* @author x
* @date 2020-09-10
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface BuildRecordMapper extends BaseMapper<BuildRecordDto, BuildRecord> {
}
Loading…
Cancel
Save