证书标签
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.UserCertificateLabel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserCertificateLabelDao extends MPJBaseMapper<UserCertificateLabel> {
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -13,6 +14,8 @@ public class UserCertificate {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer labelId;
|
||||
|
||||
private String title;
|
||||
|
||||
//证书类型A a证 B b证 ZK自考
|
||||
@@ -35,4 +38,7 @@ public class UserCertificate {
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private MyUserEntity user;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("user_certificate_label")
|
||||
public class UserCertificateLabel {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
private Integer pid;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer isLast;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<UserCertificateLabel> children;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.UserCertificateLabel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserCertificateLabelService extends IService<UserCertificateLabel> {
|
||||
|
||||
List<UserCertificateLabel> userCertificateLabelList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.UserCertificateLabelDao;
|
||||
import com.peanut.modules.common.entity.CourseMedicine;
|
||||
import com.peanut.modules.common.entity.UserCertificateLabel;
|
||||
import com.peanut.modules.common.service.UserCertificateLabelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonUserCertificateLabelService")
|
||||
public class UserCertificateLabelServiceImpl extends ServiceImpl<UserCertificateLabelDao, UserCertificateLabel> implements UserCertificateLabelService {
|
||||
|
||||
@Override
|
||||
public List<UserCertificateLabel> userCertificateLabelList() {
|
||||
return this.labels(0);
|
||||
}
|
||||
|
||||
private List<UserCertificateLabel> labels(int id){
|
||||
List<UserCertificateLabel> list = this.list(new LambdaQueryWrapper<UserCertificateLabel>()
|
||||
.eq(UserCertificateLabel::getPid, id)
|
||||
.orderByAsc(UserCertificateLabel::getSort));
|
||||
for (UserCertificateLabel label : list){
|
||||
if(label.getIsLast()!=1){
|
||||
List<UserCertificateLabel> childrens = this.labels(label.getId());
|
||||
label.setChildren(childrens);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.UserCertificate;
|
||||
import com.peanut.modules.common.entity.UserCertificateLabel;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.UserCertificateLabelService;
|
||||
import com.peanut.modules.common.service.UserCertificateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 证书管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterUserCertificate")
|
||||
@RequestMapping("master/userCertificate")
|
||||
public class UserCertificateController {
|
||||
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
@Autowired
|
||||
private UserCertificateLabelService userCertificateLabelService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
//标签列表
|
||||
@RequestMapping("/userCertificateLabelList")
|
||||
public R userCertificateLabelList() {
|
||||
List<UserCertificateLabel> labelList = userCertificateLabelService.userCertificateLabelList();
|
||||
return R.ok().put("labelList", labelList);
|
||||
}
|
||||
|
||||
//标签下证书列表
|
||||
@RequestMapping("/userCertificateListByLabel")
|
||||
public R userCertificateListByLabel(@RequestBody Map<String,Object> params) {
|
||||
Page<UserCertificate> certificatePage = userCertificateService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()),
|
||||
Long.parseLong(params.get("limit").toString())),new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getLabelId,params.get("labelId")));
|
||||
for (UserCertificate certificate:certificatePage.getRecords()){
|
||||
certificate.setUser(myUserService.getById(certificate.getUserId()));
|
||||
}
|
||||
return R.ok().put("certificateList", certificatePage);
|
||||
}
|
||||
|
||||
//新增标签
|
||||
@RequestMapping("/saveUserCertificateLabel")
|
||||
public R saveUserCertificate(@RequestBody UserCertificateLabel label) {
|
||||
userCertificateLabelService.save(label);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改标签
|
||||
@RequestMapping("/editUserCertificateLabel")
|
||||
public R editUserCertificateLabel(@RequestBody UserCertificateLabel label) {
|
||||
UserCertificateLabel oldLabel = userCertificateLabelService.getById(label.getId());
|
||||
if(oldLabel.getIsLast()==0&& label.getIsLast()==1){
|
||||
List<UserCertificateLabel> childrens = userCertificateLabelService.list(new LambdaQueryWrapper<UserCertificateLabel>()
|
||||
.eq(UserCertificateLabel::getPid, label.getId()));
|
||||
if(childrens.size()>0){
|
||||
return R.error("更新失败,请先清空此项的下级标签,才能将此标签变成终极标签");
|
||||
}
|
||||
}
|
||||
if(oldLabel.getIsLast()==1&& label.getIsLast()==0){
|
||||
Integer integer = userCertificateService.count(new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getLabelId, label.getId()));
|
||||
if(integer>0){
|
||||
return R.error("更新失败,标签下存在证书");
|
||||
}
|
||||
}
|
||||
userCertificateLabelService.updateById(label);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除标签
|
||||
@RequestMapping("/delUserCertificateLabel")
|
||||
public R delUserCertificateLabel(@RequestBody Map<String,Object> params) {
|
||||
//查看下一级是否存在
|
||||
int count = userCertificateLabelService.count(new LambdaQueryWrapper<UserCertificateLabel>()
|
||||
.eq(UserCertificateLabel::getPid, params.get("id")));
|
||||
if(count>0){
|
||||
return R.error("删除失败,请先删除子项目后再尝试");
|
||||
}
|
||||
//查看绑定关系是否存在
|
||||
Integer integer = userCertificateService.count(new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getLabelId, params.get("id")));
|
||||
if(integer>0){
|
||||
return R.error("删除失败,标签下存在证书");
|
||||
}
|
||||
userCertificateLabelService.removeById((int)params.get("id"));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user