提交 ac05e3ce 作者: 张小凤

Licence(add)

上级 b4c53bea
package com.mmc.csf.licence.dto;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
/**
* @Author small
* @Date 2023/7/14 16:51
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseOrganizationsDTO {
private static final long serialVersionUID = -5814724843819090363L;
@ApiModelProperty(value = "机构id", example = "1")
@NotNull(message = "机构id", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "机构主图不能为空", example = "http://", required = true)
@NotBlank(message = "机构主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构副图不能为空", example = "http://", required = true)
@NotBlank(message = "机构副图不能为空", groups = {Create.class, Update.class})
private String auxiliaryPicture;
@ApiModelProperty(value = "机构视频", example = "http://")
private String video;
@ApiModelProperty(value = "机构名称不能为空", example = "科比特智能教育", required = true)
@NotBlank(message = "机构名称不能为空", groups = {Create.class, Update.class})
@Size(max = 25, message = "机构名称不能超过25个字符")
private String name;
@ApiModelProperty(name = "机构地区", example = "110000,110100")
@NotBlank(message = "机构地区不能为空", groups = {Create.class, Update.class})
private String region;
@ApiModelProperty(name = "机构地区名称", example = "河北省,石家庄市", required = true)
@NotBlank(message = "机构地区名称", groups = {Create.class, Update.class})
private String regionName;
@ApiModelProperty(name = "机构详细地址", example = "南山区")
@NotBlank(message = "机构详细地址不能为空", groups = {Create.class, Update.class})
private String detailedAddress;
@ApiModelProperty(name = "是否是考点机构 0否 1是", example = "0", required = true)
@NotNull(message = "考点机构不能为空", groups = {Create.class, Update.class})
private Integer testCenter;
@ApiModelProperty(name = "机构规模id不能为空 ", example = "1")
//@NotNull(message = "机构规模id不能为空", groups = {Create.class, Update.class})
private Integer scaleId;
@ApiModelProperty(name = "机构规模名称", example = "1")
private String scaleName;
@ApiModelProperty(name = "机构描述", example = "机构描述0001")
//@NotNull(message = "机构描述", groups = {Create.class, Update.class})
private String description;
@ApiModelProperty(name = "机构详情", example = "机构详情0001")
//@NotNull(message = "机构描述", groups = {Create.class, Update.class})
private String detail;
@ApiModelProperty(name = "培训项目", required = false)
private List<LicenseTrainingProgramsDTO> programsDOList;
}
package com.mmc.csf.licence.dto;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* @Author small
* @Date 2023/7/14 13:30
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseTrainingProgramsDTO {
private static final long serialVersionUID = -5814724843819090363L;
@ApiModelProperty(value = "培训id", example = "1")
@NotNull(message = "培训id不能为空", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "培训等级id", example = "1", required = true)
@NotNull(message = "培训等级id不能为空", groups = {Create.class, Update.class})
private Integer gradeId;
@ApiModelProperty(value = "培训等级名称", example = "1", required = true)
@NotNull(message = "培训等级名称不能为空", groups = {Create.class, Update.class})
private String gradeName;
@ApiModelProperty(value = "培训机型id", example = "1", required = true)
@NotNull(message = "培训机型id不能为空", groups = {Create.class, Update.class})
private Integer modelsId;
@ApiModelProperty(value = "培训机型名称", example = "1", required = true)
@NotNull(message = "培训机型名称不能为空", groups = {Create.class, Update.class})
private String modelsName;
@ApiModelProperty(value = "培训类型id", example = "1", required = true)
@NotNull(message = "培训类型id不能为空", groups = {Create.class, Update.class})
private Integer typeId;
@ApiModelProperty(value = "培训类型名称", example = "1", required = true)
@NotNull(message = "培训类型名称", groups = {Create.class, Update.class})
private String typeName;
@ApiModelProperty(value = "培训价格", example = "1000", required = true)
@NotNull(message = "培训价格不能为空", groups = {Create.class, Update.class})
@Size(min = 0, max = 100000, message = "价格不能超过100000")
private Integer price;
@ApiModelProperty(value = "培训地点不能为空", example = "广东省深圳市南山区XXX001", required = true)
@NotBlank(message = "培训地点不能为空", groups = {Create.class, Update.class})
private String place;
@ApiModelProperty(value = "培训主图不能为空", example = "http://", required = true)
@NotBlank(message = "培训主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构id", example = "http://", required = true)
@NotBlank(message = "机构id", groups = {Create.class, Update.class})
private Integer orgId;
}
package com.mmc.csf.licence.qo;
import com.mmc.csf.release.model.group.Freeze;
import com.mmc.csf.release.model.group.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/7/14 16:58
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseOrganizationsQO {
@ApiModelProperty(value = "机构名称不能为空", example = "科比特智能教育", required = false)
private String name;
@ApiModelProperty(value = "培训等级id", example = "1", required = false)
private Integer gradeId;
@ApiModelProperty(value = "培训机型id", example = "1", required = false)
private Integer modelsId;
@ApiModelProperty(value = "培训类型id", example = "1", required = false)
private Integer typeId;
@ApiModelProperty(value = "开始时间,如果只有一个日期,就开始时间与结束时间一致", example = "2023-07-14", required = false)
private String statTime;
@ApiModelProperty(value = "结束时间", example = "2023-07-14", required = false)
private String endTime;
@ApiModelProperty(value = "机构id", example = "1", required = false)
private Integer id;
@ApiModelProperty(value = "地域region", example = "110000", required = false)
private String region;
@ApiModelProperty(value = "当前页", required = true, example = "1")
@NotNull(message = "当前页不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "页大小", required = true, example = "10")
@NotNull(message = "页大小不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.csf.licence.vo;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
/**
* @Author small
* @Date 2023/7/13 16:07
* @Version 1.0
*/
@Data
public class LicenseOrganizationsVO {
private static final long serialVersionUID = -5814724843819090363L;
@ApiModelProperty(value = "机构id", example = "1")
@NotNull(message = "机构id", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "机构主图不能为空", example = "http://", required = true)
@NotBlank(message = "机构主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构副图不能为空", example = "http://", required = true)
@NotBlank(message = "机构副图不能为空", groups = {Create.class, Update.class})
private String auxiliaryPicture;
@ApiModelProperty(value = "机构视频", example = "http://")
private String video;
@ApiModelProperty(value = "机构名称不能为空", example = "科比特智能教育", required = true)
@NotBlank(message = "机构名称不能为空", groups = {Create.class, Update.class})
@Size(max = 25, message = "机构名称不能超过25个字符")
private String name;
@ApiModelProperty(name = "机构地区编号", example = "110000,130100", required = true)
@NotBlank(message = "机构地区不能为空", groups = {Create.class, Update.class})
private String region;
@ApiModelProperty(name = "机构地区名称", example = "河北省,石家庄市", required = true)
@NotBlank(message = "机构地区名称", groups = {Create.class, Update.class})
private String regionName;
@ApiModelProperty(name = "机构详细地址", example = "南山区", required = true)
@NotBlank(message = "机构详细地址不能为空", groups = {Create.class, Update.class})
private String detailedAddress;
@ApiModelProperty(name = "是否是考点机构 0否 1是", example = "0", required = true)
@NotNull(message = "考点机构不能为空 0否 1是", groups = {Create.class, Update.class})
private Integer testCenter;
@ApiModelProperty(name = "机构规模id不能为空", example = "1")
//@NotNull(message = "机构规模id不能为空", groups = {Create.class, Update.class})
private Integer scaleId;
@ApiModelProperty(name = "机构描述", example = "机构描述0001")
//@NotNull(message = "机构描述", groups = {Create.class, Update.class})
private String description;
@ApiModelProperty(name = "机构详情", example = "机构详情0001", required = true)
@NotNull(message = "机构详情", groups = {Create.class, Update.class})
private String detail;
@ApiModelProperty(name = "培训项目", required = true)
@NotNull(message = "培训项目", groups = {Create.class, Update.class})
private List<LicenseTrainingProgramsVO> trainingProgramsVOS;
}
package com.mmc.csf.licence.vo;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Objects;
/**
* @Author small
* @Date 2023/7/14 11:12
* @Version 1.0
*/
@Data
public class LicenseTrainingProgramsVO {
private static final long serialVersionUID = -5814724843819090363L;
@ApiModelProperty(value = "培训id", example = "1")
@NotNull(message = "培训id不能为空", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "培训等级id", example = "1", required = true)
@NotNull(message = "培训等级id不能为空", groups = {Create.class, Update.class})
private Integer gradeId;
@ApiModelProperty(value = "培训机型id", example = "1", required = true)
@NotNull(message = "培训机型id不能为空", groups = {Create.class, Update.class})
private Integer modelsId;
@ApiModelProperty(value = "培训类型id", example = "1", required = true)
@NotNull(message = "培训类型id不能为空", groups = {Create.class, Update.class})
private Integer typeId;
@ApiModelProperty(value = "培训价格", example = "1000", required = true)
@NotNull(message = "培训价格不能为空", groups = {Create.class, Update.class})
@Range(min = 0, max = 100000, message = "价格不能超过100000")
private Integer price;
@ApiModelProperty(value = "培训地点不能为空", example = "广东省深圳市南山区XXX001", required = true)
@NotBlank(message = "培训地点不能为空", groups = {Create.class, Update.class})
private String place;
@ApiModelProperty(value = "培训主图不能为空", example = "http://", required = true)
@NotBlank(message = "培训主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构id", hidden = true)
private Integer orgId;
@Override
public boolean equals(Object train) {
LicenseTrainingProgramsVO programsVO = (LicenseTrainingProgramsVO) train;
if (this.gradeId.equals(programsVO.getGradeId()) && this.modelsId.equals(programsVO.getModelsId())
&& this.typeId.equals(programsVO.getTypeId())) {
return true;
} else {
return false;
}
}
@Override
public int hashCode() {
return Objects.hash(gradeId, modelsId, typeId);
}
}
package com.mmc.csf.release.model.group; package com.mmc.csf.release.model.group;
import javax.validation.groups.Default;
/** /**
* @author 作者 geDuo * @author 作者 geDuo
* @version 创建时间:2021年8月28日 下午5:37:44 * @version 创建时间:2021年8月28日 下午5:37:44
* @explain 类说明 * @explain 类说明
*/ */
public @interface Create { public interface Create extends Default {
} }
package com.mmc.csf.release.model.group; package com.mmc.csf.release.model.group;
import javax.validation.groups.Default;
/** /**
* @author 作者 geDuo * @author 作者 geDuo
* @version 创建时间:2021年8月28日 下午5:37:52 * @version 创建时间:2021年8月28日 下午5:37:52
* @explain 类说明 * @explain 类说明
*/ */
public @interface Update { public interface Update extends Default {
} }
...@@ -402,7 +402,9 @@ public enum ResultEnum implements BaseErrorInfoInterface { ...@@ -402,7 +402,9 @@ public enum ResultEnum implements BaseErrorInfoInterface {
INDUSTRY_NEWS_TITLE_EXISTS("40200", "文章标题存在"), INDUSTRY_NEWS_TITLE_EXISTS("40200", "文章标题存在"),
// 论坛 // 论坛
DYNAMIC_SENSITIVE_INFO("50100", "发布内容涉及敏感信息!"); DYNAMIC_SENSITIVE_INFO("50100", "发布信息涉及敏感信息!"),
THE_ORGANIZATION_NAME_ALREADY_EXISTS("60001", "机构名称已存在"),
THREE_FIELDS_CAN_BE_REPEATED("60002", "机型、等级、价格存在重复");
/** /**
* 错误码 * 错误码
* *
......
package com.mmc.csf.release.controller.licence;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.licence.dto.LicenseOrganizationsDTO;
import com.mmc.csf.licence.qo.LicenseOrganizationsQO;
import com.mmc.csf.licence.vo.LicenseOrganizationsVO;
import com.mmc.csf.release.controller.BaseController;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Page;
import com.mmc.csf.release.model.group.Update;
import com.mmc.csf.release.service.licence.LicenceBackgroundService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* @Author small
* @Date 2023/7/13 16:00
* @Version 1.0
*/
@Api(tags = {"执照——后台管理"})
@RestController
@RequestMapping("/licence/background")
public class LicenceBackgroundController extends BaseController {
@Autowired
private LicenceBackgroundService licenceBackgroundService;
@ApiOperation(value = "机构-上传")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/insertOrg")
public ResultBody insertOrganizations(HttpServletRequest request, @RequestBody @Validated(value = {Create.class}) LicenseOrganizationsVO organizations) {
return licenceBackgroundService.insertOrganizations(organizations, this.getUserLoginInfoFromRedis(request));
}
@ApiOperation(value = "机构-修改")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/updateOrg")
public ResultBody updateOrganizations(HttpServletRequest request, @RequestBody @Validated(value = {Update.class}) LicenseOrganizationsVO organizations) {
return licenceBackgroundService.updateOrganizations(organizations, this.getUserLoginInfoFromRedis(request));
}
@ApiOperation(value = "机构-删除")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/removeOrg")
public ResultBody removeOrganizations(@ApiParam(value = "机构id", required = true) @RequestParam Integer id) {
return licenceBackgroundService.removeOrganizations(id);
}
@ApiOperation(value = "机构列表-分页")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = LicenseOrganizationsDTO.class)})
@PostMapping("/listOrgPage")
public ResultBody<LicenseOrganizationsDTO> listOrgPage(HttpServletRequest request,
@Validated(value = {Page.class}) @ApiParam(value = "角色查询QO", required = true) @RequestBody LicenseOrganizationsQO organizationsQO) {
return ResultBody.success(licenceBackgroundService.listOrgPage(organizationsQO, this.getUserLoginInfoFromRedis(request)));
}
@ApiOperation(value = "app机构列表-分页")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = LicenseOrganizationsDTO.class)})
@PostMapping("/appListOrgPage")
public ResultBody<LicenseOrganizationsDTO> appListOrgPage(HttpServletRequest request,
@Validated(value = {Page.class}) @ApiParam(value = "角色查询QO", required = true) @RequestBody LicenseOrganizationsQO organizationsQO) {
return ResultBody.success(licenceBackgroundService.listOrgPage(organizationsQO, this.getUserLoginInfoFromRedis(request)));
}
@ApiOperation(value = "web机构列表-分页")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = LicenseOrganizationsDTO.class)})
@PostMapping("/webListOrgPage")
public ResultBody<LicenseOrganizationsDTO> webListOrgPage(HttpServletRequest request,
@Validated(value = {Page.class}) @ApiParam(value = "角色查询QO", required = true) @RequestBody LicenseOrganizationsQO organizationsQO) {
return ResultBody.success(licenceBackgroundService.listOrgPage(organizationsQO, this.getUserLoginInfoFromRedis(request)));
}
}
...@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
* @Date 2023/7/13 14:32 * @Date 2023/7/13 14:32
* @Version 1.0 * @Version 1.0
*/ */
@Api(tags = {"执照公共下拉列表"}) @Api(tags = {"执照——公共下拉列表"})
@RestController @RestController
@RequestMapping("/licence/pullDown") @RequestMapping("/licence/pullDown")
public class LicenceCommonController { public class LicenceCommonController {
......
package com.mmc.csf.release.dao.licence;
import com.mmc.csf.licence.qo.LicenseOrganizationsQO;
import com.mmc.csf.release.entity.licence.LicenseOrganizationsDO;
import com.mmc.csf.release.entity.licence.LicenseProgramsDO;
import com.mmc.csf.release.entity.licence.LicenseTrainingProgramsDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small
* @Date 2023/7/13 16:02
* @Version 1.0
*/
@Mapper
public interface LicenceBackgroundDao {
int countOrg(String name);
void insertOrganizations(LicenseOrganizationsDO organizationsDO);
void insertLicenseOrgTraining(List<Integer> orgTrainingIds, Integer orgId);
int countId(LicenseOrganizationsDO organizationsDO);
void removeOrgAndTraining(Integer id);
void updateOrganizations(LicenseOrganizationsDO organizationsDO);
void removeOrganizations(Integer id);
void removeOrgTraining(Integer id);
int countPro(Integer modelsId, Integer gradeId, Integer typeId, Integer id);
void insertProject(LicenseTrainingProgramsDO programsDO);
void updateProject(LicenseTrainingProgramsDO programsDO);
void removeProject(Integer id);
List<LicenseProgramsDO> LicenseTrainingProgramsDTO(Integer id);
int countListOrgPage(LicenseOrganizationsQO organizationsQO);
List<LicenseOrganizationsDO> listOrgPage(LicenseOrganizationsQO organizationsQO);
List<LicenseProgramsDO> trainingProgram(LicenseOrganizationsQO organizationsQO);
int removeOrg(Integer id);
}
package com.mmc.csf.release.entity.licence;
import com.mmc.csf.licence.dto.LicenseOrganizationsDTO;
import com.mmc.csf.licence.dto.LicenseTrainingProgramsDTO;
import com.mmc.csf.licence.vo.LicenseOrganizationsVO;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @Author small
* @Date 2023/7/13 16:42
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseOrganizationsDO {
@ApiModelProperty(value = "机构id", example = "1")
@NotNull(message = "机构id", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "机构主图不能为空", example = "http://", required = true)
//@Size(max = 10, message = "机构主图")
@NotBlank(message = "机构主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构副图不能为空", example = "http://", required = true)
@NotBlank(message = "机构副图不能为空", groups = {Create.class, Update.class})
private String auxiliaryPicture;
@ApiModelProperty(value = "机构视频", example = "http://")
private String video;
@ApiModelProperty(value = "机构名称不能为空", example = "科比特智能教育", required = true)
@NotBlank(message = "机构名称不能为空", groups = {Create.class, Update.class})
private String name;
@ApiModelProperty(name = "机构地区", example = "110000,110100")
@NotBlank(message = "机构地区不能为空", groups = {Create.class, Update.class})
private String region;
@ApiModelProperty(name = "机构地区名称", example = "河北省,石家庄市", required = true)
@NotBlank(message = "机构地区名称", groups = {Create.class, Update.class})
private String regionName;
@ApiModelProperty(name = "机构详细地址", example = "南山区")
@NotBlank(message = "机构详细地址不能为空", groups = {Create.class, Update.class})
private String detailedAddress;
@ApiModelProperty(name = "是否是考点机构", example = "0", required = true)
@NotNull(message = "考点机构不能为空", groups = {Create.class, Update.class})
private Integer testCenter;
@ApiModelProperty(name = "机构规模id不能为空", example = "1")
private Integer scaleId;
@ApiModelProperty(name = "机构规模名称", example = "1")
private String scaleName;
@ApiModelProperty(name = "机构描述", example = "机构描述0001")
private String description;
@ApiModelProperty(name = "机构详情", example = "机构详情0001")
private String detail;
@ApiModelProperty(name = "机构培训项目id", example = "1,2")
private List<Integer> orgTrainingIds;
@ApiModelProperty(name = "培训项目", required = false)
private List<LicenseTrainingProgramsDTO> programsDOList;
/**
* VO类转换
*/
public LicenseOrganizationsDO(LicenseOrganizationsVO organizationsVO) {
this.id = organizationsVO.getId();
this.mainImage = organizationsVO.getMainImage();
this.auxiliaryPicture = organizationsVO.getAuxiliaryPicture();
this.video = organizationsVO.getVideo();
this.name = organizationsVO.getName();
this.region = organizationsVO.getRegion();
this.testCenter = organizationsVO.getTestCenter();
this.scaleId = organizationsVO.getScaleId();
this.description = organizationsVO.getDescription();
this.detail = organizationsVO.getDetail();
this.detailedAddress = organizationsVO.getDetailedAddress();
this.regionName = organizationsVO.getRegionName();
}
/**
* DTO转换
*
* @return
*/
public LicenseOrganizationsDTO organizationsDTO() {
return LicenseOrganizationsDTO.builder()
.id(this.id)
.mainImage(this.mainImage)
.auxiliaryPicture(this.auxiliaryPicture)
.video(this.video)
.name(this.name)
.region(this.region)
.detailedAddress(this.detailedAddress)
.scaleId(this.scaleId)
.testCenter(this.testCenter)
.scaleName(this.scaleName)
.description(this.description)
.detail(this.detail)
.programsDOList(this.programsDOList)
.regionName(this.regionName)
.build();
}
}
package com.mmc.csf.release.entity.licence;
import com.mmc.csf.licence.dto.LicenseTrainingProgramsDTO;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* @Author small
* @Date 2023/7/14 13:37
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class LicenseProgramsDO {
private static final long serialVersionUID = -5814724843819090363L;
@ApiModelProperty(value = "培训id", example = "1")
@NotNull(message = "培训id不能为空", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "培训等级id", example = "1", required = true)
@NotNull(message = "培训等级id不能为空", groups = {Create.class, Update.class})
private Integer gradeId;
@ApiModelProperty(value = "培训等级名称", example = "1", required = true)
@NotNull(message = "培训等级名称不能为空", groups = {Create.class, Update.class})
private String gradeName;
@ApiModelProperty(value = "培训机型id", example = "1", required = true)
@NotNull(message = "培训机型id不能为空", groups = {Create.class, Update.class})
private Integer modelsId;
@ApiModelProperty(value = "培训机型名称", example = "1", required = true)
@NotNull(message = "培训机型名称不能为空", groups = {Create.class, Update.class})
private String modelsName;
@ApiModelProperty(value = "培训类型id", example = "1", required = true)
@NotNull(message = "培训类型id不能为空", groups = {Create.class, Update.class})
private Integer typeId;
@ApiModelProperty(value = "培训类型名称", example = "1", required = true)
@NotNull(message = "培训类型名称", groups = {Create.class, Update.class})
private String typeName;
@ApiModelProperty(value = "培训价格", example = "1000", required = true)
@NotNull(message = "培训价格不能为空", groups = {Create.class, Update.class})
@Size(min = 0, max = 100000, message = "价格不能超过100000")
private Integer price;
@ApiModelProperty(value = "培训地点不能为空", example = "广东省深圳市南山区XXX001", required = true)
@NotBlank(message = "培训地点不能为空", groups = {Create.class, Update.class})
private String place;
@ApiModelProperty(value = "培训主图不能为空", example = "http://", required = true)
@NotBlank(message = "培训主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
@ApiModelProperty(value = "机构id", example = "http://", required = true)
@NotBlank(message = "机构id", groups = {Create.class, Update.class})
private Integer orgId;
/**
* DTO转换
*
* @return
*/
public LicenseTrainingProgramsDTO buildTrainingProgramsDTO() {
return LicenseTrainingProgramsDTO.builder().id(this.id)
.gradeId(this.gradeId)
.gradeName(this.gradeName)
.modelsId(this.modelsId)
.modelsName(this.modelsName)
.typeId(this.typeId)
.typeName(this.typeName)
.price(this.price)
.place(this.place)
.mainImage(this.mainImage)
.orgId(this.orgId)
.build();
}
}
package com.mmc.csf.release.entity.licence;
import com.mmc.csf.licence.vo.LicenseTrainingProgramsVO;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/7/14 11:20
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LicenseTrainingProgramsDO {
@ApiModelProperty(value = "培训id", example = "1")
@NotNull(message = "培训id不能为空", groups = Update.class)
private Integer id;
@ApiModelProperty(value = "培训等级id", example = "1", required = true)
@NotNull(message = "培训等级id不能为空", groups = {Create.class, Update.class})
private Integer gradeId;
@ApiModelProperty(value = "培训机型id", example = "1", required = true)
@NotNull(message = "培训机型id不能为空", groups = {Create.class, Update.class})
private Integer modelsId;
@ApiModelProperty(value = "培训类型id", example = "1", required = true)
@NotNull(message = "培训类型id不能为空", groups = {Create.class, Update.class})
private Integer typeId;
@ApiModelProperty(value = "培训价格", example = "1000", required = true)
@NotNull(message = "培训价格不能为空", groups = {Create.class, Update.class})
private Integer price;
@ApiModelProperty(value = "培训地点不能为空", example = "1", required = true)
@NotBlank(message = "培训地点不能为空", groups = {Create.class, Update.class})
private String place;
@ApiModelProperty(value = "培训主图不能为空", example = "1", required = true)
@NotBlank(message = "培训主图不能为空", groups = {Create.class, Update.class})
private String mainImage;
/**
* VO类转换
*/
public LicenseTrainingProgramsDO(LicenseTrainingProgramsVO programsVO) {
this.id = programsVO.getId();
this.mainImage = programsVO.getMainImage();
this.gradeId = programsVO.getGradeId();
this.modelsId = programsVO.getModelsId();
this.typeId = programsVO.getTypeId();
this.price = programsVO.getPrice();
this.place = programsVO.getPlace();
}
}
package com.mmc.csf.release.service.licence;
import com.mmc.csf.common.util.page.PageResult;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.licence.qo.LicenseOrganizationsQO;
import com.mmc.csf.licence.vo.LicenseOrganizationsVO;
import com.mmc.csf.release.auth.dto.LoginSuccessDTO;
/**
* @Author small
* @Date 2023/7/13 16:01
* @Version 1.0
*/
public interface LicenceBackgroundService {
ResultBody insertOrganizations(LicenseOrganizationsVO organizations, LoginSuccessDTO userLoginInfoFromRedis);
ResultBody updateOrganizations(LicenseOrganizationsVO organizations, LoginSuccessDTO userLoginInfoFromRedis);
ResultBody removeOrganizations(Integer id);
PageResult listOrgPage(LicenseOrganizationsQO organizationsQO, LoginSuccessDTO userLoginInfoFromRedis);
}
package com.mmc.csf.release.service.licence.impl;
import com.mmc.csf.common.util.page.PageResult;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.common.util.web.ResultEnum;
import com.mmc.csf.licence.dto.LicenseOrganizationsDTO;
import com.mmc.csf.licence.dto.LicenseTrainingProgramsDTO;
import com.mmc.csf.licence.qo.LicenseOrganizationsQO;
import com.mmc.csf.licence.vo.LicenseOrganizationsVO;
import com.mmc.csf.licence.vo.LicenseTrainingProgramsVO;
import com.mmc.csf.release.auth.dto.LoginSuccessDTO;
import com.mmc.csf.release.dao.licence.LicenceBackgroundDao;
import com.mmc.csf.release.entity.licence.LicenseOrganizationsDO;
import com.mmc.csf.release.entity.licence.LicenseProgramsDO;
import com.mmc.csf.release.entity.licence.LicenseTrainingProgramsDO;
import com.mmc.csf.release.service.licence.LicenceBackgroundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small
* @Date 2023/7/13 16:01
* @Version 1.0
*/
@Service
@Slf4j
public class LicenceBackgroundServiceImpl implements LicenceBackgroundService {
@Autowired
private LicenceBackgroundDao licenceBackgroundDao;
@Override
public ResultBody insertOrganizations(LicenseOrganizationsVO organizations, LoginSuccessDTO userLoginInfoFromRedis) {
int count = licenceBackgroundDao.countOrg(organizations.getName());
if (count > 0) {
return ResultBody.error(ResultEnum.THE_ORGANIZATION_NAME_ALREADY_EXISTS);
}
LicenseOrganizationsDO organizationsDO = new LicenseOrganizationsDO(organizations);
List<Integer> list = new ArrayList<>();
LicenseTrainingProgramsDO programsDO = null;
if (organizations.getTrainingProgramsVOS() != null && organizations.getTrainingProgramsVOS().size() != 0) {
HashMap<LicenseTrainingProgramsVO, Integer> hashMap = new HashMap<>();
for (LicenseTrainingProgramsVO trainingProgramsVO : organizations.getTrainingProgramsVOS()) {
Integer pro = hashMap.get(trainingProgramsVO);
if (pro == null) {
hashMap.put(trainingProgramsVO, 1);
programsDO = new LicenseTrainingProgramsDO(trainingProgramsVO);
licenceBackgroundDao.insertProject(programsDO);
list.add(programsDO.getId());
organizationsDO.setOrgTrainingIds(list);
} else {
licenceBackgroundDao.removeProject(programsDO.getId());
hashMap.put(trainingProgramsVO, pro++);
return ResultBody.error(ResultEnum.THREE_FIELDS_CAN_BE_REPEATED);
}
}
licenceBackgroundDao.insertOrganizations(organizationsDO);
licenceBackgroundDao.insertLicenseOrgTraining(organizationsDO.getOrgTrainingIds(), organizationsDO.getId());
}
return ResultBody.success();
}
@Override
public ResultBody updateOrganizations(LicenseOrganizationsVO organizations, LoginSuccessDTO userLoginInfoFromRedis) {
LicenseOrganizationsDO organizationsDO = new LicenseOrganizationsDO(organizations);
int count = licenceBackgroundDao.countId(organizationsDO);
if (count > 0) {
return ResultBody.error(ResultEnum.THE_ORGANIZATION_NAME_ALREADY_EXISTS);
}
licenceBackgroundDao.removeOrgAndTraining(organizations.getId());
LicenseTrainingProgramsDO programsDO = null;
List<Integer> list = new ArrayList<>();
if (organizations.getTrainingProgramsVOS() != null && organizations.getTrainingProgramsVOS().size() != 0) {
HashMap<LicenseTrainingProgramsVO, Integer> hashMap = new HashMap<>();
for (LicenseTrainingProgramsVO trainingProgramsVO : organizations.getTrainingProgramsVOS()) {
Integer pro = hashMap.get(trainingProgramsVO);
if (pro == null) {
hashMap.put(trainingProgramsVO, 1);
} else {
hashMap.put(trainingProgramsVO, pro++);
return ResultBody.error(ResultEnum.THREE_FIELDS_CAN_BE_REPEATED);
}
licenceBackgroundDao.removeOrganizations(organizations.getId());
programsDO = new LicenseTrainingProgramsDO(trainingProgramsVO);
licenceBackgroundDao.insertProject(programsDO);
list.add(programsDO.getId());
organizationsDO.setOrgTrainingIds(list);
}
licenceBackgroundDao.updateOrganizations(organizationsDO);
licenceBackgroundDao.insertLicenseOrgTraining(organizationsDO.getOrgTrainingIds(), organizationsDO.getId());
}
return ResultBody.success();
}
@Override
public ResultBody removeOrganizations(Integer id) {
licenceBackgroundDao.removeOrg(id);
licenceBackgroundDao.removeOrganizations(id);
return ResultBody.success();
}
@Override
public PageResult listOrgPage(LicenseOrganizationsQO organizationsQO, LoginSuccessDTO userLoginInfoFromRedis) {
int count = licenceBackgroundDao.countListOrgPage(organizationsQO);
if (count == 0) {
return PageResult.buildPage(organizationsQO.getPageNo(), organizationsQO.getPageSize(), count);
}
Integer pageNo = organizationsQO.getPageNo();
organizationsQO.buildCurrentPage();
List<LicenseOrganizationsDO> licenseOrganizationsDOS = licenceBackgroundDao.listOrgPage(organizationsQO);
List<LicenseOrganizationsDTO> orgList = licenseOrganizationsDOS.stream().map(t -> t.organizationsDTO()).collect(Collectors.toList());
//培训项目数据
List<LicenseProgramsDO> licenseProgramsDOS = licenceBackgroundDao.trainingProgram(organizationsQO);
List<LicenseTrainingProgramsDTO> programsList = licenseProgramsDOS.stream().map(t -> t.buildTrainingProgramsDTO()).collect(Collectors.toList());
for (LicenseOrganizationsDTO org : orgList) {
ArrayList<LicenseTrainingProgramsDTO> list = new ArrayList<>();
for (LicenseTrainingProgramsDTO pro : programsList) {
if (org.getId().equals(pro.getOrgId())) {
list.add(pro);
org.setProgramsDOList(list);
}
}
}
List<LicenseOrganizationsDTO> collect = orgList.stream().filter(o -> {
if (o.getProgramsDOList() == null) {
return false;
}
return true;
}).collect(Collectors.toList());
if (collect.size() == 0) {
count = 0;
}
return PageResult.buildPage(pageNo, organizationsQO.getPageSize(), count, collect);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论