11 changed files with 337 additions and 38 deletions
@ -0,0 +1,77 @@ |
|||
package ${package}.controller; |
|||
|
|||
import ${main}.commons.tools.page.PageData; |
|||
import ${main}.commons.tools.utils.ExcelUtils; |
|||
import ${main}.commons.tools.utils.Result; |
|||
import ${main}.commons.tools.validator.AssertUtils; |
|||
import ${main}.commons.tools.validator.ValidatorUtils; |
|||
import ${main}.commons.tools.validator.group.AddGroup; |
|||
import ${main}.commons.tools.validator.group.UpdateGroup; |
|||
import ${main}.commons.tools.validator.group.DefaultGroup; |
|||
import ${package}.dto.${className}DTO; |
|||
import ${package}.excel.${className}Excel; |
|||
import ${package}.service.${className}Service; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* ${comments} |
|||
* |
|||
* @author ${author} ${email} |
|||
* @since ${version} ${date} |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("${pathName}") |
|||
public class ${className}Controller { |
|||
|
|||
@Autowired |
|||
private ${className}Service ${classname}Service; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<${className}DTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<${className}DTO> page = ${classname}Service.page(params); |
|||
return new Result<PageData<${className}DTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<${className}DTO> get(@PathVariable("id") String id){ |
|||
${className}DTO data = ${classname}Service.get(id); |
|||
return new Result<${className}DTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody ${className}DTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
${classname}Service.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody ${className}DTO dto){ |
|||
//效验数据 |
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
${classname}Service.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据 |
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
${classname}Service.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<${className}DTO> list = ${classname}Service.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, ${className}Excel.class); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,87 @@ |
|||
package ${package}.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import ${main}.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import ${main}.commons.tools.page.PageData; |
|||
import ${main}.commons.tools.utils.ConvertUtils; |
|||
import ${package}.commons.tools.constant.FieldConstant; |
|||
import ${package}.dao.${className}Dao; |
|||
import ${package}.dto.${className}DTO; |
|||
import ${package}.entity.${className}Entity; |
|||
import ${package}.redis.${className}Redis; |
|||
import ${package}.service.${className}Service; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* ${comments} |
|||
* |
|||
* @author ${author} ${email} |
|||
* @since ${version} ${date} |
|||
*/ |
|||
@Service |
|||
public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${className}Entity> implements ${className}Service { |
|||
|
|||
@Autowired |
|||
private ${className}Redis ${classname}Redis; |
|||
|
|||
@Override |
|||
public PageData<${className}DTO> page(Map<String, Object> params) { |
|||
IPage<${className}Entity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, ${className}DTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<${className}DTO> list(Map<String, Object> params) { |
|||
List<${className}Entity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, ${className}DTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<${className}Entity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<${className}Entity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public ${className}DTO get(String id) { |
|||
${className}Entity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, ${className}DTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(${className}DTO dto) { |
|||
${className}Entity entity = ConvertUtils.sourceToTarget(dto, ${className}Entity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(${className}DTO dto) { |
|||
${className}Entity entity = ConvertUtils.sourceToTarget(dto, ${className}Entity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解) |
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto.extract.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 网格项目main表数据 |
|||
*/ |
|||
@Data |
|||
public class GridProjectToProjectMainDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 项目ID |
|||
*/ |
|||
private String projectId; |
|||
/** |
|||
* 项目的发布日期yyyyMMdd |
|||
*/ |
|||
private String dateId; |
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
/** |
|||
* 状态 |
|||
*/ |
|||
private String projectStatus; |
|||
/** |
|||
* resolved unresolved |
|||
* */ |
|||
private String isResolved; |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue