12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553 |
- package com.idea.oa.testPlan.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.github.pagehelper.PageInfo;
- import com.github.pagehelper.StringUtil;
- import com.idea.oa.task.model.ProTaskRelation;
- import com.idea.oa.task.model.ProTaskRelationExample;
- import com.idea.oa.task.service.ProTaskRelationService;
- import com.idea.oa.task.utils.ConstantsInfo;
- import com.idea.oa.testPlan.model.*;
- import com.idea.oa.testPlan.model.in.TestPlanIn;
- import com.idea.oa.testPlan.service.TestPlanCommanderService;
- import com.idea.oa.testPlan.service.TestPlanService;
- import com.rockstar.common.base.BaseController;
- import com.rockstar.common.domain.AjaxResult;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.TableSplitResult;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.shiro.util.ShiroUtils;
- import com.rockstar.util.SnowflakeIdWorker;
- import io.swagger.annotations.Api;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by pengyq on 2020.
- */
- @Controller
- @RequestMapping(value = "TestPlanController")
- @Api(value = "测试管理/测试计划")
- public class TestPlanController extends BaseController {
- @Autowired
- private ProTaskRelationService proTaskRelationService;
- //主表
- @Autowired
- private TestPlanService modelService;
- @Autowired
- private TestPlanCommanderService testPlanCommanderService;
- @PostMapping(value = "list", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object list(Tablepar tablepar, TestPlan model, DateTrans dt) {
- PageInfo<TestPlan> page = modelService.list(tablepar, model, dt);
- TableSplitResult<TestPlan> result = new TableSplitResult<TestPlan>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- /**
- * 对应页面(测试管理/测试计划)获取列表数组
- *
- * @param tablepar
- * @param model
- * @param dt
- * @return
- */
- @PostMapping(value = "listVo", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listVo(Tablepar tablepar, TestPlanIn model, DateTrans dt) {
- List<TestPlanIn> list = modelService.listVo(tablepar, model, dt);
- return list;
- }
- /**
- * 对应页面(测试管理/测试计划)获取列表总数
- *
- * @param model
- * @param dt
- * @return
- */
- @PostMapping(value = "getTotal", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object getTotal(TestPlanIn model, DateTrans dt) {
- Long total = modelService.getTotal(model, dt);
- return total;
- }
- @PostMapping(value = "listAll", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listAll(TestPlan model, DateTrans dt) {
- return modelService.listAll(model, dt);
- }
- /**
- * 添加对象数据,对象数组中有多个负责人id,所以需要解析他们,并插入他们
- *
- * @param info
- * @return
- */
- @PostMapping(value = "add", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult add(String info) {
- System.out.println(info);
- if (info != null) {
- List<TestPlanIn> testPlanIns = JSONArray.parseArray(info, TestPlanIn.class);
- StringBuilder addFirst=new StringBuilder();
- for (TestPlanIn testPlanIn : testPlanIns) {
- testPlanIn.setCreatedAt(new Date());
- testPlanIn.setUpdatedAt(testPlanIn.getCreatedAt());
- testPlanIn.setCreatedBy(ShiroUtils.getUser().getId());
- testPlanIn.setUpdatedBy(testPlanIn.getCreatedBy());
- testPlanIn.setStatus(0);
- testPlanIn.setId(SnowflakeIdWorker.getUUID());
- //添加主目录
- modelService.insertWithoutId(testPlanIn);
- addFirst.append(testPlanIn.getId()+',');
- //下面是添加负责人
- String handleUserId = testPlanIn.getHandleUserId();
- if (!StringUtil.isEmpty(handleUserId)) {
- String[] userIds = handleUserId.split(",");
- for (int i = 0; i < userIds.length; i++) {
- TestPlanCommander testPlanCommander = new TestPlanCommander();
- testPlanCommander.setPlanId(testPlanIn.getId());
- testPlanCommander.setCommanderId(userIds[i]);
- testPlanCommander.setSort(i);
- testPlanCommander.setCreatedAt(new Date());
- testPlanCommander.setCreatedBy(ShiroUtils.getUser().getId());
- testPlanCommander.setStatus(0);
- testPlanCommanderService.insert(testPlanCommander);
- }
- }
- }
- // 判断是否存在关联任务id,注意任务编号已经改成任务id
- if(StringUtils.isNotEmpty(testPlanIns.get(0).getTaskNo())) {
- ProTaskRelationExample example1 = new ProTaskRelationExample();
- example1.createCriteria().andTaskIdEqualTo(testPlanIns.get(0).getTaskNo()).andTaskRelationNameEqualTo(ConstantsInfo.TEST_PLAN);
- List<ProTaskRelation> proTaskRelations = proTaskRelationService.selectByExample(example1);
- if(proTaskRelations!=null&&proTaskRelations.size()>0){
- ProTaskRelation proTaskRelation = proTaskRelations.get(0);
- proTaskRelation.setStatus(ConstantsInfo.RELATION_TASK_COM);
- proTaskRelation.setFirst(addFirst.toString());
- proTaskRelationService.updateByPrimaryKeySelective(proTaskRelation);
- }
- }
- return result(1);
- } else {
- return result(-1);
- }
- }
- @PostMapping(value = "remove/{id}", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult remove(@PathVariable("id") String id) {
- int result = 0;
- {//这是正式删除
- // result = modelService.deleteByPrimaryKey(id);
- // TestPlanCommanderExample testUsecaseStepExample = new TestPlanCommanderExample();
- // testUsecaseStepExample.createCriteria().andPlanIdEqualTo(id);
- // testPlanCommanderService.deleteByExample(testUsecaseStepExample);
- }
- {//这是修改删除
- TestPlanIn record = new TestPlanIn();
- record.setId(id);
- record.setStatus(1);
- record.setUpdatedBy(ShiroUtils.getUser().getId());
- record.setUpdatedAt(new Date());
- result = modelService.updateByPrimaryKeySelective(record);
- TestPlanCommander testUsecaseStep = new TestPlanCommander();
- testUsecaseStep.setStatus(1);
- TestPlanCommanderExample testUsecaseStepExample = new TestPlanCommanderExample();
- testUsecaseStepExample.createCriteria().andPlanIdEqualTo(id);
- testPlanCommanderService.updateByExampleSelective(testUsecaseStep, testUsecaseStepExample);
- }
- return result(result);
- }
- /**
- * 修改对象数据,对象数组中有多个负责人id,所以需要解析他们,并插入他们
- *
- * @param info
- * @return
- */
- @PostMapping(value = "edit", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult editSave(String info) {
- System.out.println("edit:" + info);
- if (info != null) {
- List<TestPlanIn> testPlanIns = JSONArray.parseArray(info, TestPlanIn.class);
- for (TestPlanIn testPlanIn : testPlanIns) {
- if (!StringUtil.isEmpty(testPlanIn.getId())) {
- testPlanIn.setUpdatedBy(ShiroUtils.getUser().getId());
- testPlanIn.setUpdatedAt(new Date());
- testPlanIn.setCreatedAt(null);
- testPlanIn.setCreatedBy(null);
- modelService.updateByPrimaryKeySelective(testPlanIn);
- //先删除负责人,再添加负责人
- TestPlanCommanderExample example = new TestPlanCommanderExample();
- example.createCriteria().andPlanIdEqualTo(testPlanIn.getId());
- testPlanCommanderService.deleteByExample(example);
- //下面是添加负责人
- String handleUserId = testPlanIn.getHandleUserId();
- if (!StringUtil.isEmpty(handleUserId)) {
- String[] userIds = handleUserId.split(",");
- for (int i = 0; i < userIds.length; i++) {
- TestPlanCommander testPlanCommander = new TestPlanCommander();
- testPlanCommander.setPlanId(testPlanIn.getId());
- testPlanCommander.setCommanderId(userIds[i]);
- testPlanCommander.setSort(i);
- testPlanCommander.setCreatedAt(new Date());
- testPlanCommander.setCreatedBy(ShiroUtils.getUser().getId());
- testPlanCommander.setStatus(0);
- testPlanCommanderService.insert(testPlanCommander);
- }
- }
- }else{
- testPlanIn.setCreatedAt(new Date());
- testPlanIn.setUpdatedAt(testPlanIn.getCreatedAt());
- testPlanIn.setCreatedBy(ShiroUtils.getUser().getId());
- testPlanIn.setUpdatedBy(testPlanIn.getCreatedBy());
- testPlanIn.setStatus(0);
- testPlanIn.setId(SnowflakeIdWorker.getUUID());
- //添加主目录
- modelService.insertWithoutId(testPlanIn);
- //下面是添加负责人
- String handleUserId = testPlanIn.getHandleUserId();
- if (!StringUtil.isEmpty(handleUserId)) {
- String[] userIds = handleUserId.split(",");
- for (int i = 0; i < userIds.length; i++) {
- TestPlanCommander testPlanCommander = new TestPlanCommander();
- testPlanCommander.setPlanId(testPlanIn.getId());
- testPlanCommander.setCommanderId(userIds[i]);
- testPlanCommander.setSort(i);
- testPlanCommander.setCreatedAt(new Date());
- testPlanCommander.setCreatedBy(ShiroUtils.getUser().getId());
- testPlanCommander.setStatus(0);
- testPlanCommanderService.insert(testPlanCommander);
- }
- }
- }
- }
- return result(1);
- } else {
- return result(-1);
- }
- }
- /**
- * 修改计划状态
- * @param info
- * @return
- */
- @PostMapping(value = "editStatus", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult editStatus(String info) {
- System.out.println("editStatus:" + info);
- if (info != null) {
- List<TestPlanIn> testPlanIns = JSONArray.parseArray(info, TestPlanIn.class);
- for (TestPlanIn testPlanIn : testPlanIns) {
- if (!StringUtil.isEmpty(testPlanIn.getId())) {
- TestPlanIn newTestPlanIn = new TestPlanIn();
- newTestPlanIn.setId(testPlanIn.getId());
- //对状态说明或者备注
- newTestPlanIn.setStatusremark(testPlanIn.getStatusremark());
- newTestPlanIn.setStatus(testPlanIn.getStatus());
- newTestPlanIn.setUpdatedBy(ShiroUtils.getUser().getId());
- newTestPlanIn.setUpdatedAt(new Date());
- modelService.updateByPrimaryKeySelective(newTestPlanIn);
- }
- }
- return result(1);
- } else {
- return result(-1);
- }
- }
- @PostMapping(value = "getById", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestPlan getById(String id) {
- return modelService.selectByPrimaryKey(id);
- }
- /**
- * 前端根据id获取数据
- *
- * @param id
- * @return
- */
- @PostMapping(value = "getVoById", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestPlanIn getVoById(String id) {
- return modelService.getVoById(id);
- }
- /**
- * 前端根据ids获取数据, ids是类似数组的字符串,例如:1684651,6431,或者:135456135 又或者:1651631,等
- *
- * @param ids
- * @return
- */
- @PostMapping(value = "getVoByIds", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public List<TestPlanIn> getVoByIds(String ids) {
- return modelService.getVoByIds(ids);
- }
- }
- package com.idea.oa.testPlan.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.model.TestUsecase;
- import com.idea.oa.testPlan.model.TestUsecaseStep;
- import com.idea.oa.testPlan.model.TestUsecaseStepExample;
- import com.idea.oa.testPlan.model.in.TestUsecaseIn;
- import com.idea.oa.testPlan.service.TestUsecaseService;
- import com.idea.oa.testPlan.service.TestUsecaseStepService;
- import com.rockstar.common.base.BaseController;
- import com.rockstar.common.domain.AjaxResult;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.TableSplitResult;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.shiro.util.ShiroUtils;
- import io.swagger.annotations.Api;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.util.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by pengyq on 2020.
- */
- @Controller
- @RequestMapping(value = "TestUsecaseController")
- @Api(value = "测试管理/用例库")
- public class TestUsecaseController extends BaseController {
- //主表
- @Autowired
- private TestUsecaseService modelService;
- @Autowired
- private TestUsecaseStepService testUsecaseStepService;
- @PostMapping(value = "list", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object list(Tablepar tablepar, TestUsecase model, DateTrans dt) {
- PageInfo<TestUsecase> page = modelService.list(tablepar, model, dt);
- TableSplitResult<TestUsecase> result = new TableSplitResult<TestUsecase>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- /**
- * 测试管理/用例库下的列表展示
- *
- * @param tablepar
- * @param model
- * @param dt
- * @return
- */
- @PostMapping(value = "listVo", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listVo(Tablepar tablepar, TestUsecaseIn model, DateTrans dt) {
- PageInfo<TestUsecaseIn> page = modelService.listVo(tablepar, model, dt);
- TableSplitResult<TestUsecaseIn> result = new TableSplitResult<TestUsecaseIn>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- /**
- * 测试管理/用例库下的列表展示,并展示是否已经被某个测试计划id选中
- *
- * @param tablepar
- * @param model
- * @param dt
- * @return
- */
- @PostMapping(value = "listVoWithHasSelect", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listVoWithHasSelect(Tablepar tablepar, TestUsecaseIn model, DateTrans dt) {
- PageInfo<TestUsecaseIn> page = modelService.listVoWithHasSelect(tablepar, model, dt);
- TableSplitResult<TestUsecaseIn> result = new TableSplitResult<TestUsecaseIn>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- @PostMapping(value = "listAll", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listAll(TestUsecase model, DateTrans dt) {
- return modelService.listAll(model, dt);
- }
- /**
- * 导出用例时获取所有数据
- *
- * @param model
- * @param dt
- * @return
- */
- @PostMapping(value = "findAllByInfo", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object findAllByInfo(TestUsecaseIn model, DateTrans dt) {
- return modelService.findAllByInfo(model, dt);
- }
- @PostMapping(value = "add", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult add(TestUsecaseIn record) {
- System.out.println("add start");
- // System.out.println(testUsecaseSteps);
- System.out.println(record);
- record.setCreatedAt(new Date());
- record.setUpdatedAt(record.getCreatedAt());
- record.setCreatedBy(ShiroUtils.getUser().getId());
- record.setUpdatedBy(record.getCreatedBy());
- record.setStatus(0);
- String usecaseId = modelService.insertReturnId(record);
- if (record != null) {
- if (record.getTestUsecaseSteps() != null) {
- List<TestUsecaseStep> list = JSONArray.parseArray(record.getTestUsecaseSteps(), TestUsecaseStep.class);
- System.out.println(list);
- TestUsecaseStep testUsecaseStep = null;
- for (int i = 0; i < list.size(); i++) {
- testUsecaseStep = list.get(i);
- testUsecaseStep.setUsecaseId(usecaseId);
- // if (StringUtils.isEmpty(testUsecaseStep.getId())) {
- testUsecaseStep.setCreatedAt(new Date());
- testUsecaseStep.setUpdatedAt(record.getCreatedAt());
- testUsecaseStep.setCreatedBy(ShiroUtils.getUser().getId());
- testUsecaseStep.setUpdatedBy(record.getCreatedBy());
- testUsecaseStep.setStatus(0);
- testUsecaseStepService.insert(testUsecaseStep);
- // } else {
- // record.setUpdatedAt(new Date());
- // record.setUpdatedBy(ShiroUtils.getUser().getId());
- // testUsecaseStepService.updateByPrimaryKeySelective(testUsecaseStep);
- // }
- }
- }
- return this.success();
- } else {
- return this.error();
- }
- }
- @PostMapping(value = "remove/{id}", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult remove(@PathVariable("id") String id) {
- // int result = modelService.deleteByPrimaryKey(id);
- TestUsecase record = new TestUsecase();
- record.setId(id);
- record.setStatus(1);
- record.setUpdatedBy(ShiroUtils.getUser().getId());
- record.setUpdatedAt(new Date());
- int result = modelService.updateByPrimaryKeySelective(record);
- TestUsecaseStep testUsecaseStep = new TestUsecaseStep();
- testUsecaseStep.setStatus(1);
- testUsecaseStep.setUpdatedBy(ShiroUtils.getUser().getId());
- testUsecaseStep.setUpdatedAt(new Date());
- TestUsecaseStepExample testUsecaseStepExample = new TestUsecaseStepExample();
- testUsecaseStepExample.createCriteria().andUsecaseIdEqualTo(id);
- testUsecaseStepService.updateByExampleSelective(testUsecaseStep, testUsecaseStepExample);
- return result(result);
- }
- @PostMapping(value = "edit", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult editSave(TestUsecaseIn record) {
- System.out.println("edit start");
- // System.out.println(testUsecaseSteps);
- System.out.println(record);
- record.setUpdatedBy(ShiroUtils.getUser().getId());
- record.setUpdatedAt(new Date());
- record.setCreatedAt(null);
- record.setCreatedBy(null);
- record.setStatus(null);
- int result = modelService.updateByPrimaryKeySelective(record);
- if (result > 0) {//修改成功
- //如果修改成功进行下面的操作
- //1.修改或者添加步骤并把步骤id记录下来,最后删除步骤id以外的丢弃步骤
- ArrayList<String> inids = new ArrayList<>();
- if (record.getTestUsecaseSteps() != null) {
- List<TestUsecaseStep> list = JSONArray.parseArray(record.getTestUsecaseSteps(), TestUsecaseStep.class);
- // System.out.println(list);
- TestUsecaseStep testUsecaseStep = null;
- for (int i = 0; i < list.size(); i++) {
- testUsecaseStep = list.get(i);
- testUsecaseStep.setUsecaseId(record.getId());
- if (StringUtils.isEmpty(testUsecaseStep.getId())) {
- testUsecaseStep.setCreatedAt(new Date());
- testUsecaseStep.setUpdatedAt(record.getCreatedAt());
- testUsecaseStep.setCreatedBy(ShiroUtils.getUser().getId());
- testUsecaseStep.setUpdatedBy(record.getCreatedBy());
- testUsecaseStep.setStatus(0);
- String s = testUsecaseStepService.insertReturnId(testUsecaseStep);
- if (s != null) {
- inids.add(s);
- }
- } else {
- inids.add(testUsecaseStep.getId());
- testUsecaseStep.setUpdatedAt(new Date());
- testUsecaseStep.setUpdatedBy(ShiroUtils.getUser().getId());
- testUsecaseStepService.updateByPrimaryKeySelective(testUsecaseStep);
- }
- }
- }
- TestUsecaseStep testUsecaseStep = new TestUsecaseStep();
- testUsecaseStep.setStatus(1);
- testUsecaseStep.setUpdatedBy(ShiroUtils.getUser().getId());
- testUsecaseStep.setUpdatedAt(new Date());
- TestUsecaseStepExample testUsecaseStepExample = new TestUsecaseStepExample();
- testUsecaseStepExample.createCriteria().andUsecaseIdEqualTo(record.getId()).andIdNotIn(inids);
- testUsecaseStepService.updateByExampleSelective(testUsecaseStep, testUsecaseStepExample);
- } else {//修改失败
- }
- // int result = modelService.updateByPrimaryKeySelective(model);
- return result(result);
- }
- @PostMapping(value = "getById", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestUsecase getById(String id) {
- return modelService.selectByPrimaryKey(id);
- }
- @PostMapping(value = "test", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object getTest() {
- System.out.println("test");
- return null;
- }
- @PostMapping(value = "getVoById", produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestUsecaseIn getVoById(String id) {
- return modelService.getVoById(id);
- }
- }
- package com.idea.oa.testPlan.service;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.mapper.TestPlanExtendMapper;
- import com.idea.oa.testPlan.mapper.TestPlanMapper;
- import com.idea.oa.testPlan.model.TestPlan;
- import com.idea.oa.testPlan.model.TestPlanExample;
- import com.idea.oa.testPlan.model.in.TestPlanIn;
- import com.rockstar.common.base.BaseService;
- import com.rockstar.common.support.Convert;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.util.DateUtils;
- import com.rockstar.util.SnowflakeIdWorker;
- import com.rockstar.util.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Date;
- import java.util.List;
- @Service
- public class TestPlanService implements BaseService<TestPlan, TestPlanExample> {
- //文件mapper
- @Autowired
- private TestPlanMapper modelMapper;
- @Autowired
- private TestPlanExtendMapper testPlanExtendMapper;
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<TestPlan> list(Tablepar tablepar, TestPlan model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestPlan> list = modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<TestPlan> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 查询指定
- *
- * @return
- */
- public List<TestPlan> listAll(TestPlan model, DateTrans dt) {
- return modelMapper.selectByExample(getCondition(model,dt));
- }
- private TestPlanExample getCondition(TestPlan model, DateTrans dt) {
- TestPlanExample ex = new TestPlanExample();
- ex.setOrderByClause("created_at asc");
- TestPlanExample.Criteria criteria = ex.createCriteria();
- if(StringUtils.isNotEmpty(model.getPlanName())){
- criteria.andPlanNameLike("%"+model.getPlanName()+"%");
- }
- if(StringUtils.isNotEmpty(model.getProId())){
- criteria.andProIdEqualTo(model.getProId());
- }
- if(StringUtils.isNotEmpty(model.getTaskNo())){
- criteria.andTaskNoEqualTo(model.getTaskNo());
- }
- if(dt != null){
- if(StringUtils.isNotEmpty(dt.getDate_from_1())){
- criteria.andCreatedAtGreaterThanOrEqualTo(DateUtils.string2Date(dt.getDate_from_1()));
- }
- if(StringUtils.isNotEmpty(dt.getDate_to_1())){
- criteria.andCreatedAtLessThanOrEqualTo(DateUtils.string2Date(dt.getDate_to_1()));
- }
- }
- return ex;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> lista = Convert.toListStrArray(ids);
- TestPlanExample example = new TestPlanExample();
- example.createCriteria().andIdIn(lista);
- return modelMapper.deleteByExample(example);
- }
- @Override
- public TestPlan selectByPrimaryKey(String id) {
- return modelMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(TestPlan record) {
- return modelMapper.updateByPrimaryKeySelective(record);
- }
- @Override
- public int updateByExampleSelective(TestPlan record, TestPlanExample example) {
- return modelMapper.updateByExampleSelective(record, example);
- }
- @Override
- public int updateByExample(TestPlan record, TestPlanExample example) {
- return modelMapper.updateByExample(record, example);
- }
- @Override
- public List<TestPlan> selectByExample(TestPlanExample example) {
- return modelMapper.selectByExample(example);
- }
- @Override
- public long countByExample(TestPlanExample example) {
- return modelMapper.countByExample(example);
- }
- public long countByExample(TestPlan model, DateTrans dt) {
- return modelMapper.countByExample(getCondition(model,dt));
- }
- @Override
- public int deleteByExample(TestPlanExample example) {
- return modelMapper.deleteByExample(example);
- }
- public int insert(TestPlan record){
- record.setId(SnowflakeIdWorker.getUUID());
- return insertWithoutId(record);
- }
- public int insertWithoutId(TestPlan record){
- return modelMapper.insert(record);
- }
- @Override
- public int insertSelective(TestPlan record) {
- record.setId(SnowflakeIdWorker.getUUID());
- record.setCreatedAt(new Date());
- return modelMapper.insertSelective(record);
- }
- public List<TestPlanIn> listVo(Tablepar tablepar, TestPlanIn model, DateTrans dt) {
- int i = (tablepar.getPageNum() - 1) * tablepar.getPageSize();
- tablepar.setPageNum(i);
- List<TestPlanIn> list=testPlanExtendMapper.listVo(tablepar, model, dt);
- return list;
- }
- public Long getTotal(TestPlanIn model, DateTrans dt) {
- return testPlanExtendMapper.getTotal( model, dt);
- }
- public TestPlanIn getVoById(String id) {
- if (StringUtils.isEmpty(id)){
- return null;
- }
- TestPlanIn testPlanIn = new TestPlanIn();
- testPlanIn.setId(id);
- List<TestPlanIn> testPlanIns = testPlanExtendMapper.listVo(new Tablepar(), testPlanIn, new DateTrans());
- if (testPlanIns.isEmpty()){
- return null;
- }else{
- return testPlanIns.get(0);
- }
- }
- /**
- * 前端根据ids获取数据, ids是类似数组的字符串,例如:1684651,6431,或者:135456135 又或者:1651631,等
- * @param ids
- * @return
- */
- public List<TestPlanIn> getVoByIds(String ids) {
- if (StringUtils.isEmpty(ids)){
- return null;
- }
- String[] split = ids.split(",");
- TestPlanIn testPlanIn = new TestPlanIn();
- testPlanIn.setIds(split);
- List<TestPlanIn> testPlanIns = testPlanExtendMapper.listVo(new Tablepar(), testPlanIn, new DateTrans());
- if (testPlanIns.isEmpty()){
- return null;
- }else{
- return testPlanIns;
- }
- }
- }
- package com.idea.oa.testPlan.service;
- import com.alibaba.fastjson.JSONArray;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.mapper.TestUsecaseExtendMapper;
- import com.idea.oa.testPlan.mapper.TestUsecaseMapper;
- import com.idea.oa.testPlan.model.TestUsecase;
- import com.idea.oa.testPlan.model.TestUsecaseExample;
- import com.idea.oa.testPlan.model.in.TestUsecaseIn;
- import com.rockstar.common.base.BaseService;
- import com.rockstar.common.support.Convert;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.util.DateUtils;
- import com.rockstar.util.SnowflakeIdWorker;
- import com.rockstar.util.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- @Service
- public class TestUsecaseService implements BaseService<TestUsecase, TestUsecaseExample> {
- //文件mapper
- @Autowired
- private TestUsecaseMapper modelMapper;
- @Autowired
- private TestUsecaseExtendMapper testUsecaseExtendMapper;
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<TestUsecase> list(Tablepar tablepar, TestUsecase model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestUsecase> list = modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<TestUsecase> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 查询指定
- *
- * @return
- */
- public List<TestUsecase> listAll(TestUsecase model, DateTrans dt) {
- return modelMapper.selectByExample(getCondition(model,dt));
- }
- private TestUsecaseExample getCondition(TestUsecase model, DateTrans dt) {
- TestUsecaseExample ex = new TestUsecaseExample();
- ex.setOrderByClause("created_at asc");
- TestUsecaseExample.Criteria criteria = ex.createCriteria();
- if(StringUtils.isNotEmpty(model.getUsecaseTitle())){
- criteria.andUsecaseTitleLike("%"+model.getUsecaseTitle()+"%");
- }
- if(model.getIdPro()!=null){
- criteria.andIdProEqualTo(model.getIdPro());
- }
- if(dt != null){
- if(StringUtils.isNotEmpty(dt.getDate_from_1())){
- criteria.andCreatedAtGreaterThanOrEqualTo(DateUtils.string2Date(dt.getDate_from_1()));
- }
- if(StringUtils.isNotEmpty(dt.getDate_to_1())){
- criteria.andCreatedAtLessThanOrEqualTo(DateUtils.string2Date(dt.getDate_to_1()));
- }
- }
- return ex;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> lista = Convert.toListStrArray(ids);
- TestUsecaseExample example = new TestUsecaseExample();
- example.createCriteria().andIdIn(lista);
- return modelMapper.deleteByExample(example);
- }
- @Override
- public TestUsecase selectByPrimaryKey(String id) {
- return modelMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(TestUsecase record) {
- return modelMapper.updateByPrimaryKeySelective(record);
- }
- @Override
- public int updateByExampleSelective(TestUsecase record, TestUsecaseExample example) {
- return modelMapper.updateByExampleSelective(record, example);
- }
- @Override
- public int updateByExample(TestUsecase record, TestUsecaseExample example) {
- return modelMapper.updateByExample(record, example);
- }
- @Override
- public List<TestUsecase> selectByExample(TestUsecaseExample example) {
- return modelMapper.selectByExample(example);
- }
- @Override
- public long countByExample(TestUsecaseExample example) {
- return modelMapper.countByExample(example);
- }
- public long countByExample(TestUsecase model, DateTrans dt) {
- return modelMapper.countByExample(getCondition(model,dt));
- }
- @Override
- public int deleteByExample(TestUsecaseExample example) {
- return modelMapper.deleteByExample(example);
- }
- public int insert(TestUsecase record){
- // record.setCreatedAt(new Date());
- // record.setUpdatedAt(record.getCreatedAt());
- // record.setCreatedBy(ShiroUtils.getUser().getId());
- // record.setUpdatedBy(record.getCreatedBy());
- // record.setStatus(0);
- record.setId(SnowflakeIdWorker.getUUID());
- return insertWithoutId(record);
- }
- public String insertReturnId(TestUsecase record){
- record.setId(SnowflakeIdWorker.getUUID());
- int i = insertWithoutId(record);
- if (i>0){
- return record.getId();
- }else{
- return null;
- }
- }
- public int insertWithoutId(TestUsecase record){
- // record.setCreatedAt(new Date());
- return modelMapper.insert(record);
- }
- @Override
- public int insertSelective(TestUsecase record) {
- record.setId(SnowflakeIdWorker.getUUID());
- record.setCreatedAt(new Date());
- return modelMapper.insertSelective(record);
- }
- public PageInfo<TestUsecaseIn> listVo(Tablepar tablepar, TestUsecaseIn model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestUsecaseIn> list = testUsecaseExtendMapper.selectMoreByInfo(model,dt);
- PageInfo<TestUsecaseIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public TestUsecaseIn getVoById(String id) {
- return testUsecaseExtendMapper.getVoById(id);
- }
- /**
- * 导出用例时获取所有数据
- * @param model
- * @param dt
- * @return
- */
- public List<Map<String, Object>> findAllByInfo(TestUsecaseIn model, DateTrans dt) {
- // System.out.println(model);
- List<String> ids=null;
- if (model.getIdList() != null) {
- ids = JSONArray.parseArray(model.getIdList(), String.class);
- // ids = Convert.toListStrArray(model.getIdList());
- // for (String id : ids) {
- // System.out.println("获取数据:"+id);
- // }
- }
- return testUsecaseExtendMapper.findAllByInfo(model,ids, dt);
- }
- public PageInfo<TestUsecaseIn> listVoWithHasSelect(Tablepar tablepar, TestUsecaseIn model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestUsecaseIn> list = testUsecaseExtendMapper.listVoWithHasSelect(model,dt);
- PageInfo<TestUsecaseIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- }
- package com.idea.oa.testPlan.mapper;
- import com.idea.oa.testPlan.model.TestPlan;
- import com.idea.oa.testPlan.model.TestPlanExample;
- import java.util.List;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Component;
- @Component
- public interface TestPlanMapper {
- long countByExample(TestPlanExample example);
- int deleteByExample(TestPlanExample example);
- int deleteByPrimaryKey(String id);
- int insert(TestPlan record);
- int insertSelective(TestPlan record);
- List<TestPlan> selectByExample(TestPlanExample example);
- TestPlan selectByPrimaryKey(String id);
- int updateByExampleSelective(@Param("record") TestPlan record, @Param("example") TestPlanExample example);
- int updateByExample(@Param("record") TestPlan record, @Param("example") TestPlanExample example);
- int updateByPrimaryKeySelective(TestPlan record);
- int updateByPrimaryKey(TestPlan record);
- }
- package com.idea.oa.testPlan.mapper;
- import com.idea.oa.testPlan.model.TestUsecase;
- import com.idea.oa.testPlan.model.TestUsecaseExample;
- import java.util.List;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Component;
- @Component
- public interface TestUsecaseMapper {
- long countByExample(TestUsecaseExample example);
- int deleteByExample(TestUsecaseExample example);
- int deleteByPrimaryKey(String id);
- int insert(TestUsecase record);
- int insertSelective(TestUsecase record);
- List<TestUsecase> selectByExample(TestUsecaseExample example);
- TestUsecase selectByPrimaryKey(String id);
- int updateByExampleSelective(@Param("record") TestUsecase record, @Param("example") TestUsecaseExample example);
- int updateByExample(@Param("record") TestUsecase record, @Param("example") TestUsecaseExample example);
- int updateByPrimaryKeySelective(TestUsecase record);
- int updateByPrimaryKey(TestUsecase record);
- }
- package com.idea.oa.testPlan.controller;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.model.TestPlanCommander;
- import com.idea.oa.testPlan.service.TestPlanCommanderService;
- import com.rockstar.common.base.BaseController;
- import com.rockstar.common.domain.AjaxResult;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.TableSplitResult;
- import com.rockstar.frame.model.extend.Tablepar;
- import io.swagger.annotations.Api;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import java.util.Date;
- /**
- * Created by pengyq on 2020.
- */
- @Controller
- @RequestMapping(value = "TestPlanCommanderController")
- @Api(value="测试管理/测试计划/负责人关联表")
- public class TestPlanCommanderController extends BaseController {
- //主表
- @Autowired
- private TestPlanCommanderService modelService;
- @PostMapping(value = "list",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object list(Tablepar tablepar, TestPlanCommander model, DateTrans dt){
- PageInfo<TestPlanCommander> page= modelService.list(tablepar,model,dt);
- TableSplitResult<TestPlanCommander> result=new TableSplitResult<TestPlanCommander>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- @PostMapping(value = "listAll",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listAll(TestPlanCommander model, DateTrans dt){
- return modelService.listAll(model,dt);
- }
- @PostMapping(value = "add",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult add(TestPlanCommander record){
- record.setCreatedAt(new Date());
- int result = modelService.insert(record);
- return result(result);
- }
- @PostMapping(value = "remove/{id}",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult remove(@PathVariable("id") String id){
- int result = modelService.deleteByPrimaryKey(id);
- return result(result);
- }
- @PostMapping(value = "edit",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult editSave(TestPlanCommander model){
- int result = modelService.updateByPrimaryKeySelective(model);
- return result(result);
- }
- @PostMapping(value = "getById",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestPlanCommander getById(String id) {
- return modelService.selectByPrimaryKey(id);
- }
- }
- package com.idea.oa.testPlan.service;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.mapper.TestPlanCommanderMapper;
- import com.idea.oa.testPlan.model.TestPlanCommander;
- import com.idea.oa.testPlan.model.TestPlanCommanderExample;
- import com.rockstar.common.base.BaseService;
- import com.rockstar.common.support.Convert;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.util.DateUtils;
- import com.rockstar.util.SnowflakeIdWorker;
- import com.rockstar.util.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Date;
- import java.util.List;
- @Service
- public class TestPlanCommanderService implements BaseService<TestPlanCommander, TestPlanCommanderExample> {
- //文件mapper
- @Autowired
- private TestPlanCommanderMapper modelMapper;
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<TestPlanCommander> list(Tablepar tablepar, TestPlanCommander model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestPlanCommander> list = modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<TestPlanCommander> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 查询指定
- *
- * @return
- */
- public List<TestPlanCommander> listAll(TestPlanCommander model, DateTrans dt) {
- return modelMapper.selectByExample(getCondition(model,dt));
- }
- private TestPlanCommanderExample getCondition(TestPlanCommander model, DateTrans dt) {
- TestPlanCommanderExample ex = new TestPlanCommanderExample();
- ex.setOrderByClause("created_at asc");
- TestPlanCommanderExample.Criteria criteria = ex.createCriteria();
- // if(StringUtils.isNotEmpty(model.getPlanName())){
- // criteria.andPlanNameLike("%"+model.getPlanName()+"%");
- // }
- // if(StringUtils.isNotEmpty(model.getProId())){
- // criteria.andProIdEqualTo(model.getProId());
- // }
- if(StringUtils.isNotEmpty(model.getPlanId())){
- criteria.andPlanIdEqualTo(model.getPlanId());
- }
- if(dt != null){
- if(StringUtils.isNotEmpty(dt.getDate_from_1())){
- criteria.andCreatedAtGreaterThanOrEqualTo(DateUtils.string2Date(dt.getDate_from_1()));
- }
- if(StringUtils.isNotEmpty(dt.getDate_to_1())){
- criteria.andCreatedAtLessThanOrEqualTo(DateUtils.string2Date(dt.getDate_to_1()));
- }
- }
- return ex;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> lista = Convert.toListStrArray(ids);
- TestPlanCommanderExample example = new TestPlanCommanderExample();
- example.createCriteria().andIdIn(lista);
- return modelMapper.deleteByExample(example);
- }
- @Override
- public TestPlanCommander selectByPrimaryKey(String id) {
- return modelMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(TestPlanCommander record) {
- return modelMapper.updateByPrimaryKeySelective(record);
- }
- @Override
- public int updateByExampleSelective(TestPlanCommander record, TestPlanCommanderExample example) {
- return modelMapper.updateByExampleSelective(record, example);
- }
- @Override
- public int updateByExample(TestPlanCommander record, TestPlanCommanderExample example) {
- return modelMapper.updateByExample(record, example);
- }
- @Override
- public List<TestPlanCommander> selectByExample(TestPlanCommanderExample example) {
- return modelMapper.selectByExample(example);
- }
- @Override
- public long countByExample(TestPlanCommanderExample example) {
- return modelMapper.countByExample(example);
- }
- public long countByExample(TestPlanCommander model, DateTrans dt) {
- return modelMapper.countByExample(getCondition(model,dt));
- }
- @Override
- public int deleteByExample(TestPlanCommanderExample example) {
- return modelMapper.deleteByExample(example);
- }
- public int insert(TestPlanCommander record){
- record.setId(SnowflakeIdWorker.getUUID());
- return insertWithoutId(record);
- }
- public int insertWithoutId(TestPlanCommander record){
- record.setCreatedAt(new Date());
- return modelMapper.insert(record);
- }
- @Override
- public int insertSelective(TestPlanCommander record) {
- record.setId(SnowflakeIdWorker.getUUID());
- record.setCreatedAt(new Date());
- return modelMapper.insertSelective(record);
- }
- }
- package com.idea.oa.testPlan.mapper;
- import com.idea.oa.testPlan.model.TestPlanCommander;
- import com.idea.oa.testPlan.model.TestPlanCommanderExample;
- import java.util.List;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.stereotype.Component;
- @Component
- public interface TestPlanCommanderMapper {
- long countByExample(TestPlanCommanderExample example);
- int deleteByExample(TestPlanCommanderExample example);
- int deleteByPrimaryKey(String id);
- int insert(TestPlanCommander record);
- int insertSelective(TestPlanCommander record);
- List<TestPlanCommander> selectByExample(TestPlanCommanderExample example);
- TestPlanCommander selectByPrimaryKey(String id);
- int updateByExampleSelective(@Param("record") TestPlanCommander record, @Param("example") TestPlanCommanderExample example);
- int updateByExample(@Param("record") TestPlanCommander record, @Param("example") TestPlanCommanderExample example);
- int updateByPrimaryKeySelective(TestPlanCommander record);
- int updateByPrimaryKey(TestPlanCommander record);
- }
- package com.idea.oa.testPlan.controller;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.model.TestUsecaseStep;
- import com.idea.oa.testPlan.service.TestUsecaseStepService;
- import com.rockstar.common.base.BaseController;
- import com.rockstar.common.domain.AjaxResult;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.TableSplitResult;
- import com.rockstar.frame.model.extend.Tablepar;
- import io.swagger.annotations.Api;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by pengyq on 2020.
- */
- @Controller
- @RequestMapping(value = "TestUsecaseStepController")
- @Api(value="测试管理/用例库/用例步骤详细关联表")
- public class TestUsecaseStepController extends BaseController {
- //主表
- @Autowired
- private TestUsecaseStepService modelService;
- @PostMapping(value = "list",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object list(Tablepar tablepar, TestUsecaseStep model, DateTrans dt){
- PageInfo<TestUsecaseStep> page= modelService.list(tablepar,model,dt);
- TableSplitResult<TestUsecaseStep> result=new TableSplitResult<TestUsecaseStep>(page.getPageNum(), page.getTotal(), page.getList());
- return result;
- }
- @PostMapping(value = "listAll",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public Object listAll(TestUsecaseStep model, DateTrans dt){
- return modelService.listAll(model,dt);
- }
- /**
- * 通过usecaseid来获取所有的步骤
- * @param model
- * @return
- */
- @PostMapping(value = "/findListByUsecaseId",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public List<TestUsecaseStep> findListByUsecaseId(TestUsecaseStep model){
- return modelService.findListByUsecaseId(model);
- }
- @PostMapping(value = "add",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult add(TestUsecaseStep record){
- record.setCreatedAt(new Date());
- int result = modelService.insert(record);
- return result(result);
- }
- @PostMapping(value = "remove/{id}",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult remove(@PathVariable("id") String id){
- int result = modelService.deleteByPrimaryKey(id);
- return result(result);
- }
- @PostMapping(value = "edit",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public AjaxResult editSave(TestUsecaseStep model){
- int result = modelService.updateByPrimaryKeySelective(model);
- return result(result);
- }
- @PostMapping(value = "getById",produces = {"application/json;charset=UTF-8"})
- @ResponseBody
- public TestUsecaseStep getById(String id) {
- return modelService.selectByPrimaryKey(id);
- }
- }
- package com.idea.oa.testPlan.service;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.testPlan.mapper.TestUsecaseStepMapper;
- import com.idea.oa.testPlan.model.TestUsecaseStep;
- import com.idea.oa.testPlan.model.TestUsecaseStepExample;
- import com.rockstar.common.base.BaseService;
- import com.rockstar.common.support.Convert;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.util.DateUtils;
- import com.rockstar.util.SnowflakeIdWorker;
- import com.rockstar.util.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Date;
- import java.util.List;
- @Service
- public class TestUsecaseStepService implements BaseService<TestUsecaseStep, TestUsecaseStepExample> {
- //文件mapper
- @Autowired
- private TestUsecaseStepMapper modelMapper;
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<TestUsecaseStep> list(Tablepar tablepar, TestUsecaseStep model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<TestUsecaseStep> list = modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<TestUsecaseStep> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 查询指定
- *
- * @return
- */
- public List<TestUsecaseStep> listAll(TestUsecaseStep model, DateTrans dt) {
- return modelMapper.selectByExample(getCondition(model,dt));
- }
- private TestUsecaseStepExample getCondition(TestUsecaseStep model, DateTrans dt) {
- TestUsecaseStepExample ex = new TestUsecaseStepExample();
- ex.setOrderByClause("created_at asc");
- TestUsecaseStepExample.Criteria criteria = ex.createCriteria();
- // if(StringUtils.isNotEmpty(model.getPlanName())){
- // criteria.andPlanNameLike("%"+model.getPlanName()+"%");
- // }
- if(StringUtils.isNotEmpty(model.getUsecaseId())){
- criteria.andUsecaseIdEqualTo(model.getUsecaseId());
- }
- // if(StringUtils.isNotEmpty(model.getTaskNo())){
- // criteria.andTaskNoEqualTo(model.getTaskNo());
- // }
- if(dt != null){
- if(StringUtils.isNotEmpty(dt.getDate_from_1())){
- criteria.andCreatedAtGreaterThanOrEqualTo(DateUtils.string2Date(dt.getDate_from_1()));
- }
- if(StringUtils.isNotEmpty(dt.getDate_to_1())){
- criteria.andCreatedAtLessThanOrEqualTo(DateUtils.string2Date(dt.getDate_to_1()));
- }
- }
- return ex;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> lista = Convert.toListStrArray(ids);
- TestUsecaseStepExample example = new TestUsecaseStepExample();
- example.createCriteria().andIdIn(lista);
- return modelMapper.deleteByExample(example);
- }
- @Override
- public TestUsecaseStep selectByPrimaryKey(String id) {
- return modelMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(TestUsecaseStep record) {
- return modelMapper.updateByPrimaryKeySelective(record);
- }
- @Override
- public int updateByExampleSelective(TestUsecaseStep record, TestUsecaseStepExample example) {
- return modelMapper.updateByExampleSelective(record, example);
- }
- @Override
- public int updateByExample(TestUsecaseStep record, TestUsecaseStepExample example) {
- return modelMapper.updateByExample(record, example);
- }
- @Override
- public List<TestUsecaseStep> selectByExample(TestUsecaseStepExample example) {
- return modelMapper.selectByExample(example);
- }
- @Override
- public long countByExample(TestUsecaseStepExample example) {
- return modelMapper.countByExample(example);
- }
- public long countByExample(TestUsecaseStep model, DateTrans dt) {
- return modelMapper.countByExample(getCondition(model,dt));
- }
- @Override
- public int deleteByExample(TestUsecaseStepExample example) {
- return modelMapper.deleteByExample(example);
- }
- public int insert(TestUsecaseStep record){
- record.setId(SnowflakeIdWorker.getUUID());
- return insertWithoutId(record);
- }
- public String insertReturnId(TestUsecaseStep record){
- record.setId(SnowflakeIdWorker.getUUID());
- int i = insertWithoutId(record);
- if (i>0){
- return record.getId();
- }else{
- return null;
- }
- }
- public int insertWithoutId(TestUsecaseStep record){
- // record.setCreatedAt(new Date());
- return modelMapper.insert(record);
- }
- @Override
- public int insertSelective(TestUsecaseStep record) {
- record.setId(SnowflakeIdWorker.getUUID());
- record.setCreatedAt(new Date());
- return modelMapper.insertSelective(record);
- }
- public List<TestUsecaseStep> findListByUsecaseId(TestUsecaseStep model) {
- TestUsecaseStepExample ex = new TestUsecaseStepExample();
- ex.setOrderByClause("step_number asc");
- TestUsecaseStepExample.Criteria criteria = ex.createCriteria();
- // if(StringUtils.isNotEmpty(model.getUsecaseId())){
- criteria.andUsecaseIdEqualTo(model.getUsecaseId());
- // }
- criteria.andStatusEqualTo(0);
- return modelMapper.selectByExample(ex);
- }
- }
- package com.idea.oa.testPlan.mapper;
- import com.idea.oa.testPlan.model.TestUsecaseStep;
- import com.idea.oa.testPlan.model.TestUsecaseStepExample;
- import java.util.List;
- import org.apache.ibatis.annotations.Param;
- public interface TestUsecaseStepMapper {
- long countByExample(TestUsecaseStepExample example);
- int deleteByExample(TestUsecaseStepExample example);
- int deleteByPrimaryKey(String id);
- int insert(TestUsecaseStep record);
- int insertSelective(TestUsecaseStep record);
- List<TestUsecaseStep> selectByExample(TestUsecaseStepExample example);
- TestUsecaseStep selectByPrimaryKey(String id);
- int updateByExampleSelective(@Param("record") TestUsecaseStep record, @Param("example") TestUsecaseStepExample example);
- int updateByExample(@Param("record") TestUsecaseStep record, @Param("example") TestUsecaseStepExample example);
- int updateByPrimaryKeySelective(TestUsecaseStep record);
- int updateByPrimaryKey(TestUsecaseStep record);
- }
|