|
|
|
@ -1,9 +1,15 @@
|
|
|
|
package com.ruoyi.kaohe.controller;
|
|
|
|
package com.ruoyi.kaohe.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.kaohe.domain.KhItems;
|
|
|
|
|
|
|
|
import com.ruoyi.kaohe.domain.KhTemItem;
|
|
|
|
|
|
|
|
import com.ruoyi.kaohe.service.IKhTemItemService;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
@ -33,6 +39,8 @@ public class KhTemplateController extends BaseController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IKhTemplateService khTemplateService;
|
|
|
|
private IKhTemplateService khTemplateService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IKhTemItemService temItemService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询考核模板列表
|
|
|
|
* 查询考核模板列表
|
|
|
|
@ -75,20 +83,52 @@ public class KhTemplateController extends BaseController
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:template:add')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:template:add')")
|
|
|
|
@Log(title = "考核模板", businessType = BusinessType.INSERT)
|
|
|
|
@Log(title = "考核模板", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping
|
|
|
|
@PostMapping
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public AjaxResult add(@RequestBody KhTemplate khTemplate)
|
|
|
|
public AjaxResult add(@RequestBody KhTemplate khTemplate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return toAjax(khTemplateService.insertKhTemplate(khTemplate));
|
|
|
|
khTemplateService.insertKhTemplate(khTemplate);
|
|
|
|
|
|
|
|
List<KhItems> items = khTemplate.getItems();
|
|
|
|
|
|
|
|
if(items !=null&& items.size()>0){
|
|
|
|
|
|
|
|
for(KhItems item:items){
|
|
|
|
|
|
|
|
KhTemItem temItem = new KhTemItem();
|
|
|
|
|
|
|
|
temItem.setTemName(khTemplate.getTemName());
|
|
|
|
|
|
|
|
temItem.setTemId(khTemplate.getId());
|
|
|
|
|
|
|
|
temItem.setItemName(item.getItemName());
|
|
|
|
|
|
|
|
temItem.setKhitemId(item.getId());
|
|
|
|
|
|
|
|
temItemService.insertKhTemItem(temItem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 修改考核模板
|
|
|
|
* 修改考核模板 同时修改模板选项关联表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:template:edit')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:template:edit')")
|
|
|
|
@Log(title = "考核模板", businessType = BusinessType.UPDATE)
|
|
|
|
@Log(title = "考核模板", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
|
|
|
@PutMapping
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public AjaxResult edit(@RequestBody KhTemplate khTemplate)
|
|
|
|
public AjaxResult edit(@RequestBody KhTemplate khTemplate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return toAjax(khTemplateService.updateKhTemplate(khTemplate));
|
|
|
|
khTemplateService.updateKhTemplate(khTemplate);
|
|
|
|
|
|
|
|
List<KhItems> items = khTemplate.getItems();
|
|
|
|
|
|
|
|
if(items !=null&& items.size()>0){
|
|
|
|
|
|
|
|
//删除原来关联
|
|
|
|
|
|
|
|
KhTemItem query = new KhTemItem();
|
|
|
|
|
|
|
|
query.setTemId(khTemplate.getId());
|
|
|
|
|
|
|
|
List<KhTemItem> temItems = temItemService.selectKhTemItemList(query);
|
|
|
|
|
|
|
|
List<Long> ids = temItems.stream().map(KhTemItem::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
temItemService.deleteKhTemItemByIds(ids.toArray(new Long[ids.size()]));
|
|
|
|
|
|
|
|
for(KhItems item:items){
|
|
|
|
|
|
|
|
KhTemItem temItem = new KhTemItem();
|
|
|
|
|
|
|
|
temItem.setTemName(khTemplate.getTemName());
|
|
|
|
|
|
|
|
temItem.setTemId(khTemplate.getId());
|
|
|
|
|
|
|
|
temItem.setItemName(item.getItemName());
|
|
|
|
|
|
|
|
temItem.setKhitemId(item.getId());
|
|
|
|
|
|
|
|
temItemService.insertKhTemItem(temItem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|