New file |
| | |
| | | package com.dg.core.api; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dg.core.ResultData; |
| | | import com.dg.core.annotation.Authorization; |
| | | import com.dg.core.annotation.CurrentUser; |
| | | import com.dg.core.controller.BaseController; |
| | | import com.dg.core.db.gen.entity.ReplyTemplateEntity; |
| | | import com.dg.core.db.gen.entity.SysUser; |
| | | import com.dg.core.service.IOrganizationChartService; |
| | | import com.dg.core.service.IReplyTemplateService; |
| | | import com.dg.core.util.TableDataInfo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Api(tags = {"回复模板小程序接口"}) |
| | | @RestController |
| | | @RequestMapping("/applets/reply") |
| | | public class ReplyTemplateAppletsController extends BaseController |
| | | { |
| | | |
| | | @Autowired |
| | | IReplyTemplateService iReplyTemplateService; |
| | | |
| | | @Autowired |
| | | IOrganizationChartService iOrganizationChartService; |
| | | |
| | | |
| | | /** |
| | | * 获取模板列表 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取模板列表",response = ReplyTemplateEntity.class) |
| | | @GetMapping("/getlist") |
| | | @Authorization |
| | | public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum, |
| | | @RequestParam(value = "pageSize",required = false) Integer pageSize, |
| | | @RequestParam(value = "Name",required = false) String Name, |
| | | @CurrentUser SysUser sysUser) |
| | | { |
| | | Page<ReplyTemplateEntity> pageParam = new Page<>(pageNum,pageSize); |
| | | List<String> ids=iOrganizationChartService.getIds(sysUser.getDepartmentId()); |
| | | List<ReplyTemplateEntity> list = iReplyTemplateService.selectConfigList(pageParam,pageSize,Name,ids); |
| | | int num=iReplyTemplateService.countNum(Name,ids); |
| | | return getDataTable(list,num); |
| | | } |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * @param Id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取详情",response = ReplyTemplateEntity.class) |
| | | @GetMapping("/getdata") |
| | | @Authorization |
| | | public ResultData selectConfigData(@RequestParam(value = "Id",required = false) String Id) |
| | | { |
| | | if(StringUtils.isEmpty(Id)) |
| | | { |
| | | return ResultData.error("Id不能为空"); |
| | | } |
| | | return ResultData.success(iReplyTemplateService.selectConfigData(Id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增模板 |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "新增模板",response = ReplyTemplateEntity.class) |
| | | @PostMapping("/add") |
| | | @Authorization |
| | | public ResultData insertConfig(@RequestBody ReplyTemplateEntity entity,@CurrentUser SysUser sysUser) |
| | | { |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(entity.getName())) |
| | | { |
| | | return ResultData.error("模板名称不能为空"); |
| | | } |
| | | |
| | | entity.setId(null); |
| | | entity.setDepartmentId(sysUser.getDepartmentId()); |
| | | entity.setCreateUserId(sysUser.getUserId()+""); |
| | | |
| | | return toAjax(iReplyTemplateService.insertConfig(entity)); |
| | | } |
| | | |
| | | /** |
| | | * 更新模板 |
| | | * @param entity |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "更新模板",response = ReplyTemplateEntity.class) |
| | | @PostMapping("/update") |
| | | @Authorization |
| | | public ResultData updateConfig(@RequestBody ReplyTemplateEntity entity) |
| | | { |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("参数不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(entity.getName())) |
| | | { |
| | | return ResultData.error("模板名称不能为空"); |
| | | } |
| | | return toAjax(iReplyTemplateService.updateConfig(entity)); |
| | | } |
| | | |
| | | /** |
| | | * 删除模板 |
| | | * @param Id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除模板",response = ReplyTemplateEntity.class) |
| | | @DeleteMapping("/delete") |
| | | @Authorization |
| | | public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id) |
| | | { |
| | | return toAjax(iReplyTemplateService.deleteConfigById(Id)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 复制模板 |
| | | * @param Id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "复制模板",response = ReplyTemplateEntity.class) |
| | | @PostMapping("/copy") |
| | | @Authorization |
| | | public ResultData copy(@RequestParam(value = "Id",required = false) String Id) |
| | | { |
| | | if(StringUtils.isEmpty(Id)) |
| | | { |
| | | return ResultData.error("Id不能为空"); |
| | | } |
| | | |
| | | ReplyTemplateEntity entity=iReplyTemplateService.selectConfigData(Id); |
| | | |
| | | if(entity==null) |
| | | { |
| | | return ResultData.error("模板不存在!"); |
| | | } |
| | | entity.setId(null); |
| | | return toAjax(iReplyTemplateService.insertConfig(entity)); |
| | | } |
| | | |
| | | |
| | | } |