6 changed files with 853 additions and 1 deletions
-
204xm-core-ui/src/views/xm/core/xmMenuComment/XmMenuCommentEdit.vue
-
296xm-core/src/main/java/com/xm/core/ctrl/XmMenuCommentController.java
-
5xm-core/src/main/java/com/xm/core/ctrl/XmQuestionController.java
-
93xm-core/src/main/java/com/xm/core/entity/XmMenuComment.java
-
24xm-core/src/main/java/com/xm/core/service/XmMenuCommentService.java
-
232xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMenuCommentMapper.xml
@ -0,0 +1,204 @@ |
|||
<template> |
|||
<section class="page-container padding"> |
|||
<el-row class="page-header"> |
|||
</el-row> |
|||
<el-row class="page-main" :style="{overflowX:'auto',height:maxTableHeight+'px'}" ref="table"> |
|||
<!--编辑界面 XmMenuComment 档案评论表--> |
|||
<el-form :model="editForm" label-width="120px" :rules="editFormRules" ref="editFormRef"> |
|||
<el-form-item label="主键" prop="id"> |
|||
<el-input v-model="editForm.id" placeholder="主键" :maxlength="50" @change="editSomeFields(editForm,'id',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="评论人" prop="userid"> |
|||
<el-input v-model="editForm.userid" placeholder="评论人" :maxlength="50" @change="editSomeFields(editForm,'userid',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="评论人姓名" prop="username"> |
|||
<el-input v-model="editForm.username" placeholder="评论人姓名" :maxlength="50" @change="editSomeFields(editForm,'username',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="星级" prop="star"> |
|||
<el-input v-model="editForm.star" placeholder="星级" :maxlength="1" @change="editSomeFields(editForm,'star',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="时间" prop="cdate"> |
|||
<el-date-picker type="date" placeholder="选择日期" v-model="editForm.cdate" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker> |
|||
</el-form-item> |
|||
<el-form-item label="需求编号" prop="menuId"> |
|||
<el-input v-model="editForm.menuId" placeholder="需求编号" :maxlength="50" @change="editSomeFields(editForm,'menuId',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="上级评论" prop="pid"> |
|||
<el-input v-model="editForm.pid" placeholder="上级评论" :maxlength="50" @change="editSomeFields(editForm,'pid',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="点赞数量" prop="ups"> |
|||
<el-input v-model="editForm.ups" placeholder="点赞数量" :maxlength="10"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="是否显示0否1是" prop="isShow"> |
|||
<el-input v-model="editForm.isShow" placeholder="是否显示0否1是" :maxlength="1" @change="editSomeFields(editForm,'isShow',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="回复用户编号" prop="toUserid"> |
|||
<el-input v-model="editForm.toUserid" placeholder="回复用户编号" :maxlength="50" @change="editSomeFields(editForm,'toUserid',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="回复用户名" prop="toUsername"> |
|||
<el-input v-model="editForm.toUsername" placeholder="回复用户名" :maxlength="50" @change="editSomeFields(editForm,'toUsername',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="层级0,1,2,3,4" prop="lvl"> |
|||
<el-input v-model="editForm.lvl" placeholder="层级0,1,2,3,4" :maxlength="1" @change="editSomeFields(editForm,'lvl',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="评论内容" prop="context"> |
|||
<el-input v-model="editForm.context" placeholder="评论内容" :maxlength="65535" @change="editSomeFields(editForm,'context',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="机构编号" prop="branchId"> |
|||
<el-input v-model="editForm.branchId" placeholder="机构编号" :maxlength="50" @change="editSomeFields(editForm,'branchId',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="ip地址" prop="ip"> |
|||
<el-input v-model="editForm.ip" placeholder="ip地址" :maxlength="50" @change="editSomeFields(editForm,'ip',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="城市编号" prop="cityId"> |
|||
<el-input v-model="editForm.cityId" placeholder="城市编号" :maxlength="50" @change="editSomeFields(editForm,'cityId',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="城市名称" prop="cityName"> |
|||
<el-input v-model="editForm.cityName" placeholder="城市名称" :maxlength="50" @change="editSomeFields(editForm,'cityName',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="状态0未审核,1已审核,3审核不通过" prop="status"> |
|||
<el-input v-model="editForm.status" placeholder="状态0未审核,1已审核,3审核不通过" :maxlength="1" @change="editSomeFields(editForm,'status',$event)"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="儿子节点数量" prop="childNums"> |
|||
<el-input-number v-model="editForm.childNums" :min="0" :max="200"></el-input-number> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-row> |
|||
|
|||
<el-row v-if="opType=='add'" class="page-bottom bottom-fixed"> |
|||
<el-button @click.native="handleCancel">取消</el-button> |
|||
<el-button v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="load.edit==true">提交</el-button> |
|||
</el-row> |
|||
</section> |
|||
</template> |
|||
|
|||
<script> |
|||
import util from '@/common/js/util';//全局公共库 |
|||
import config from "@/common/config"; //全局公共库import |
|||
import { initDicts, addXmMenuComment,editXmMenuComment,editSomeFieldsXmMenuComment } from '@/api/xm/core/xmMenuComment'; |
|||
import { mapGetters } from 'vuex' |
|||
|
|||
export default { |
|||
name:'xmMenuCommentEdit', |
|||
components: { |
|||
|
|||
}, |
|||
computed: { |
|||
...mapGetters([ 'userInfo' ]), |
|||
|
|||
}, |
|||
props:['xmMenuComment','visible','opType'], |
|||
|
|||
watch: { |
|||
'xmMenuComment':function( xmMenuComment ) { |
|||
if(xmMenuComment){ |
|||
this.editForm = {...xmMenuComment}; |
|||
} |
|||
|
|||
}, |
|||
'visible':function(visible) { |
|||
if(visible==true){ |
|||
this.initData() |
|||
} |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
currOpType:'add',//add/edit |
|||
load:{ list: false, edit: false, del: false, add: false },//查询中... |
|||
dicts:{},//下拉选择框的所有静态数据 params={categoryId:'all',itemCodes:['sex']} 返回结果 {sex: [{id:'1',name:'男'},{id:'2',name:'女'}]} |
|||
editFormRules: { |
|||
id: [ |
|||
//{ required: true, message: '主键不能为空', trigger: 'blur' } |
|||
] |
|||
}, |
|||
editForm: { |
|||
id:'',userid:'',username:'',star:'',cdate:'',menuId:'',pid:'',ups:'',isShow:'',toUserid:'',toUsername:'',lvl:'',context:'',branchId:'',ip:'',cityId:'',cityName:'',status:'',childNums:'' |
|||
}, |
|||
maxTableHeight:300, |
|||
}//end return |
|||
},//end data |
|||
methods: { |
|||
|
|||
...util, |
|||
|
|||
// 取消按钮点击 父组件监听@cancel="editFormVisible=false" 监听 |
|||
handleCancel:function(){ |
|||
this.$refs['editFormRef'].resetFields(); |
|||
this.$emit('cancel'); |
|||
}, |
|||
//新增、编辑提交XmMenuComment 档案评论表父组件监听@submit="afterEditSubmit" |
|||
saveSubmit: function () { |
|||
this.$refs.editFormRef.validate((valid) => { |
|||
if (valid) { |
|||
this.$confirm('确认提交吗?', '提示', {}).then(() => { |
|||
this.load.edit=true |
|||
let params = Object.assign({}, this.editForm); |
|||
var func=addXmMenuComment |
|||
if(this.currOpType=='edit'){ |
|||
func=editXmMenuComment |
|||
} |
|||
func(params).then((res) => { |
|||
this.load.edit=false |
|||
var tips=res.data.tips; |
|||
if(tips.isOk){ |
|||
this.editForm=res.data.data |
|||
this.initData() |
|||
this.currOpType="edit"; |
|||
this.$emit('submit');// @submit="afterAddSubmit" |
|||
} |
|||
this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error' }); |
|||
}).catch( err =>this.load.edit=false); |
|||
}); |
|||
}else{ |
|||
this.$notify({ showClose:true, message: "表单验证不通过,请修改表单数据再提交", type: 'error' }); |
|||
} |
|||
}); |
|||
}, |
|||
initData: function(){ |
|||
this.currOpType=this.opType |
|||
if(this.xmMenuComment){ |
|||
this.editForm = Object.assign({},this.xmMenuComment); |
|||
} |
|||
|
|||
if(this.opType=='edit'){ |
|||
|
|||
}else{ |
|||
|
|||
} |
|||
this.editFormBak={...this.editForm} |
|||
}, |
|||
|
|||
editSomeFields(row,fieldName,$event){ |
|||
if(this.opType=='add'){ |
|||
return; |
|||
} |
|||
let params={}; |
|||
params['ids']=[row].map(i=>i.id) |
|||
params[fieldName]=$event |
|||
var func = editSomeFieldsXmMenuComment |
|||
func(params).then(res=>{ |
|||
let tips = res.data.tips; |
|||
if(tips.isOk){ |
|||
this.editFormBak=[...this.editForm] |
|||
}else{ |
|||
Object.assign(this.editForm,this.editFormBak) |
|||
this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'}) |
|||
} |
|||
}).catch((e)=>Object.assign(this.editForm,this.editFormBak)) |
|||
}, |
|||
},//end method |
|||
mounted() { |
|||
this.$nextTick(() => { |
|||
initDicts(this); |
|||
this.initData() |
|||
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.table.$el) |
|||
}); |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
|||
@ -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 ApiEntityParams; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import com.xm.core.service.XmMenuCommentService; |
|||
import com.xm.core.entity.XmMenuComment; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对xm_menu_comment 档案评论表的操作有增删改查,对应的url分别为:<br> |
|||
* 组织 com 顶级模块 xm 大模块 core 小模块 <br> |
|||
* 实体 XmMenuComment 表 xm_menu_comment 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("xm.core.xmMenuCommentController") |
|||
@RequestMapping(value="/**/core/xmMenuComment") |
|||
@Api(tags={"档案评论表操作接口"}) |
|||
public class XmMenuCommentController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(XmMenuCommentController.class); |
|||
|
|||
@Autowired |
|||
private XmMenuCommentService xmMenuCommentService; |
|||
|
|||
|
|||
Map<String,Object> fieldsMap = toMap(new XmMenuComment()); |
|||
|
|||
|
|||
@ApiOperation( value = "查询档案评论表信息列表",notes=" ") |
|||
@ApiEntityParams( XmMenuComment.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=XmMenuComment.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Map<String,Object> listXmMenuComment( @ApiIgnore @RequestParam Map<String,Object> xmMenuComment){ |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("查询成功"); |
|||
RequestUtils.transformArray(xmMenuComment, "ids"); |
|||
PageUtils.startPage(xmMenuComment); |
|||
List<Map<String,Object>> xmMenuCommentList = xmMenuCommentService.selectListMapByWhere(xmMenuComment); //列出XmMenuComment列表 |
|||
PageUtils.responePage(m, xmMenuCommentList); |
|||
m.put("data",xmMenuCommentList); |
|||
|
|||
m.put("tips", tips); |
|||
return m; |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "新增一条档案评论表信息",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=XmMenuComment.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Map<String,Object> addXmMenuComment(@RequestBody XmMenuComment xmMenuComment) { |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("成功新增一条数据"); |
|||
try{ |
|||
boolean createPk=false; |
|||
if(!StringUtils.hasText(xmMenuComment.getId())) { |
|||
createPk=true; |
|||
xmMenuComment.setId(xmMenuCommentService.createKey("id")); |
|||
} |
|||
if(createPk==false){ |
|||
if(xmMenuCommentService.selectOneObject(xmMenuComment) !=null ){ |
|||
return failed("pk-exists","编号重复,请修改编号再提交"); |
|||
} |
|||
} |
|||
xmMenuCommentService.insert(xmMenuComment); |
|||
m.put("data",xmMenuComment); |
|||
}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<String,Object> delXmMenuComment(@RequestBody XmMenuComment xmMenuComment){ |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("成功删除一条数据"); |
|||
try{ |
|||
if(!StringUtils.hasText(xmMenuComment.getId())) { |
|||
return failed("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
XmMenuComment xmMenuCommentDb = xmMenuCommentService.selectOneObject(xmMenuComment); |
|||
if( xmMenuCommentDb == null ){ |
|||
return failed("data-not-exists","数据不存在,无法删除"); |
|||
} |
|||
xmMenuCommentService.deleteByPk(xmMenuComment); |
|||
}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=XmMenuComment.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Map<String,Object> editXmMenuComment(@RequestBody XmMenuComment xmMenuComment) { |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("成功更新一条数据"); |
|||
try{ |
|||
if(!StringUtils.hasText(xmMenuComment.getId())) { |
|||
return failed("pk-not-exists","请上送主键参数id"); |
|||
} |
|||
XmMenuComment xmMenuCommentDb = xmMenuCommentService.selectOneObject(xmMenuComment); |
|||
if( xmMenuCommentDb == null ){ |
|||
return failed("data-not-exists","数据不存在,无法修改"); |
|||
} |
|||
xmMenuCommentService.updateSomeFieldByPk(xmMenuComment); |
|||
m.put("data",xmMenuComment); |
|||
}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 = XmMenuComment.class, props={ }, remark = "档案评论表", paramType = "body" ) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=XmMenuComment.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Map<String,Object> editSomeFields( @ApiIgnore @RequestBody Map<String,Object> xmMenuCommentMap) { |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("成功更新一条数据"); |
|||
try{ |
|||
List<String> ids= (List<String>) xmMenuCommentMap.get("ids"); |
|||
if(ids==null || ids.size()==0){ |
|||
return failed("ids-0","ids不能为空"); |
|||
} |
|||
|
|||
Set<String> fields=new HashSet<>(); |
|||
fields.add("id"); |
|||
for (String fieldName : xmMenuCommentMap.keySet()) { |
|||
if(fields.contains(fieldName)){ |
|||
return failed(fieldName+"-no-edit",fieldName+"不允许修改"); |
|||
} |
|||
} |
|||
Set<String> fieldKey=xmMenuCommentMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); |
|||
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmMenuCommentMap.get(i) )).collect(Collectors.toSet()); |
|||
|
|||
if(fieldKey.size()<=0) { |
|||
return failed("fieldKey-0","没有需要更新的字段"); |
|||
} |
|||
XmMenuComment xmMenuComment = fromMap(xmMenuCommentMap,XmMenuComment.class); |
|||
List<XmMenuComment> xmMenuCommentsDb=xmMenuCommentService.selectListByIds(ids); |
|||
if(xmMenuCommentsDb==null ||xmMenuCommentsDb.size()==0){ |
|||
return failed("data-0","记录已不存在"); |
|||
} |
|||
List<XmMenuComment> can=new ArrayList<>(); |
|||
List<XmMenuComment> no=new ArrayList<>(); |
|||
User user = LoginUtils.getCurrentUserInfo(); |
|||
for (XmMenuComment xmMenuCommentDb : xmMenuCommentsDb) { |
|||
Tips tips2 = new Tips("检查通过"); |
|||
if(!tips2.isOk()){ |
|||
no.add(xmMenuCommentDb); |
|||
}else{ |
|||
can.add(xmMenuCommentDb); |
|||
} |
|||
} |
|||
if(can.size()>0){ |
|||
xmMenuCommentMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList())); |
|||
xmMenuCommentService.editSomeFields(xmMenuCommentMap); |
|||
} |
|||
List<String> 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<String,Object> batchDelXmMenuComment(@RequestBody List<XmMenuComment> xmMenuComments) { |
|||
Map<String,Object> m = new HashMap<>(); |
|||
Tips tips=new Tips("成功删除"); |
|||
try{ |
|||
if(xmMenuComments.size()<=0){ |
|||
return failed("data-0","请上送待删除数据列表"); |
|||
} |
|||
List<XmMenuComment> datasDb=xmMenuCommentService.selectListByIds(xmMenuComments.stream().map(i-> i.getId() ).collect(Collectors.toList())); |
|||
|
|||
List<XmMenuComment> can=new ArrayList<>(); |
|||
List<XmMenuComment> no=new ArrayList<>(); |
|||
for (XmMenuComment data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
xmMenuCommentService.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; |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
package com.xm.core.entity; |
|||
|
|||
import lombok.Data; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* 组织 com 顶级模块 xm 大模块 core 小模块 <br> |
|||
* 实体 XmMenuComment所有属性名: <br> |
|||
* "id","主键","userid","评论人","username","评论人姓名","star","星级","cdate","时间","menuId","需求编号","pid","上级评论","ups","点赞数量","isShow","是否显示0否1是","toUserid","回复用户编号","toUsername","回复用户名","lvl","层级0,1,2,3,4","context","评论内容","branchId","机构编号","ip","ip地址","cityId","城市编号","cityName","城市名称","status","状态0未审核,1已审核,3审核不通过","childNums","儿子节点数量";<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
*/ |
|||
@Data |
|||
@ApiModel(description="档案评论表") |
|||
public class XmMenuComment implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="评论人",allowEmptyValue=true,example="",allowableValues="") |
|||
String userid; |
|||
|
|||
@ApiModelProperty(notes="评论人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String username; |
|||
|
|||
@ApiModelProperty(notes="星级",allowEmptyValue=true,example="",allowableValues="") |
|||
String star; |
|||
|
|||
@ApiModelProperty(notes="时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
@ApiModelProperty(notes="需求编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String menuId; |
|||
|
|||
@ApiModelProperty(notes="上级评论",allowEmptyValue=true,example="",allowableValues="") |
|||
String pid; |
|||
|
|||
@ApiModelProperty(notes="点赞数量",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal ups; |
|||
|
|||
@ApiModelProperty(notes="是否显示0否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String isShow; |
|||
|
|||
@ApiModelProperty(notes="回复用户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String toUserid; |
|||
|
|||
@ApiModelProperty(notes="回复用户名",allowEmptyValue=true,example="",allowableValues="") |
|||
String toUsername; |
|||
|
|||
@ApiModelProperty(notes="层级0,1,2,3,4",allowEmptyValue=true,example="",allowableValues="") |
|||
String lvl; |
|||
|
|||
@ApiModelProperty(notes="评论内容",allowEmptyValue=true,example="",allowableValues="") |
|||
String context; |
|||
|
|||
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
@ApiModelProperty(notes="ip地址",allowEmptyValue=true,example="",allowableValues="") |
|||
String ip; |
|||
|
|||
@ApiModelProperty(notes="城市编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String cityId; |
|||
|
|||
@ApiModelProperty(notes="城市名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String cityName; |
|||
|
|||
@ApiModelProperty(notes="状态0未审核,1已审核,3审核不通过",allowEmptyValue=true,example="",allowableValues="") |
|||
String status; |
|||
|
|||
@ApiModelProperty(notes="儿子节点数量",allowEmptyValue=true,example="",allowableValues="") |
|||
Integer childNums; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public XmMenuComment(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 档案评论表 |
|||
**/ |
|||
public XmMenuComment() { |
|||
} |
|||
|
|||
} |
|||
@ -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.XmMenuComment; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com 顶级模块 xm 大模块 core 小模块 <br> |
|||
* 实体 XmMenuComment 表 xm_menu_comment 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service("xm.core.xmMenuCommentService") |
|||
public class XmMenuCommentService extends BaseService { |
|||
static Logger logger =LoggerFactory.getLogger(XmMenuCommentService.class); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,232 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.xm.core.entity.XmMenuComment"> |
|||
|
|||
|
|||
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 --> |
|||
|
|||
<sql id="whereForMap"> |
|||
<if test=" ids != null"> and (res.id) in |
|||
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item}) |
|||
</foreach> |
|||
</if> |
|||
<if test="key != null and key !='' "> </if> |
|||
</sql> |
|||
|
|||
|
|||
<!--结束 自定义sql函数区域--> |
|||
|
|||
|
|||
|
|||
<!-- 通过条件查询获取数据列表 返回list<map> --> |
|||
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap"> |
|||
select * from xm_menu_comment res |
|||
<where> |
|||
<include refid="whereForMap"/> |
|||
<include refid="where"/> |
|||
</where> |
|||
</select> |
|||
|
|||
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> --> |
|||
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmMenuComment" resultType="com.xm.core.entity.XmMenuComment"> |
|||
select * from xm_menu_comment res |
|||
<where> |
|||
<include refid="where"/> |
|||
</where> |
|||
</select> |
|||
|
|||
<!-- 通过主键查询获取数据对象 返回object --> |
|||
<select id="selectOneObject" parameterType="com.xm.core.entity.XmMenuComment" resultType="com.xm.core.entity.XmMenuComment"> |
|||
select * from xm_menu_comment res |
|||
where |
|||
res.id = #{id} |
|||
</select> |
|||
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmMenuComment"> |
|||
select * from xm_menu_comment res |
|||
where (res.id) in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item}) |
|||
</foreach> |
|||
</select> |
|||
<!-- 通过主键查询获取数据对象 返回map--> |
|||
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap"> |
|||
select * from xm_menu_comment res |
|||
where |
|||
res.id = #{id} |
|||
</select> |
|||
<!-- 获取数据条目 返回long --> |
|||
<select id="countByWhere" parameterType="com.xm.core.entity.XmMenuComment" resultType="long"> |
|||
select count(*) from xm_menu_comment res |
|||
<where> |
|||
<include refid="where"/> |
|||
</where> |
|||
</select> |
|||
<!-- 新增一条记录 主键id,--> |
|||
<insert id="insert" parameterType="com.xm.core.entity.XmMenuComment" useGeneratedKeys="false" keyProperty="id"> |
|||
insert into xm_menu_comment( |
|||
<include refid="columns"/> |
|||
) values ( |
|||
#{id},#{userid},#{username},#{star},#{cdate},#{menuId},#{pid},#{ups},#{isShow},#{toUserid},#{toUsername},#{lvl},#{context},#{branchId},#{ip},#{cityId},#{cityName},#{status},#{childNums} |
|||
) |
|||
</insert> |
|||
|
|||
<!-- 按条件删除若干条记录--> |
|||
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmMenuComment"> |
|||
delete from xm_menu_comment res |
|||
<where> |
|||
<include refid="where"/> |
|||
</where> |
|||
</delete> |
|||
|
|||
<!-- 按主键删除一条记录--> |
|||
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmMenuComment"> |
|||
delete from xm_menu_comment |
|||
where id = #{id} |
|||
</delete> |
|||
|
|||
<!-- 根据条件修改若干条记录 --> |
|||
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmMenuComment"> |
|||
update xm_menu_comment |
|||
<set> |
|||
<include refid="someFieldSet"/> |
|||
</set> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<!-- 根据主键修改一条记录 --> |
|||
<update id="updateByPk" parameterType="com.xm.core.entity.XmMenuComment"> |
|||
update xm_menu_comment |
|||
<set> |
|||
<include refid="set"/> |
|||
</set> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<!-- 批量新增 批量插入 借用insert 循环插入实现 |
|||
<insert id="batchInsert" parameterType="List"> |
|||
</insert> |
|||
--> |
|||
|
|||
<!-- 批量更新 --> |
|||
<update id="batchUpdate" parameterType="List"> |
|||
<foreach collection="list" item="item" index="index" separator=";" > |
|||
update xm_menu_comment |
|||
set |
|||
<include refid="batchSet"/> |
|||
where id = #{item.id} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<!-- 批量修改某几个字段 --> |
|||
<delete id="editSomeFields" parameterType="HashMap"> |
|||
update xm_menu_comment |
|||
<set> |
|||
<include refid="someFieldSet"/> |
|||
</set> |
|||
where (id) in |
|||
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item}) |
|||
</foreach> |
|||
</delete> |
|||
<!-- 批量删除 --> |
|||
<delete id="batchDelete" parameterType="List"> |
|||
delete from xm_menu_comment |
|||
where |
|||
(id) in |
|||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" > |
|||
( #{item.id} ) |
|||
</foreach> |
|||
</delete> |
|||
|
|||
|
|||
<!--sql片段 列--> |
|||
<sql id="columns"> |
|||
id,userid,username,star,cdate,menu_id,pid,ups,is_show,to_userid,to_username,lvl,context,branch_id,ip,city_id,city_name,status,child_nums |
|||
</sql> |
|||
|
|||
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS--> |
|||
<sql id="where"> |
|||
<if test="id != null and id != ''"> and res.id = #{id} </if> |
|||
<if test="userid != null and userid != ''"> and res.userid = #{userid} </if> |
|||
<if test="username != null and username != ''"> and res.username = #{username} </if> |
|||
<if test="star != null and star != ''"> and res.star = #{star} </if> |
|||
<if test="cdate != null"> and date_format(res.cdate,'%Y-%m-%d') = date_format(#{cdate},'%Y-%m-%d') </if> |
|||
<if test="menuId != null and menuId != ''"> and res.menu_id = #{menuId} </if> |
|||
<if test="pid != null and pid != ''"> and res.pid = #{pid} </if> |
|||
<if test="ups != null and ups != ''"> and res.ups = #{ups} </if> |
|||
<if test="isShow != null and isShow != ''"> and res.is_show = #{isShow} </if> |
|||
<if test="toUserid != null and toUserid != ''"> and res.to_userid = #{toUserid} </if> |
|||
<if test="toUsername != null and toUsername != ''"> and res.to_username = #{toUsername} </if> |
|||
<if test="lvl != null and lvl != ''"> and res.lvl = #{lvl} </if> |
|||
<if test="context != null and context != ''"> and res.context = #{context} </if> |
|||
<if test="branchId != null and branchId != ''"> and res.branch_id = #{branchId} </if> |
|||
<if test="ip != null and ip != ''"> and res.ip = #{ip} </if> |
|||
<if test="cityId != null and cityId != ''"> and res.city_id = #{cityId} </if> |
|||
<if test="cityName != null and cityName != ''"> and res.city_name = #{cityName} </if> |
|||
<if test="status != null and status != ''"> and res.status = #{status} </if> |
|||
<if test="childNums != null and childNums != ''"> and res.child_nums = #{childNums} </if> |
|||
</sql> |
|||
<!--sql片段 更新字段 --> |
|||
<sql id="set"> |
|||
userid = #{userid}, |
|||
username = #{username}, |
|||
star = #{star}, |
|||
cdate = #{cdate}, |
|||
menu_id = #{menuId}, |
|||
pid = #{pid}, |
|||
ups = #{ups}, |
|||
is_show = #{isShow}, |
|||
to_userid = #{toUserid}, |
|||
to_username = #{toUsername}, |
|||
lvl = #{lvl}, |
|||
context = #{context}, |
|||
branch_id = #{branchId}, |
|||
ip = #{ip}, |
|||
city_id = #{cityId}, |
|||
city_name = #{cityName}, |
|||
status = #{status}, |
|||
child_nums = #{childNums} |
|||
</sql> |
|||
<sql id="someFieldSet"> |
|||
<if test="userid != null and userid != ''"> userid = #{userid}, </if> |
|||
<if test="username != null and username != ''"> username = #{username}, </if> |
|||
<if test="star != null and star != ''"> star = #{star}, </if> |
|||
<if test="cdate != null"> cdate = #{cdate}, </if> |
|||
<if test="menuId != null and menuId != ''"> menu_id = #{menuId}, </if> |
|||
<if test="pid != null and pid != ''"> pid = #{pid}, </if> |
|||
<if test="ups != null and ups != ''"> ups = #{ups}, </if> |
|||
<if test="isShow != null and isShow != ''"> is_show = #{isShow}, </if> |
|||
<if test="toUserid != null and toUserid != ''"> to_userid = #{toUserid}, </if> |
|||
<if test="toUsername != null and toUsername != ''"> to_username = #{toUsername}, </if> |
|||
<if test="lvl != null and lvl != ''"> lvl = #{lvl}, </if> |
|||
<if test="context != null and context != ''"> context = #{context}, </if> |
|||
<if test="branchId != null and branchId != ''"> branch_id = #{branchId}, </if> |
|||
<if test="ip != null and ip != ''"> ip = #{ip}, </if> |
|||
<if test="cityId != null and cityId != ''"> city_id = #{cityId}, </if> |
|||
<if test="cityName != null and cityName != ''"> city_name = #{cityName}, </if> |
|||
<if test="status != null and status != ''"> status = #{status}, </if> |
|||
<if test="childNums != null and childNums != ''"> child_nums = #{childNums}, </if> |
|||
</sql> |
|||
<!--sql片段 批量更新 --> |
|||
<sql id="batchSet"> |
|||
userid = #{item.userid}, |
|||
username = #{item.username}, |
|||
star = #{item.star}, |
|||
cdate = #{item.cdate}, |
|||
menu_id = #{item.menuId}, |
|||
pid = #{item.pid}, |
|||
ups = #{item.ups}, |
|||
is_show = #{item.isShow}, |
|||
to_userid = #{item.toUserid}, |
|||
to_username = #{item.toUsername}, |
|||
lvl = #{item.lvl}, |
|||
context = #{item.context}, |
|||
branch_id = #{item.branchId}, |
|||
ip = #{item.ip}, |
|||
city_id = #{item.cityId}, |
|||
city_name = #{item.cityName}, |
|||
status = #{item.status}, |
|||
child_nums = #{item.childNums} |
|||
</sql> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue