| | |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.common.vo.DeptVo; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.modules.chatrg.entity.Chatgroup; |
| | | import org.springblade.modules.chatrg.vo.ChatgroupVO; |
| | | import org.springblade.modules.chatrg.service.IChatgroupService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | public class ChatgroupController extends BladeController { |
| | | |
| | | private final IChatgroupService chatgroupService; |
| | | private final IUserService iUserService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @ApiOperation(value = "分页", notes = "传入chatgroup") |
| | | public R<IPage<Chatgroup>> list(Chatgroup chatgroup, Query query) { |
| | | IPage<Chatgroup> pages = chatgroupService.page(Condition.getPage(query), Condition.getQueryWrapper(chatgroup)); |
| | | List<Map<String, Object>> list = iUserService.selectUser(); |
| | | for (int i=0;i<pages.getTotal();i++){ |
| | | StringBuffer deptNameBuiffer = new StringBuffer(); |
| | | String groupmember = pages.getRecords().get(i).getGroupmember(); |
| | | String[] split =groupmember.split(","); |
| | | List<String> lists = Arrays.asList(split); |
| | | //数据匹配封装 |
| | | for (String deptId:lists) { |
| | | for (Map<String, Object> deptVo:list) { |
| | | if (deptId.equals(deptVo.get("groupmember").toString())){ |
| | | deptNameBuiffer.append(deptVo.get("rname")).append("/"); |
| | | } |
| | | } |
| | | } |
| | | pages.getRecords().get(i).setGroupmember(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1)); |
| | | } |
| | | return R.data(pages); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入chatgroup") |
| | | public R save(@Valid @RequestBody Chatgroup chatgroup) { |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | chatgroup.setTime(end); |
| | | return R.status(chatgroupService.save(chatgroup)); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入chatgroup") |
| | | public R submit(@Valid @RequestBody Chatgroup chatgroup) { |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | chatgroup.setTime(end); |
| | | return R.status(chatgroupService.saveOrUpdate(chatgroup)); |
| | | } |
| | | |