/**
* The MIT License (MIT)
* Copyright (c) 2012-present 铭软科技(mingsoft.net)
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package net.mingsoft.cms.action.web;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.biz.IManagerBiz;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import net.mingsoft.basic.entity.ManagerEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.cms.action.BaseAction;
import net.mingsoft.cms.biz.ICmsSignBiz;
import net.mingsoft.cms.entity.CmsSignEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 分类管理控制层
* @author 铭飞开发团队
* 创建日期:2019-11-28 15:12:32
* 历史修订:
*/
@Api(tags={"前端端-文章签收接口"})
@Controller("webCmsSignAction")
@RequestMapping("/cms/sign")
public class CmsSignAction extends BaseAction {
/**
* 注入分类业务层
*/
@Autowired
private ICmsSignBiz cmsSignBiz;
@Autowired
private IManagerBiz managerBiz;
/**
* 获取账号
* @param
*/
@ApiOperation(value = "获取账号列表接口")
@GetMapping ("/getManagerList")
@ResponseBody
public ResultData getManagerList() {
//查询所有部门用户
List managerList = managerBiz.list();
List managers = managerList.stream().filter(manager -> !manager.getManagerName().equals("msopen")).map(ManagerEntity::getManagerNickName).collect(Collectors.toList());
return ResultData.build().success(managers);
}
/**
* 保存需签收科室
* @param
*/
@ApiOperation(value = "保存需签收科室接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "cmsSigns", value = "需签收科室列表", required =true,paramType="query"),
})
@PostMapping("/saveList")
@ResponseBody
@LogAnn(title = "保存需签收科室", businessType = BusinessTypeEnum.INSERT)
public ResultData saveList(@RequestBody List cmsSigns) {
//把之前选的删掉
String contentId = cmsSigns.get(0).getContentId();
cmsSignBiz.deleteByContentId(contentId);
//循环插入新的
for(CmsSignEntity cmsSign : cmsSigns){
cmsSign.setIsSign("0");
cmsSign.setCreateDate(new Date());
cmsSign.setCreateBy(BasicUtil.getManager().getId());
cmsSignBiz.save(cmsSign);
}
return ResultData.build().success("保存成功!");
}
/**
* 保存文章签收
* @param cmsSign 文章实体
*/
@ApiOperation(value = "保存文章签收接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "contentId", value = "文章关联id", required =true,paramType="query"),
@ApiImplicitParam(name = "managerName", value = "用户名", required =false,paramType="query"),
})
@PostMapping("/save")
@ResponseBody
@LogAnn(title = "保存文章签收", businessType = BusinessTypeEnum.INSERT)
public ResultData save(@ModelAttribute @ApiIgnore CmsSignEntity cmsSign) {
cmsSign.setCreateDate(new Date());
cmsSign.setCreateBy(BasicUtil.getManager().getId());
cmsSignBiz.save(cmsSign);
return ResultData.build().success("保存成功!");
}
/**
* 查询签收列表接口
* @param cmsSign
* @return
*/
@ApiOperation(value = "查询签收列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "文章id", required =false,paramType="query"),
@ApiImplicitParam(name = "contentId", value = "关联文章id", required =false,paramType="query"),
@ApiImplicitParam(name = "managerName", value = "用户名", required =false,paramType="query"),
@ApiImplicitParam(name = "isSign", value = "是否签收", required =false,paramType="query"),
})
@RequestMapping(value = "/list",method = {RequestMethod.GET,RequestMethod.POST})
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore CmsSignEntity cmsSign) {
//查询签收列表
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CmsSignEntity::getContentId,cmsSign.getContentId());
List contentList = cmsSignBiz.list(wrapper);
return ResultData.build().success(contentList);
}
}