作者 mxy

成果树

成长树
我的孩子
正在显示 20 个修改的文件 包含 948 行增加19 行删除
... ... @@ -5,6 +5,7 @@ import com.example.client.domain.bo.CFamilyRelationStudentBo;
import com.example.client.service.FamilyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -76,4 +77,16 @@ public class FamilyController {
return familyService.saveFamily(bo);
}
@ApiImplicitParams({
@ApiImplicitParam(name = "connect",value = "绑定的状态(0绑定,1解绑)",dataType = "Integer",required = true,paramType = "query"),
@ApiImplicitParam(name = "userId",value = "孩子的账号Id",dataType = "Long",required = true,paramType = "query")
})
@ApiOperation("修改家长和孩子的绑定")
@PostMapping("/updateFamilyConnect")
public AjaxResult updateFamilyConnect(Integer connect,Long userId){
log.info("<<<接收的参数<<<::"+connect);
return familyService.updateFamilyConnect(connect,userId);
}
}
... ...
package com.example.client.controller;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CCertificateStudentBo;
import com.example.client.service.FruitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:15:42
* */
@Slf4j
@Validated
@Api(tags = "成果树")
@RestController
@RequestMapping("/tree/fruit")
public class FruitController {
@Autowired
private FruitService fruitService;
@ApiImplicitParam(name = "classify",value = "证书分类1~12",dataType = "Integer",required = true,paramType = "query")
@ApiOperation("查看所有成果/证书")
@PostMapping("/selectFruits")
public AjaxResult selectAllFruits(Integer classify){
return fruitService.selectAllFruits(classify);
}
@ApiOperation("打开成果树")
@PostMapping("/openFruit")
public AjaxResult openFruit(){
return fruitService.openFruit();
}
@ApiImplicitParam(name = "certificateId",value = "证书Id",dataType = "Long",required = true,paramType = "query")
@ApiOperation("查看单个成果")
@PostMapping("/selectFruit")
public AjaxResult selectFruit(Long certificateId){
log.info("<<<接收的参数<<<::"+certificateId);
return fruitService.selectFruit(certificateId);
}
@ApiOperation("上传证书")
@PostMapping("/saveFruit")
public AjaxResult saveFruit(@RequestBody CCertificateStudentBo bo){
log.info("<<<接收到的参数<<<::"+bo);
return fruitService.saveFruit(bo);
}
}
... ...
package com.example.client.controller;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.service.GrowthTreeService;
import com.jhlabs.image.GradientWipeFilter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:18:35
* */
@Slf4j
@Validated
@Api(tags = "成长树")
@RestController
@RequestMapping("/tree/growthTree")
public class GrowthTreeController {
@Autowired
private GrowthTreeService growthTreeService;
@ApiOperation("成长树列表")
@PostMapping("/selectAllGrowth")
public AjaxResult selectAllGrowth(){
return growthTreeService.selectAllGrowth();
}
@ApiImplicitParam(name = "growthId",value = "成长树报表id",dataType = "Long",required = true,paramType = "query")
@ApiOperation("查询单个成长树报表")
@PostMapping("/selectGrowth")
public AjaxResult selectGrowth(Long growthId){
log.info("<<<接收的参数<<<::"+growthId);
return growthTreeService.selectGrowth(growthId);
}
@ApiOperation("范围查询成长树列表")
@PostMapping("/byTime")
public AjaxResult byTimeSelectGrowth(LocalDateTime startTime,LocalDateTime endTime){
return growthTreeService.byTimeSelectGrowth(startTime,endTime);
}
}
... ...
... ... @@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
... ... @@ -86,13 +87,13 @@ public class CCertificateStudent implements Serializable {
* $column.columnComment
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
private LocalDateTime createTime;
/**
* $column.columnComment
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
private LocalDateTime updateTime;
/**
* 证书分类 分十二种 1到12
... ...
... ... @@ -66,5 +66,12 @@ public class CFamilyRelationStudentVo {
@ApiModelProperty("学校或公司")
private String company;
/**
* 绑定状态 0 绑定 1未绑定
*/
@Excel(name = "绑定状态")
@ApiModelProperty("绑定状态")
private Integer Connect;
}
... ...
... ... @@ -66,5 +66,12 @@ public class CGrowthReportStudentVo {
@ApiModelProperty("评价状态 : 1-待老师评价 2-待班主任评价 3-家长反馈 4 - 完成")
private Long type;
/**
* 家长反馈
*/
@Excel(name = "学生信息")
@ApiModelProperty("学生信息")
private CPersonalInformationVo personalInformationVo;
}
... ...
package com.example.client.domain.vo;
import cn.bronet.admin.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ChildVo {
/**
* 孩子的用户ID
*/
private Long childId;
/**
* 孩子的名字
*/
private String childName;
/**
* 绑定状态
*/
private Integer connect;
}
... ...
... ... @@ -4,6 +4,8 @@ package com.example.client.mapper;
import cn.bronet.admin.common.core.mybatisplus.core.BaseMapperPlus;
import com.example.client.domain.CCertificateStudent;
import java.util.List;
/**
* 我的证书(学生)Mapper接口
*
... ... @@ -12,4 +14,11 @@ import com.example.client.domain.CCertificateStudent;
*/
public interface CCertificateStudentMapper extends BaseMapperPlus<CCertificateStudent> {
List<CCertificateStudent> getAllFruits(Long uid);
List<Integer> openFruit(Long uid);
Integer count(Long uid);
}
... ...
... ... @@ -5,6 +5,7 @@ import cn.bronet.admin.common.core.mybatisplus.core.BaseMapperPlus;
import com.example.client.domain.CComments;
import com.example.client.domain.vo.CCommentsVo;
import com.example.client.domain.vo.CommentsVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
... ... @@ -16,6 +17,6 @@ import java.util.List;
*/
public interface CCommentsMapper extends BaseMapperPlus<CComments> {
List<CommentsVo> commentToComment(Long pid,Long aid);
List<CommentsVo> commentToComment(@Param("pid") Long pid, @Param("aid") Long aid);
}
... ...
... ... @@ -15,4 +15,6 @@ import java.util.List;
public interface CFamilyRelationStudentMapper extends BaseMapperPlus<CFamilyRelationStudent> {
List<CFamilyRelationStudent> getAllFamilies(Long uId);
List<CFamilyRelationStudent> getMyChildren(Long uId);
}
... ...
... ... @@ -48,4 +48,10 @@ public interface FamilyService {
*/
AjaxResult saveFamily(CFamilyRelationStudentBo bo);
/**
* 修改家长和孩子的绑定状况
* @param connect
* @return
*/
AjaxResult updateFamilyConnect(Integer connect,Long userId);
}
... ...
package com.example.client.service;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CCertificateStudentBo;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:15:43
* */
public interface FruitService {
/**
* 查询所有的成果
* @return
*/
AjaxResult selectAllFruits(Integer classify);
/**
* 打开成果树
* @return
*/
AjaxResult openFruit();
/**
* 查询单个成果
* @param certificateId
* @return
*/
AjaxResult selectFruit(Long certificateId);
/**
* 上传证书
* @param bo
* @return
*/
AjaxResult saveFruit(CCertificateStudentBo bo);
}
... ...
package com.example.client.service;
import cn.bronet.admin.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:18:36
* */
public interface GrowthTreeService {
/**
* 查询成长树列表
* @return
*/
AjaxResult selectAllGrowth();
/**
* 查询单条成长报表
* @param growthId
* @return
*/
AjaxResult selectGrowth(Long growthId);
/**
* 根据时间查询成长树报表
* @param startTime
* @param endTime
* @return
*/
AjaxResult byTimeSelectGrowth(LocalDateTime startTime, LocalDateTime endTime);
}
... ...
... ... @@ -85,4 +85,6 @@ public interface MineService {
* @return
*/
AjaxResult MyClass();
}
... ...
... ... @@ -10,6 +10,7 @@ import com.example.client.domain.CUser;
import com.example.client.domain.bo.CFamilyRelationStudentBo;
import com.example.client.domain.bo.MyAuthentication;
import com.example.client.domain.vo.CFamilyRelationStudentVo;
import com.example.client.domain.vo.ChildVo;
import com.example.client.domin.UserContext;
import com.example.client.enumeration.Identity;
import com.example.client.mapper.CFamilyRelationStudentMapper;
... ... @@ -17,6 +18,7 @@ import com.example.client.mapper.CPersonalInformationMapper;
import com.example.client.mapper.CUserMapper;
import com.example.client.service.FamilyService;
import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
import org.apache.poi.poifs.property.Child;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -139,8 +141,8 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
//判断 等于null 添加关系人的用户名
if (family.getName()==null){
CUser cUser1 = cUserMapper.selectById(family.getUserId());
familyVo.setName(cUser1.getUserName());
CUser parent = cUserMapper.selectById(family.getUserId());
familyVo.setName(parent.getUserName());
}
... ... @@ -150,6 +152,50 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
return AjaxResult.success(familiesVos);
}
//身份为 家长
}else if(cUser.getIdentityType().equals(Identity.PATRIARCH)){
//根据登录人Id查询家庭关系表
List<CFamilyRelationStudent> families= cFamilyRelationStudentMapper.getMyChildren(uId);
//判断 等于null
if (families.isEmpty()){
return AjaxResult.success("你还没有绑定孩子");
//不等于 null
}else {
//创建返回值集合
List<ChildVo> childVos = new ArrayList<ChildVo>();
//循环遍历查询到的家庭关系表的信息 并 添加信息到返回值集合
for (CFamilyRelationStudent family : families) {
ChildVo childVo = new ChildVo();
childVo.setChildId(family.getSubclassId());
childVo.setConnect(1);
//判断 等于null 添加关系人的用户名
if (family.getName()==null){
CPersonalInformation child = cPersonalInformationMapper.getPersonalInfo(family.getSubclassId());
childVo.setChildName(child.getName());
if (cUser.getAtPresent().equals(child.getUserId())){
childVo.setConnect(0);
}
}
childVos.add(childVo);
}
return AjaxResult.success(childVos);
}
}
return AjaxResult.error("错误");
... ... @@ -163,22 +209,26 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
@Override
public AjaxResult getFamilyInfo(Long familyId) {
//根据家庭关系表的ID查询家庭关系表
CFamilyRelationStudent family = cFamilyRelationStudentMapper.selectById(familyId);
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//创建返回值 并 添加数据
CFamilyRelationStudentVo familyVo = new CFamilyRelationStudentVo();
BeanUtils.copyProperties(family,familyVo);
//根据家庭关系表的ID查询家庭关系表
CFamilyRelationStudent family = cFamilyRelationStudentMapper.selectById(familyId);
//判断 等于null 没有名字
if (family.getName()==null){
//创建返回值 并 添加数据
CFamilyRelationStudentVo familyVo = new CFamilyRelationStudentVo();
BeanUtils.copyProperties(family, familyVo);
//添加家长的 用户名
CUser cUserFamily = cUserMapper.selectById(family.getUserId());
familyVo.setName(cUserFamily.getUserName());
}
//判断 等于null 没有名字
if (family.getName() == null) {
//添加家长的 用户名
CUser cUserFamily = cUserMapper.selectById(family.getUserId());
familyVo.setName(cUserFamily.getUserName());
}
return AjaxResult.success(familyVo);
return AjaxResult.success(familyVo);
}
/**
... ... @@ -236,7 +286,7 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
CUser cUser = cUserMapper.selectById(uId);
//判断 等于2 身份为学生
if (cUser.getIdentityType().equals(Identity.STUDENT)){
if (cUser.getIdentityType().equals(Identity.STUDENT) || cUser.getIdentityType().equals(Identity.PATRIARCH)){
return AjaxResult.success("你没有添加权限");
}
... ... @@ -250,4 +300,34 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap
return AjaxResult.success();
}
/**
* 修改家长和孩子的绑定状态
* @param connect
* @return
*/
@Override
public AjaxResult updateFamilyConnect(Integer connect,Long userId) {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//绑定
if (connect.equals(0)){
cUser.setAtPresent(userId)
.setUpdateTime(LocalDateTime.now());
cUserMapper.updateById(cUser);
//解绑
}else if (connect.equals(1)){
cUser.setAtPresent(0L)
.setUpdateTime(LocalDateTime.now());
cUserMapper.updateById(cUser);
}
return AjaxResult.success();
}
}
... ...
package com.example.client.service.impl;
import cn.bronet.admin.common.core.domain.AjaxResult;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.client.domain.CCertificateStudent;
import com.example.client.domain.CUser;
import com.example.client.domain.bo.CCertificateStudentBo;
import com.example.client.domain.vo.CCertificateStudentVo;
import com.example.client.domin.UserContext;
import com.example.client.enumeration.Identity;
import com.example.client.mapper.CCertificateStudentMapper;
import com.example.client.mapper.CUserMapper;
import com.example.client.service.FruitService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.javassist.expr.NewArray;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Array;
import java.time.LocalDateTime;
import java.util.*;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:15:42
* */
@Slf4j
@Service
public class FruitServiceImpl implements FruitService {
@Autowired
private CUserMapper cUserMapper;
@Autowired
private CCertificateStudentMapper cCertificateStudentMapper;
/**
* 查看所有的证书
* @return
*/
@Override
public AjaxResult selectAllFruits(Integer classify) {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
List<CCertificateStudentVo> vos = new ArrayList<>();
//没有分类
if (classify==null){
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
List<CCertificateStudent> allFruits = cCertificateStudentMapper.getAllFruits(cUser.getAtPresent());
for (CCertificateStudent allFruit : allFruits) {
CCertificateStudentVo vo = new CCertificateStudentVo();
BeanUtils.copyProperties(allFruit,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
//学生
}else {
List<CCertificateStudent> allFruits = cCertificateStudentMapper.getAllFruits(uId);
for (CCertificateStudent allFruit : allFruits) {
CCertificateStudentVo vo = new CCertificateStudentVo();
BeanUtils.copyProperties(allFruit,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
}
//有分类
}else {
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
LambdaQueryWrapper<CCertificateStudent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CCertificateStudent::getClassify,classify)
.eq(CCertificateStudent::getUserId,cUser.getAtPresent());
List<CCertificateStudent> allFruits = cCertificateStudentMapper.selectList(queryWrapper);
for (CCertificateStudent allFruit : allFruits) {
CCertificateStudentVo vo = new CCertificateStudentVo();
BeanUtils.copyProperties(allFruit,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
//学生
}else {
LambdaQueryWrapper<CCertificateStudent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CCertificateStudent::getClassify,classify)
.eq(CCertificateStudent::getUserId,uId);
List<CCertificateStudent> allFruits = cCertificateStudentMapper.selectList(queryWrapper);
for (CCertificateStudent allFruit : allFruits) {
CCertificateStudentVo vo = new CCertificateStudentVo();
BeanUtils.copyProperties(allFruit,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
}
}
}
/**
* 打开成果树
* @return
*/
@Override
public AjaxResult openFruit() {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
//苹果编号1~12
List<Integer> fruits = cCertificateStudentMapper.openFruit(cUser.getAtPresent());
return AjaxResult.success(fruits);
//学生
}else {
//苹果编号1~12
List<Integer> fruits = cCertificateStudentMapper.openFruit(uId);
return AjaxResult.success(fruits);
}
}
/**
* 查询单个成果
* @param certificateId
* @return
*/
@Override
public AjaxResult selectFruit(Long certificateId) {
//根据证书Id查询证书表
CCertificateStudent cCertificateStudent = cCertificateStudentMapper.selectById(certificateId);
//创建返回值vo
CCertificateStudentVo vo = new CCertificateStudentVo();
BeanUtils.copyProperties(cCertificateStudent,vo);
return AjaxResult.success(vo);
}
/**
* 上传证书
* @param bo
* @return
*/
@Transactional
@Override
public AjaxResult saveFruit(CCertificateStudentBo bo) {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//家长 上传
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
Integer count = cCertificateStudentMapper.count(cUser.getAtPresent());
List<Integer> integers = cCertificateStudentMapper.openFruit(cUser.getAtPresent());
//等于 12 个
if (count.equals(12)){
int classify = (int) (Math.random() * 12 + 1);
CCertificateStudent cCertificateStudent = new CCertificateStudent();
BeanUtils.copyProperties(bo,cCertificateStudent);
cCertificateStudent.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now())
.setClassify(classify);
cCertificateStudentMapper.insert(cCertificateStudent);
//小于 12 个
}else {
ArrayList<Integer> classify = new ArrayList<>();
classify.add(1);
classify.add(2);
classify.add(3);
classify.add(4);
classify.add(5);
classify.add(6);
classify.add(7);
classify.add(8);
classify.add(9);
classify.add(10);
classify.add(11);
classify.add(12);
for (int i = 0; i < classify.size(); i++) {
for (Integer integer : integers) {
if (integer.equals(classify.get(i))){
classify.remove(i);
}
}
}
log.info("<<<classify<<<::"+classify.toString());
int index =(int) Math.random() * classify.size();
CCertificateStudent cCertificateStudent = new CCertificateStudent();
BeanUtils.copyProperties(bo,cCertificateStudent);
cCertificateStudent.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now())
.setClassify(classify.get(index));
cCertificateStudentMapper.insert(cCertificateStudent);
}
return AjaxResult.success();
//学生上传
}else{
Integer count = cCertificateStudentMapper.count(uId);
List<Integer> integers = cCertificateStudentMapper.openFruit(uId);
//等于 12 个
if (count.equals(12)){
int classify = (int) (Math.random() * 12 + 1);
CCertificateStudent cCertificateStudent = new CCertificateStudent();
BeanUtils.copyProperties(bo,cCertificateStudent);
cCertificateStudent.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now())
.setClassify(classify);
cCertificateStudentMapper.insert(cCertificateStudent);
//小于 12 个
}else {
//int[] classify ={1,2,3,4,5,6,7,8,9,10,11,12};
ArrayList<Integer> classify = new ArrayList<>();
classify.add(1);
classify.add(2);
classify.add(3);
classify.add(4);
classify.add(5);
classify.add(6);
classify.add(7);
classify.add(8);
classify.add(9);
classify.add(10);
classify.add(11);
classify.add(12);
for (int i = 0; i < classify.size(); i++) {
for (Integer integer : integers) {
if (integer.equals(classify.get(i))){
classify.remove(i);
}
}
}
log.info("<<<classify<<<::"+classify.toString());
int index =(int) Math.random() * classify.size();
CCertificateStudent cCertificateStudent = new CCertificateStudent();
BeanUtils.copyProperties(bo,cCertificateStudent);
cCertificateStudent.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now())
.setClassify(classify.get(index));
cCertificateStudentMapper.insert(cCertificateStudent);
}
return AjaxResult.success();
}
}
}
... ...
package com.example.client.service.impl;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.client.domain.CGrowthReportStudent;
import com.example.client.domain.CPersonalInformation;
import com.example.client.domain.CUser;
import com.example.client.domain.vo.CGrowthReportStudentVo;
import com.example.client.domain.vo.CPersonalInformationVo;
import com.example.client.domin.UserContext;
import com.example.client.enumeration.Identity;
import com.example.client.mapper.CGrowthReportStudentMapper;
import com.example.client.mapper.CPersonalInformationMapper;
import com.example.client.mapper.CUserMapper;
import com.example.client.service.GrowthTreeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/17
* Time:18:36
* */
@Slf4j
@Service
public class GrowthTreeServiceImpl implements GrowthTreeService {
@Autowired
private CUserMapper cUserMapper;
@Autowired
private CGrowthReportStudentMapper cGrowthReportStudentMapper;
@Autowired
private CPersonalInformationMapper cPersonalInformationMapper;
/**
* 查询成长树列表
* @return
*/
@Override
public AjaxResult selectAllGrowth() {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
//未完成家长返回的
LambdaQueryWrapper<CGrowthReportStudent> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CGrowthReportStudent::getUserId,cUser.getAtPresent())
.eq(CGrowthReportStudent::getType,3)
.orderByDesc(CGrowthReportStudent::getCreateTime);
List<CGrowthReportStudent> cGrowthReportStudents = cGrowthReportStudentMapper.selectList(wrapper);
List<CGrowthReportStudentVo> vos = new ArrayList<>();
for (CGrowthReportStudent cGrowthReportStudent : cGrowthReportStudents) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent,vo);
vos.add(vo);
}
//完成家长反馈的啊
wrapper.eq(CGrowthReportStudent::getType,4);
List<CGrowthReportStudent> cGrowthReportStudents1 = cGrowthReportStudentMapper.selectList(wrapper);
for (CGrowthReportStudent cGrowthReportStudent1 : cGrowthReportStudents1) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent1,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
//学生
}else {
LambdaQueryWrapper<CGrowthReportStudent> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CGrowthReportStudent::getUserId,uId)
.eq(CGrowthReportStudent::getType,4)
.orderByDesc(CGrowthReportStudent::getCreateTime);
List<CGrowthReportStudent> cGrowthReportStudents = cGrowthReportStudentMapper.selectList(wrapper);
List<CGrowthReportStudentVo> vos = new ArrayList<>();
for (CGrowthReportStudent cGrowthReportStudent : cGrowthReportStudents) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
}
}
/**
* 查询单条成长树报表
* @param growthId
* @return
*/
@Override
public AjaxResult selectGrowth(Long growthId) {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
CGrowthReportStudent cGrowthReportStudent = cGrowthReportStudentMapper.selectById(growthId);
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent,vo);
CPersonalInformation personalInfo = cPersonalInformationMapper.getPersonalInfo(cUser.getAtPresent());
CPersonalInformationVo informationVo = new CPersonalInformationVo();
BeanUtils.copyProperties(personalInfo,informationVo);
vo.setPersonalInformationVo(informationVo);
return AjaxResult.success(vo);
//学生
}else {
CGrowthReportStudent cGrowthReportStudent = cGrowthReportStudentMapper.selectById(growthId);
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent,vo);
CPersonalInformation personalInfo = cPersonalInformationMapper.getPersonalInfo(uId);
CPersonalInformationVo informationVo = new CPersonalInformationVo();
BeanUtils.copyProperties(personalInfo,informationVo);
vo.setPersonalInformationVo(informationVo);
return AjaxResult.success(vo);
}
}
/**
* 根据时间查询时间报表
* @param startTime
* @param endTime
* @return
*/
@Override
public AjaxResult byTimeSelectGrowth(LocalDateTime startTime, LocalDateTime endTime) {
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//家长
if (cUser.getIdentityType().equals(Identity.PATRIARCH)){
//未完成家长反馈的
LambdaQueryWrapper<CGrowthReportStudent> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CGrowthReportStudent::getUserId,cUser.getAtPresent())
.eq(CGrowthReportStudent::getType,3)
.between(CGrowthReportStudent::getCreateTime,startTime,endTime);
List<CGrowthReportStudent> cGrowthReportStudents = cGrowthReportStudentMapper.selectList(wrapper);
List<CGrowthReportStudentVo> vos = new ArrayList<>();
for (CGrowthReportStudent cGrowthReportStudent : cGrowthReportStudents) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent,vo);
vos.add(vo);
}
//完成家长反馈的
wrapper.eq(CGrowthReportStudent::getType,4);
List<CGrowthReportStudent> cGrowthReportStudents1 = cGrowthReportStudentMapper.selectList(wrapper);
for (CGrowthReportStudent cGrowthReportStudent1 : cGrowthReportStudents1) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent1,vo);
vos.add(vo);
}
return AjaxResult.success(vos);
//学生
}else {
//未完成家长反馈的
LambdaQueryWrapper<CGrowthReportStudent> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CGrowthReportStudent::getUserId, uId)
.eq(CGrowthReportStudent::getType, 4)
.between(CGrowthReportStudent::getCreateTime, startTime, endTime);
List<CGrowthReportStudent> cGrowthReportStudents = cGrowthReportStudentMapper.selectList(wrapper);
List<CGrowthReportStudentVo> vos = new ArrayList<>();
for (CGrowthReportStudent cGrowthReportStudent : cGrowthReportStudents) {
CGrowthReportStudentVo vo = new CGrowthReportStudentVo();
BeanUtils.copyProperties(cGrowthReportStudent, vo);
vos.add(vo);
}
return AjaxResult.success(vos);
}
}
}
... ...
... ... @@ -21,5 +21,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="classify" column="classify"/>
</resultMap>
<select id="getAllFruits" resultMap="CCertificateStudentResult">
SELECT * FROM c_certificate_student WHERE user_id=#{uid};
</select>
<select id="openFruit" resultType="integer">
SELECT DISTINCT c_certificate_student.classify FROM c_certificate_student WHERE user_id=#{uid};
</select>
<select id="count" resultType="integer">
SELECT COUNT(DISTINCT c_certificate_student.classify) FROM c_certificate_student WHERE user_id=#{uid};
</select>
</mapper>
... ...
... ... @@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<select id="commentToComment" resultMap="CommentsResult">
select * from c_comments where parent_id = #{pid} and and activity_id = #{aid} ORDER BY create_time DESC ;
select * from c_comments where parent_id = #{pid} and activity_id = #{aid} ORDER BY create_time DESC ;
</select>
... ...
... ... @@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT * From c_family_relation_student WHERE subclass_id =#{uid};
</select>
<select id="getMyChildren" resultMap="CFamilyRelationStudentResult">
SELECT * From c_family_relation_student WHERE user_id =#{uid};
</select>
</mapper>
... ...