Commit 0b2e7cdd authored by 李博今's avatar 李博今

Merge branch 'V2.0.3' of http://103.249.252.28:90/lcy/education

parents fff6983e 293e86cf
......@@ -34,7 +34,7 @@ public class BAgencyController extends PaginationController<BAgency> {
@ApiOperation(value="添加教学单位", notes="添加教学单位")
@ApiImplicitParams({@ApiImplicitParam(name = "code", value = "教学单位编号(1-50)", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "name", value = "教学单位名(1-250)", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "name", value = "教学单位名(1-100)", required = true, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(@Valid @ApiIgnore BAgency bAgency, BindingResult bindingResult) {
PersistModel data = bAgencyServiceImpl.save(bAgency);
......@@ -56,10 +56,18 @@ public class BAgencyController extends PaginationController<BAgency> {
businessId);
}
@ApiOperation(value="查询教学单位下是否有用户", notes="查询教学单位下是否有用户")
@GetMapping(value = "/selectBAgencyHaveUser")
public String HaveUserOrNot(@ApiIgnore BAgency bAgency) {
bAgency.setCreateBy(UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID));
String result = bAgencyServiceImpl.findBAgencyHaveUserOrNot(getPaginationUtility(), bAgency);
return result;
}
@ApiOperation(value="修改教学单位", notes="修改教学单位")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "教学单位编号(1-50)", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "name", value = "教学单位名(1-250)", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "name", value = "教学单位名(1-100)", required = true, dataType = "varchar")})
@PutMapping("/update/{businessId:\\w+}")
public Result update(@Valid @ApiIgnore BAgency bAgency, BindingResult bindingResult) {
PersistModel data = bAgencyServiceImpl.merge(bAgency);
......
......@@ -60,5 +60,9 @@ public interface BAgencyRepository extends BaseMapper<BAgency> {
@Select("select * from b_agency where code = #{code} and del_flag = 0 and flag = 1")
@ResultMap(value = "BaseResultMap" )
List<BAgency> queryBAgencysByCode(String code);
@Select("select * from b_agency where business_id = #{businessId} and del_flag = 0 and flag = 1")
@ResultMap(value = "BaseResultMap" )
BAgency selectOneBagency(String businessId);
}
......@@ -29,7 +29,7 @@ public class BAgency extends IdEntity<BAgency> {
private String code;
/*代理商名*/
@Length(min = 1, max = 256, message = "长度最小为1,最大为250")
@Length(min = 1, max = 100, message = "长度最小为1,最大为250")
@NotBlank
private String name;
......@@ -39,5 +39,12 @@ public class BAgency extends IdEntity<BAgency> {
public BAgency(String code) {
this.code = code;
}
// public BAgency(String businessId, String del_flag, String flag){
// this.businessId = businessId;
// this.delFlag = del_flag;
// this.flag = flag;
// }
}
......@@ -48,6 +48,16 @@ public interface BAgencyService {
BAgency bAgency);
/**
* 查询教学单位下是否有用户
* @param paginationUtility
* @param bAgency
* @return
*/
String findBAgencyHaveUserOrNot(PageUtil paginationUtility,
BAgency bAgency);
List<BAgency> queryMoreByPagination(PageUtil paginationUtility,
BAgency bAgency);
......
......@@ -4,11 +4,17 @@ import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.bagency.dao.BAgencyRepository;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.business.bagency.service.BAgencyService;
import org.rcisoft.business.bcompany.dao.BCompanyRepository;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bteacher.dao.BTeacherRepository;
import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
......@@ -28,6 +34,15 @@ public class BAgencyServiceImpl implements BAgencyService {
@Autowired
private BAgencyRepository bAgencyRepository;
@Autowired
private BTeacherRepository bTeacherRepository;
@Autowired
private BCompanyRepository bCompanyRepository;
@Autowired
private SysUserMapper sysUserMapper;
/**
* 保存 bAgency
......@@ -49,6 +64,16 @@ public class BAgencyServiceImpl implements BAgencyService {
return new PersistModel(line);
}
public String findBAgencyHaveUserOrNot(PageUtil paginationUtility, BAgency bAgency){
List<BAgency> teacherAgency = bAgencyRepository.queryTeacherAgency(bAgency.getBusinessId());
List<BAgency> companyAgency = bAgencyRepository.queryCompanyAgency(bAgency.getBusinessId());
if(teacherAgency.size()>0||companyAgency.size()>0){
return "教学单位下存在用户";
}
return "教学单位下不存在用户";
}
/**
* 逻辑删除
* @param bAgency
......@@ -57,12 +82,30 @@ public class BAgencyServiceImpl implements BAgencyService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BAgency bAgency){
//先查询该教学单位是否被使用
List<BAgency> teacherAgency = bAgencyRepository.queryTeacherAgency(bAgency.getBusinessId());
List<BAgency> companyAgency = bAgencyRepository.queryCompanyAgency(bAgency.getBusinessId());
if(teacherAgency.size()>0||companyAgency.size()>0){
throw new ServiceException(ResultServiceEnums.AGENCY_IS_USED);
}
//利用教学单位code删除所对应的teacher和company的字段
BAgency bagency = bAgencyRepository.selectOneBagency(bAgency.getBusinessId());
String code = bagency.getCode();
BTeacher bTeacher = new BTeacher();
BCompany bCompany = new BCompany();
bTeacher.setAgencyCode(code);
bCompany.setAgencyCode(code);
//根据agency_code查询b_teacher
List<BTeacher> teacherList = bTeacherRepository.selectByAgencyCode(bTeacher);
//根据agency_code查询b_company
List<BCompany> companyList = bCompanyRepository.selectByAgencyCode(bCompany);
//删除b_teacher
bTeacherRepository.batchDeleteBycode(teacherList);
//删除b_company
bCompanyRepository.batchDeleteBycode(companyList);
//根据code查询s_user
List<SysUser> usersByTeacher = sysUserMapper.selectByTeacherCode(teacherList);
List<SysUser> usersByCompany = sysUserMapper.selectByCompanyCode(companyList);
//删除s_user
sysUserMapper.batchDeleteByTeacherCode(teacherList);
sysUserMapper.batchDeleteByCompanyCode(companyList);
//删除s_r_user_role
sysUserMapper.deleteTeacherUserRole(usersByTeacher);
sysUserMapper.deleteCompanyUserRole(usersByCompany);
UserUtil.setCurrentMergeOperation(bAgency);
bAgency.setDeleted();
int line = bAgencyRepository.logicalDelete(bAgency);
......
......@@ -37,6 +37,7 @@ public class BArrangeController extends PaginationController<BArrange> {
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(String json) {
System.out.println(json);
return Result.builder(bArrangeServiceImpl.save(json),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
......@@ -115,12 +115,18 @@ public class BArrangeServiceImpl implements BArrangeService {
List<BSubtask> subtaskList = new ArrayList<>();
JSONObject jsonObject = JSONObject.fromObject(json);
JSONObject arrange = jsonObject.getJSONObject("arrange");
// if (arrange.isEmpty()){
// throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR);
// }
bArrange.setDescription(arrange.getString("desc"));
bArrange.setTermCode(arrange.getString("termCode"));
bArrange.setStatus("0");
UserUtil.setCurrentPersistOperation(bArrange);
int line = bArrangeRepository.insertSelective(bArrange);
JSONArray childList = arrange.getJSONArray("childList");
// if (childList.isEmpty()){
// throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR);
// }
for(int i = 0; i < childList.size() ; i++){
JSONObject subtask = childList.getJSONObject(i);
BSubtask bSubtask = new BSubtask();
......
......@@ -3,6 +3,7 @@ package org.rcisoft.business.bcompany.dao;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
......@@ -31,4 +32,10 @@ public interface BCompanyRepository extends BaseMapper<BCompany>{
@Select("select agency_code from b_company where code = #{username}")
String queryAgencyCodeByCode(String username);
@Select("SELECT * from b_company where agency_code = #{agencyCode} and del_flag = 0 and flag = 1")
@ResultMap(value = "BaseResultMap" )
List<BCompany> selectByAgencyCode(BCompany bCompany);
int batchDeleteBycode(List<BCompany> companyList);
}
......@@ -43,7 +43,7 @@ public class BEduClassController extends PaginationController<BEduClass> {
@ApiImplicitParam(name = "agencyId", value = "企业ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "type", value = "班级类型", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "classesId", value = "教学班code串", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
@PostMapping(value = "/add")
@PreAuthorize("hasRole('ROLE_1001')")
public Result add(BEduClass bEduClass) {
bEduClass.setToken(getToken());
......
......@@ -22,6 +22,7 @@ public interface BGradeRepository extends BaseMapper<BGrade> {
@Select("<script>select * from b_grade where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "order by code desc"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BGrade> queryBGrades(BGrade bGrade);
......@@ -29,7 +30,7 @@ public interface BGradeRepository extends BaseMapper<BGrade> {
/**
查询是否有本年的年级
*/
@Select("<script>select * from b_grade where code = #{nowYear} </script>")
@Select("<script>select * from b_grade where code = #{nowYear} order by create_date desc</script>")
@ResultMap(value = "BaseResultMap" )
List<BGrade> queryBGradeByNowYear(String nowYear);
......
......@@ -27,6 +27,7 @@ public interface BRoomsRepository extends BaseMapper<BRooms> {
+ "<if test=\"code !=null and code != '' \">and code like concat(concat(\"%\",#{code}),\"%\") </if> "
+ "<if test=\"category !=null and category != '' \">and category = #{category} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "order by create_date desc"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BRooms> queryBRoomss(BRooms bRooms);
......
......@@ -33,7 +33,9 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"LEFT JOIN b_grade bg ON b.grade_code = bg.`code`\n" +
"where b.del_flag != 1 and b.flag = 1 "+
"<if test=\"name!=null and name != ''\">and u.`name` like CONCAT('%',#{name},'%') </if>"+
"<if test=\"code!=null and code != ''\">and b.`code` like CONCAT('%',#{code},'%') </if></script>")
"<if test=\"code!=null and code != ''\">and b.`code` like CONCAT('%',#{code},'%') </if>" +
"order by b.grade_code desc" +
"</script>")
@ResultMap(value = "BaseResultMap" )
List<BStudent> queryBStudents(BStudent param);
......@@ -44,7 +46,7 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
"LEFT JOIN b_student t3 ON t2.student_code = t3.`code`\n" +
"LEFT JOIN s_user t4 ON t3.`code` = t4.login_name\n" +
"WHERE\n" +
"\tt2.class_code = #{classCode} and t3.del_flag != 1 and t3.flag = 1</script>")
"\tt2.class_code = #{classCode} and t3.del_flag != 1 and t3.flag = 1 order by t3.grade_code desc</script>")
@ResultMap(value = "BaseResultMap" )
List<BStudent> queryStudentByClassCode(@Param("classCode") String classCode);
......
package org.rcisoft.business.bteacher.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
......@@ -75,5 +73,13 @@ public interface BTeacherRepository extends BaseMapper<BTeacher> {
"left JOIN s_user on b_schedule_dto.teacher_code = s_user.login_name where sub_agency_id = #{subAgencyId} GROUP BY `name` ")
@ResultMap(value = "SmallBaseResultMap" )
List<BTeacher> selectTeacherBySubAgencyId(String subAgencyId);
@Select("SELECT * from b_teacher where agency_code = #{agencyCode} and del_flag = 0 and flag = 1")
@ResultMap(value = "BaseResultMap" )
List<BTeacher> selectByAgencyCode(BTeacher bTeacher);
int batchDeleteBycode(List<BTeacher> teacherList);
}
......@@ -172,7 +172,7 @@ public enum ResultServiceEnums {
EXCEL_IMPORT_DATA_HAS_NULL(92,"第一行存在空数据"),
STARTDATE_AFTER_ENDDATE(93,"开始时间比结束时间晚"),
STARTDATE_AFTER_ENDDATE(93,"结束时间应晚于开始时间"),
STARTDATE_EQUAL_ENDDATE(94,"开始时间等于结束时间"),
......
......@@ -99,4 +99,17 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
"left join s_user on s_user.business_id = s_r_user_role.user_id " +
"where role_id = #{roleId} and s_user.del_flag = 0 ")
int countUserByRole(String roleId);
List<SysUser> selectByTeacherCode(List<BTeacher> teacherList);
List<SysUser> selectByCompanyCode(List<BCompany> companyList);
int batchDeleteByTeacherCode(List<BTeacher> teacherList);
int batchDeleteByCompanyCode(List<BCompany> bCompanyList);
int deleteTeacherUserRole(List<SysUser> userTeacherList);
int deleteCompanyUserRole(List<SysUser> userCompanyList);
}
......@@ -13,4 +13,11 @@
<result column="agency_code" jdbcType="INTEGER" property="agencyCode"/>
</resultMap>
<delete id="batchDeleteBycode" parameterType="java.util.List">
update b_company set del_flag = 1 where business_id IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.businessId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -22,4 +22,12 @@
<result column="teacher_code" jdbcType="VARCHAR" property="code"/>
<result column="name" jdbcType="VARCHAR" property="name" />
</resultMap>
<delete id="batchDeleteBycode" parameterType="java.util.List">
update b_teacher set del_flag = 1 where business_id IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.businessId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -18,4 +18,52 @@
<result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
</resultMap>
<select id="selectByTeacherCode" parameterType="java.util.List" resultMap="BaseResultMap">
SELECT business_id FROM s_user where del_flag = 0 and flag = 1 and login_name IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.code}
</foreach>
</select>
<select id="selectByCompanyCode" parameterType="java.util.List" resultMap="BaseResultMap">
SELECT business_id FROM s_user where del_flag = 0 and flag = 1 and login_name IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.code}
</foreach>
</select>
<delete id="batchDeleteByTeacherCode" parameterType="java.util.List">
update s_user set del_flag = 1 where login_name IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.code}
</foreach>
</delete>
<delete id="batchDeleteByCompanyCode" parameterType="java.util.List">
update s_user set del_flag = 1 where login_name IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.code}
</foreach>
</delete>
<delete id="deleteTeacherUserRole" parameterType="java.util.List">
delete FROM s_r_user_role WHERE user_id IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.businessId}
</foreach>
</delete>
<delete id="deleteCompanyUserRole" parameterType="java.util.List">
delete FROM s_r_user_role WHERE user_id IN
<foreach collection="list" item="item"
separator="," open="(" close=")">
#{item.businessId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment