Commit ea762979 authored by 刘子正's avatar 刘子正

更新bagency

parent 38903735
package org.rcisoft.business.bagency.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.business.bagency.service.BAgencyService;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
/**
* Created by on 2018-4-4 8:57:37.
*/
@RestController
@RequestMapping("/bagency")
public class BAgencyController extends PaginationController<BAgency> {
@Autowired
private BAgencyService bAgencyServiceImpl;
@ApiOperation(value="添加教学单位", notes="添加教学单位")
@ApiImplicitParams({@ApiImplicitParam(name = "code", value = "教学单位编号(1-50)", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "name", value = "教学单位名(1-250)", required = true, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(@Valid @ApiIgnore BAgency bAgency, BindingResult bindingResult) {
PersistModel data = bAgencyServiceImpl.save(bAgency);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bAgency);
}
@ApiOperation(value="逻辑删除教学单位", notes="逻辑删除教学单位")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")})
@DeleteMapping("/delete/{businessId:\\w+}")
public Result delete(@PathVariable String businessId, BAgency bAgency) {
bAgency.setBusinessId(businessId);
PersistModel data = bAgencyServiceImpl.remove(bAgency);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
@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")})
@PutMapping("/update/{businessId:\\w+}")
public Result update(@Valid @ApiIgnore BAgency bAgency, BindingResult bindingResult) {
PersistModel data = bAgencyServiceImpl.merge(bAgency);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bAgency);
}
@ApiOperation(value="查看单个教学单位", notes="查看单个教学单位")
@GetMapping("/detail/{businessId:\\w+}")
public Result detail(@PathVariable String businessId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bAgencyServiceImpl.findById(businessId));
}
@ApiOperation(value="根据条件查询教学单位表(不传条件默认为查全部)", notes="根据条件查询教学单位表(不传条件默认为查全部)")
@GetMapping(value = "/queryBAgencyByPagination")
public GridModel listByPagination(@ApiIgnore BAgency bAgency) {
bAgency.setCreateBy(UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID));
bAgencyServiceImpl.findAllByPagination(getPaginationUtility(), bAgency);
return getGridModelResponse();
}
/**
@ApiOperation(value="查询学期开过课的企业", notes="查询学期开过课的企业")
@ApiImplicitParams({@ApiImplicitParam(name = "termCode", value = "学期编码(长度最小为1,最大为50)", required = true, dataType = "varchar")})
@GetMapping(value = "/queryMoreByPagination")
public GridModel queryMoreByPagination(@ApiIgnore BAgency bAgency) {
bAgency.setCreateBy(UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID));
bAgencyServiceImpl.queryMoreByPagination(getPaginationUtility(), bAgency);
return getGridModelResponse();
}
*/
}
package org.rcisoft.business.bagency.dao;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2018-4-4 8:57:37.
*/
@Repository
public interface BAgencyRepository extends BaseMapper<BAgency> {
/**
* 分页查询 bAgency
*
*/
@Select("<script>select * from b_agency where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BAgency> queryBAgencys(BAgency bAgency);
/**
* 根据条件查询
* @param bAgency
* @return
*/
List<BAgency> listBAgencys(BAgency bAgency);
@Select("<script>select distinct b_agency.business_id,b_agency.code,b_agency.name from b_agency "
+ " left join b_edu_class on b_edu_class.agency_id = b_agency.business_id\n"
+ " left join b_sl on b_sl.edu_class_id = b_edu_class.business_id"
+ " where 1=1 and term_code = #{termCode}"
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BAgency> queryMoreByPagination(BAgency bAgency);
}
package org.rcisoft.business.bagency.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* Created with on 2018-4-4 8:57:36.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "b_agency")
public class BAgency extends IdEntity<BAgency> {
private static final long serialVersionUID = 4660799781307219222L;
/*代理商编号*/
@Length(min= 1 , max = 64, message = "长度最小为1,最大为50")
@NotBlank
private String code;
/*代理商名*/
@Length(min = 1, max = 256, message = "长度最小为1,最大为250")
@NotBlank
private String name;
@Transient
private String termCode;
}
package org.rcisoft.business.bagency.service;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import java.util.List;
/**
* Created by on 2018-4-4 8:57:37.
*/
public interface BAgencyService {
/**
* 保存
* @param bAgency
* @return
*/
PersistModel save(BAgency bAgency);
/**
* 逻辑删除
* @param bAgency
* @return
*/
PersistModel remove(BAgency bAgency);
/**
* 修改
* @param bAgency
* @return
*/
PersistModel merge(BAgency bAgency);
/**
* 根据id查询
* @param id
* @return
*/
BAgency findById(String id);
/**
* 分页查询
* @param bAgency
* @return
*/
List<BAgency> findAllByPagination(PageUtil paginationUtility,
BAgency bAgency);
List<BAgency> queryMoreByPagination(PageUtil paginationUtility,
BAgency bAgency);
}
package org.rcisoft.business.bagency.service.impl;
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.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Created by on 2018-4-4 8:57:37.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class BAgencyServiceImpl implements BAgencyService {
@Autowired
private BAgencyRepository bAgencyRepository;
/**
* 保存 bAgency
* @param bAgency
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(BAgency bAgency){
bAgency.setCommonBusinessId();
//增加操作
UserUtil.setCurrentPersistOperation(bAgency);
int line = bAgencyRepository.insertSelective(bAgency);
log.info(UserUtil.getUserInfoProp(bAgency.getToken(), UserUtil.USER_USERNAME)+"新增了ID为"+
bAgency.getBusinessId()+"的信息");
return new PersistModel(line);
}
/**
* 逻辑删除
* @param bAgency
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BAgency bAgency){
UserUtil.setCurrentMergeOperation(bAgency);
bAgency.setDeleted();
int line = bAgencyRepository.logicalDelete(bAgency);
log.info(UserUtil.getUserInfoProp(bAgency.getToken(), UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
bAgency.getBusinessId()+"的信息");
return new PersistModel(line);
}
/**
* 修改 bAgency
* @param bAgency
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(BAgency bAgency){
UserUtil.setCurrentMergeOperation(bAgency);
int line = bAgencyRepository.updateByPrimaryKeySelective(bAgency);
log.info(UserUtil.getUserInfoProp(bAgency.getToken(), UserUtil.USER_USERNAME)+"修改了ID为"+
bAgency.getBusinessId()+"的信息");
return new PersistModel(line);
}
/**
* 根据id查询 bAgency
* @param id
* @return
*/
@Override
public BAgency findById(String id){
return bAgencyRepository.selectByPrimaryKey(id);
}
/**
* 分页查询 bAgency
* @param bAgency
* @return
*/
@Override
public List<BAgency> findAllByPagination(PageUtil paginationUtility,
BAgency bAgency){
return bAgencyRepository.listBAgencys(bAgency);
}
@Override
public List<BAgency> queryMoreByPagination(PageUtil paginationUtility, BAgency bAgency) {
return bAgencyRepository.queryMoreByPagination(bAgency);
}
}
...@@ -71,4 +71,5 @@ public class BCourseCodeController extends PaginationController<BCourseCode> { ...@@ -71,4 +71,5 @@ public class BCourseCodeController extends PaginationController<BCourseCode> {
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
bCourseCodeServiceImpl.findAll(bCourseCode)); bCourseCodeServiceImpl.findAll(bCourseCode));
} }
} }
...@@ -28,6 +28,4 @@ public interface BCourseCodeService { ...@@ -28,6 +28,4 @@ public interface BCourseCodeService {
List<BCourseCode> findAll(BCourseCode bCourseCode); List<BCourseCode> findAll(BCourseCode bCourseCode);
} }
...@@ -150,8 +150,11 @@ public enum ResultServiceEnums { ...@@ -150,8 +150,11 @@ public enum ResultServiceEnums {
CLASSHOUR_ERROR (81,"学时不能小于当前已添加的学时"), CLASSHOUR_ERROR (81,"学时不能小于当前已添加的学时"),
THIS_IS_FILE (82,"该目录下不能新建文件") THIS_IS_FILE (82,"该目录下不能新建文件"),
;
PERVIOUS_NOT_ENABLED (83,"上一节课未启用"),
NEXT_NOT_DISABLED (84,"下一节课未停用");
private Integer code; private Integer code;
private String message; private String message;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.bagency.dao.BAgencyRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bagency.entity.BAgency">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="code" jdbcType="VARCHAR" property="code"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="listBAgencys" resultMap="BaseResultMap">
SELECT * FROM b_agency b
WHERE b.del_flag != '1' and flag = 1
<if test="name!=null and name != ''">
AND (b.name LIKE CONCAT('%',#{name},'%'))
</if>
<if test="code!=null and code != ''">
AND (b.code LIKE CONCAT('%',#{code},'%'))
</if>
</select>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</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