From cb0f87817f5e2f7d734a5568cf9f6ea46434131b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A3=95=E8=B4=A2?= Date: Fri, 1 Jul 2022 14:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E3=80=81=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E6=B8=85=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xm/core/ctrl/XmRecordVisitController.java | 296 ++++++++++++++++++ .../ctrl/XmTaskAccessRecordController.java | 48 +++ .../com/xm/core/entity/XmRecordVisit.java | 74 +++++ .../xm/core/service/XmRecordVisitService.java | 24 ++ .../xm/core/dao/XmRecordVisitMapper.xml | 208 ++++++++++++ 5 files changed, 650 insertions(+) create mode 100644 xm-core/src/main/java/com/xm/core/ctrl/XmRecordVisitController.java create mode 100644 xm-core/src/main/java/com/xm/core/ctrl/XmTaskAccessRecordController.java create mode 100644 xm-core/src/main/java/com/xm/core/entity/XmRecordVisit.java create mode 100644 xm-core/src/main/java/com/xm/core/service/XmRecordVisitService.java create mode 100644 xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRecordVisitMapper.xml diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmRecordVisitController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmRecordVisitController.java new file mode 100644 index 00000000..72610da8 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmRecordVisitController.java @@ -0,0 +1,296 @@ +package com.xm.core.ctrl; + +import java.util.*; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.*; + +import static com.mdp.core.utils.ResponseHelper.*; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; +import com.mdp.mybatis.PageUtils; +import com.mdp.core.utils.RequestUtils; +import com.mdp.core.utils.NumberUtil; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; +import com.mdp.swagger.ApiEntityParams; +import springfox.documentation.annotations.ApiIgnore; + +import com.xm.core.service.XmRecordVisitService; +import com.xm.core.entity.XmRecordVisit; + +/** + * url编制采用rest风格,如对xm_record_visit 重要页面访问记录的操作有增删改查,对应的url分别为:
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRecordVisit 表 xm_record_visit 当前主键(包括多主键): id; + ***/ +@RestController("xm.core.xmRecordVisitController") +@RequestMapping(value="/**/core/xmRecordVisit") +@Api(tags={"重要页面访问记录操作接口"}) +public class XmRecordVisitController { + + static Logger logger =LoggerFactory.getLogger(XmRecordVisitController.class); + + @Autowired + private XmRecordVisitService xmRecordVisitService; + + + Map fieldsMap = toMap(new XmRecordVisit()); + + + @ApiOperation( value = "查询重要页面访问记录信息列表",notes=" ") + @ApiEntityParams( XmRecordVisit.class ) + @ApiImplicitParams({ + @ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false), + @ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), + @ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), + @ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false), + @ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false), + }) + @ApiResponses({ + @ApiResponse(code = 200,response=XmRecordVisit.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") + }) + @RequestMapping(value="/list",method=RequestMethod.GET) + public Map listXmRecordVisit( @ApiIgnore @RequestParam Map xmRecordVisit){ + Map m = new HashMap<>(); + Tips tips=new Tips("查询成功"); + RequestUtils.transformArray(xmRecordVisit, "ids"); + PageUtils.startPage(xmRecordVisit); + List> xmRecordVisitList = xmRecordVisitService.selectListMapByWhere(xmRecordVisit); //列出XmRecordVisit列表 + PageUtils.responePage(m, xmRecordVisitList); + m.put("data",xmRecordVisitList); + + m.put("tips", tips); + return m; + } + + + + /** + @ApiOperation( value = "新增一条重要页面访问记录信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmRecordVisit.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/add",method=RequestMethod.POST) + public Map addXmRecordVisit(@RequestBody XmRecordVisit xmRecordVisit) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功新增一条数据"); + try{ + boolean createPk=false; + if(!StringUtils.hasText(xmRecordVisit.getId())) { + createPk=true; + xmRecordVisit.setId(xmRecordVisitService.createKey("id")); + } + if(createPk==false){ + if(xmRecordVisitService.selectOneObject(xmRecordVisit) !=null ){ + return failed("pk-exists","编号重复,请修改编号再提交"); + } + } + xmRecordVisitService.insert(xmRecordVisit); + m.put("data",xmRecordVisit); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "删除一条重要页面访问记录信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") + }) + @RequestMapping(value="/del",method=RequestMethod.POST) + public Map delXmRecordVisit(@RequestBody XmRecordVisit xmRecordVisit){ + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除一条数据"); + try{ + if(!StringUtils.hasText(xmRecordVisit.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmRecordVisit xmRecordVisitDb = xmRecordVisitService.selectOneObject(xmRecordVisit); + if( xmRecordVisitDb == null ){ + return failed("data-not-exists","数据不存在,无法删除"); + } + xmRecordVisitService.deleteByPk(xmRecordVisit); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键修改一条重要页面访问记录信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmRecordVisit.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/edit",method=RequestMethod.POST) + public Map editXmRecordVisit(@RequestBody XmRecordVisit xmRecordVisit) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + if(!StringUtils.hasText(xmRecordVisit.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmRecordVisit xmRecordVisitDb = xmRecordVisitService.selectOneObject(xmRecordVisit); + if( xmRecordVisitDb == null ){ + return failed("data-not-exists","数据不存在,无法修改"); + } + xmRecordVisitService.updateSomeFieldByPk(xmRecordVisit); + m.put("data",xmRecordVisit); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "批量修改某些字段",notes="") + @ApiEntityParams( value = XmRecordVisit.class, props={ }, remark = "重要页面访问记录", paramType = "body" ) + @ApiResponses({ + @ApiResponse(code = 200,response=XmRecordVisit.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/editSomeFields",method=RequestMethod.POST) + public Map editSomeFields( @ApiIgnore @RequestBody Map xmRecordVisitMap) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + List ids= (List) xmRecordVisitMap.get("ids"); + if(ids==null || ids.size()==0){ + return failed("ids-0","ids不能为空"); + } + + Set fields=new HashSet<>(); + fields.add("id"); + for (String fieldName : xmRecordVisitMap.keySet()) { + if(fields.contains(fieldName)){ + return failed(fieldName+"-no-edit",fieldName+"不允许修改"); + } + } + Set fieldKey=xmRecordVisitMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); + fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmRecordVisitMap.get(i) )).collect(Collectors.toSet()); + + if(fieldKey.size()<=0) { + return failed("fieldKey-0","没有需要更新的字段"); + } + XmRecordVisit xmRecordVisit = fromMap(xmRecordVisitMap,XmRecordVisit.class); + List xmRecordVisitsDb=xmRecordVisitService.selectListByIds(ids); + if(xmRecordVisitsDb==null ||xmRecordVisitsDb.size()==0){ + return failed("data-0","记录已不存在"); + } + List can=new ArrayList<>(); + List no=new ArrayList<>(); + User user = LoginUtils.getCurrentUserInfo(); + for (XmRecordVisit xmRecordVisitDb : xmRecordVisitsDb) { + Tips tips2 = new Tips("检查通过"); + if(!tips2.isOk()){ + no.add(xmRecordVisitDb); + }else{ + can.add(xmRecordVisitDb); + } + } + if(can.size()>0){ + xmRecordVisitMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList())); + xmRecordVisitService.editSomeFields(xmRecordVisitMap); + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + msgs.add(String.format("成功更新以下%s条数据",can.size())); + } + if(no.size()>0){ + msgs.add(String.format("以下%s个数据无权限更新",no.size())); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + //m.put("data",xmMenu); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键列表批量删除重要页面访问记录信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") + }) + @RequestMapping(value="/batchDel",method=RequestMethod.POST) + public Map batchDelXmRecordVisit(@RequestBody List xmRecordVisits) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除"); + try{ + if(xmRecordVisits.size()<=0){ + return failed("data-0","请上送待删除数据列表"); + } + List datasDb=xmRecordVisitService.selectListByIds(xmRecordVisits.stream().map(i-> i.getId() ).collect(Collectors.toList())); + + List can=new ArrayList<>(); + List no=new ArrayList<>(); + for (XmRecordVisit data : datasDb) { + if(true){ + can.add(data); + }else{ + no.add(data); + } + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + xmRecordVisitService.batchDelete(can); + msgs.add(String.format("成功删除%s条数据.",can.size())); + } + + if(no.size()>0){ + msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(",")))); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ +} diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmTaskAccessRecordController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmTaskAccessRecordController.java new file mode 100644 index 00000000..abca2060 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmTaskAccessRecordController.java @@ -0,0 +1,48 @@ +package com.xm.core.ctrl; + +import com.mdp.core.utils.ResponseHelper; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; +import com.xm.core.entity.XmTask; +import com.xm.core.service.XmTaskService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * url编制采用rest风格,如对XM.xm_task xm_task的操作有增删改查,对应的url分别为:
+ * 新增: xm/xmTask/add
+ * 查询: xm/xmTask/list
+ * 模糊查询: xm/xmTask/listKey
+ * 修改: xm/xmTask/edit
+ * 删除: xm/xmTask/del
+ * 批量删除: xm/xmTask/batchDel
+ * 组织 com.qqkj 顶级模块 oa 大模块 xm 小模块
+ * 实体 XmTask 表 XM.xm_task 当前主键(包括多主键): id; + ***/ +@RestController("xm.core.xmTaskController") +@RequestMapping(value="/**/xm/core/xmTask") +@Api(tags={"任务操作接口"}) +public class XmTaskAccessRecordController { + + static Log logger=LogFactory.getLog(XmTaskAccessRecordController.class); + + + @Autowired + private XmTaskService xmTaskService; + + @ApiOperation("统计所有上级的进度情况") + @RequestMapping(value="/accessLog",method=RequestMethod.POST) + public Map calcProgress( @RequestBody XmTask xmTask){ + User user=LoginUtils.getCurrentUserInfo(); + return ResponseHelper.ok("成功"); + } +} diff --git a/xm-core/src/main/java/com/xm/core/entity/XmRecordVisit.java b/xm-core/src/main/java/com/xm/core/entity/XmRecordVisit.java new file mode 100644 index 00000000..3c42a7f4 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/entity/XmRecordVisit.java @@ -0,0 +1,74 @@ +package com.xm.core.entity; + +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; + +/** + * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRecordVisit所有属性名:
+ * "id","日志编号","operUserid","操作人id","operUsername","操作人名字","operTime","操作时间","objType","对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6","action","操作的id","remarks","备注-只描述新旧值之间的变化","gloNo","全局根踪号,用于跟踪日志","branchId","机构编号","ip","ip地址","bizId","业务主键编号","pbizId","对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号","bizName","对象名称";
+ * 当前主键(包括多主键):
+ * id;
+ */ + @Data +@ApiModel(description="重要页面访问记录") +public class XmRecordVisit implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes="日志编号,主键",allowEmptyValue=true,example="",allowableValues="") + String id; + + + @ApiModelProperty(notes="操作人id",allowEmptyValue=true,example="",allowableValues="") + String operUserid; + + @ApiModelProperty(notes="操作人名字",allowEmptyValue=true,example="",allowableValues="") + String operUsername; + + @ApiModelProperty(notes="操作时间",allowEmptyValue=true,example="",allowableValues="") + Date operTime; + + @ApiModelProperty(notes="对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代6",allowEmptyValue=true,example="",allowableValues="") + String objType; + + @ApiModelProperty(notes="操作的id",allowEmptyValue=true,example="",allowableValues="") + String action; + + @ApiModelProperty(notes="备注-只描述新旧值之间的变化",allowEmptyValue=true,example="",allowableValues="") + String remarks; + + @ApiModelProperty(notes="全局根踪号,用于跟踪日志",allowEmptyValue=true,example="",allowableValues="") + String gloNo; + + @ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") + String branchId; + + @ApiModelProperty(notes="ip地址",allowEmptyValue=true,example="",allowableValues="") + String ip; + + @ApiModelProperty(notes="业务主键编号",allowEmptyValue=true,example="",allowableValues="") + String bizId; + + @ApiModelProperty(notes="对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号",allowEmptyValue=true,example="",allowableValues="") + String pbizId; + + @ApiModelProperty(notes="对象名称",allowEmptyValue=true,example="",allowableValues="") + String bizName; + + /** + *日志编号 + **/ + public XmRecordVisit(String id) { + this.id = id; + } + + /** + * 重要页面访问记录 + **/ + public XmRecordVisit() { + } + +} \ No newline at end of file diff --git a/xm-core/src/main/java/com/xm/core/service/XmRecordVisitService.java b/xm-core/src/main/java/com/xm/core/service/XmRecordVisitService.java new file mode 100644 index 00000000..690ccc9e --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/service/XmRecordVisitService.java @@ -0,0 +1,24 @@ +package com.xm.core.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; +import org.springframework.stereotype.Service; +import com.mdp.core.service.BaseService; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; + +import com.xm.core.entity.XmRecordVisit; +/** + * 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRecordVisit 表 xm_record_visit 当前主键(包括多主键): id; + ***/ +@Service("xm.core.xmRecordVisitService") +public class XmRecordVisitService extends BaseService { + static Logger logger =LoggerFactory.getLogger(XmRecordVisitService.class); + +} + diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRecordVisitMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRecordVisitMapper.xml new file mode 100644 index 00000000..1667f4f7 --- /dev/null +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRecordVisitMapper.xml @@ -0,0 +1,208 @@ + + + + + + + + + and (res.id) in + + ( #{item}) + + + + + + + + + + + + + + + + + + + + + + + + + + insert into xm_record_visit( + + ) values ( + #{id},#{operUserid},#{operUsername},#{operTime},#{objType},#{action},#{remarks},#{gloNo},#{branchId},#{ip},#{bizId},#{pbizId},#{bizName} + ) + + + + + delete from xm_record_visit res + + + + + + + + delete from xm_record_visit + where id = #{id} + + + + + update xm_record_visit + + + + where id = #{id} + + + + + update xm_record_visit + + + + where id = #{id} + + + + + + + + update xm_record_visit + set + + where id = #{item.id} + + + + + + update xm_record_visit + + + + where (id) in + + ( #{item}) + + + + + delete from xm_record_visit + where + (id) in + + ( #{item.id} ) + + + + + + + id,oper_userid,oper_username,oper_time,obj_type,action,remarks,glo_no,branch_id,ip,biz_id,pbiz_id,biz_name + + + + + and res.id = #{id} + and res.oper_userid = #{operUserid} + and res.oper_username = #{operUsername} + and date_format(res.oper_time,'%Y-%m-%d') = date_format(#{operTime},'%Y-%m-%d') + and res.obj_type = #{objType} + and res.action = #{action} + and res.remarks = #{remarks} + and res.glo_no = #{gloNo} + and res.branch_id = #{branchId} + and res.ip = #{ip} + and res.biz_id = #{bizId} + and res.pbiz_id = #{pbizId} + and res.biz_name = #{bizName} + + + + oper_userid = #{operUserid}, + oper_username = #{operUsername}, + oper_time = #{operTime}, + obj_type = #{objType}, + action = #{action}, + remarks = #{remarks}, + glo_no = #{gloNo}, + branch_id = #{branchId}, + ip = #{ip}, + biz_id = #{bizId}, + pbiz_id = #{pbizId}, + biz_name = #{bizName} + + + oper_userid = #{operUserid}, + oper_username = #{operUsername}, + oper_time = #{operTime}, + obj_type = #{objType}, + action = #{action}, + remarks = #{remarks}, + glo_no = #{gloNo}, + branch_id = #{branchId}, + ip = #{ip}, + biz_id = #{bizId}, + pbiz_id = #{pbizId}, + biz_name = #{bizName}, + + + + oper_userid = #{item.operUserid}, + oper_username = #{item.operUsername}, + oper_time = #{item.operTime}, + obj_type = #{item.objType}, + action = #{item.action}, + remarks = #{item.remarks}, + glo_no = #{item.gloNo}, + branch_id = #{item.branchId}, + ip = #{item.ip}, + biz_id = #{item.bizId}, + pbiz_id = #{item.pbizId}, + biz_name = #{item.bizName} + + \ No newline at end of file