Bladeren bron

增加注释

chenyongxing 8 jaren geleden
bovenliggende
commit
94bb0a509f

+ 1 - 24
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/WlyyContants.java

@ -82,7 +82,7 @@ public class WlyyContants {
    }
    //协议模块常量
    public static class WlyySignFamily{
    public static class SignFamily{
        public static final String api_common="signFamily";
        public static final String api_create="create";
        public static final String api_delete="delete";
@ -105,29 +105,6 @@ public class WlyyContants {
        public static final String message_fail_expenseStatus_is_null="expenseStatus is null";
        public static final String message_fail_agreementCode_is_null="agreementCode is null";
        public static final String message_success_update="agreement update success";
        public static final String message_success_delete="agreement delete success";
        public static final String message_success_find="agreement find success";
        public static final String message_success_create="agreement create success";
        public static final String message_success_find_functions="agreement find success";
    }
    //协议模块常量
    public static class SignFamily{
        public static final String api_common="signFamily";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_success_update="signFamily update success";
        public static final String message_success_delete="signFamily delete success";
        public static final String message_success_find="signFamily find success";

File diff suppressed because it is too large
+ 219 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/util/IDCard.java


+ 14 - 13
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/controller/WlyySignFamilyController.java

@ -15,57 +15,58 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.WlyySignFamily.api_common)
@RequestMapping(WlyyContants.SignFamily.api_common)
@Api(value = "签约相关操作", description = "签约相关操作")
public class WlyySignFamilyController extends EnvelopRestController {
    @Autowired
    private WlyySignFamilyService wlyySignFamilyService;
    @PostMapping(value = WlyyContants.WlyySignFamily.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WlyyContants.SignFamily.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建签约", notes = "创建签约")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
            @RequestBody String jsonData) throws ParseException {
        try {
            WlyySignFamily wlyySignFamily = toEntity(jsonData, WlyySignFamily.class);
            return Envelop.getSuccess(WlyyContants.WlyySignFamily.message_success_create, wlyySignFamilyService.create(wlyySignFamily));
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_create, wlyySignFamilyService.create(wlyySignFamily));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.WlyySignFamily.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PutMapping(value = WlyyContants.SignFamily.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改签约", notes = "修改签约")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
            @RequestBody String jsonData) throws ParseException {
        try {
            WlyySignFamily wlyySignFamily = toEntity(jsonData, WlyySignFamily.class);
            return Envelop.getSuccess(WlyyContants.WlyySignFamily.message_success_update, wlyySignFamilyService.update(wlyySignFamily));
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_update, wlyySignFamilyService.update(wlyySignFamily));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.WlyySignFamily.api_getByCode)
    @GetMapping(value =WlyyContants.SignFamily.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.WlyySignFamily.message_success_find, wlyySignFamilyService.findByCode(code));
            return Envelop.getSuccess(WlyyContants.SignFamily.message_success_find, wlyySignFamilyService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.WlyySignFamily.api_queryPage, method = RequestMethod.GET)
    @RequestMapping(value =WlyyContants.SignFamily.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -89,11 +90,11 @@ public class WlyySignFamilyController extends EnvelopRestController {
        //封装返回格式
        List<WlyySignFamily> wlyySignFamily = convertToModels(list, new ArrayList<>(list.size()), WlyySignFamily.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.WlyySignFamily.message_success_find_functions,wlyySignFamily, page, size,count);
        return Envelop.getSuccessListWithPage(WlyyContants.SignFamily.message_success_find_functions,wlyySignFamily, page, size,count);
    }
    @GetMapping(value =WlyyContants.WlyySignFamily.api_getList)
    @GetMapping(value =WlyyContants.SignFamily.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -106,7 +107,7 @@ public class WlyySignFamilyController extends EnvelopRestController {
        List<WlyySignFamily> list = wlyySignFamilyService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyySignFamily> wlyySignFamily = convertToModels(list, new ArrayList<>(list.size()), WlyySignFamily.class, fields);
        return Envelop.getSuccessList(WlyyContants.WlyySignFamily.message_success_find_functions,wlyySignFamily);
        return Envelop.getSuccessList(WlyyContants.SignFamily.message_success_find_functions,wlyySignFamily);
    }
}

+ 33 - 16
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyySignFamilyService.java

@ -4,13 +4,16 @@ import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.util.IDCard;
import com.yihu.jw.wlyy.Agreement.dao.WlyySignFamilyDao;
import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.Agreement.entity.WlyySignFamily;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.text.ParseException;
/**
 * Created by Administrator on 2017/6/2 0002.
@ -21,8 +24,11 @@ public class WlyySignFamilyService extends BaseJpaService<WlyySignFamily, WlyySi
    @Autowired
    private WlyySignFamilyDao wlyySignFamilyDao;
    @Autowired
    private WlyyAgreementService wlyyAgreementService;
    @Transient
    public WlyySignFamily create(WlyySignFamily wlyySignFamily) {
    public WlyySignFamily create(WlyySignFamily wlyySignFamily) throws ParseException {
        boolean b = canSaveOrUpdate(wlyySignFamily);
        if(b){
            return wlyySignFamilyDao.save(wlyySignFamily);
@ -31,7 +37,7 @@ public class WlyySignFamilyService extends BaseJpaService<WlyySignFamily, WlyySi
    }
    @Transient
    public WlyySignFamily update(WlyySignFamily wlyySignFamily) {
    public WlyySignFamily update(WlyySignFamily wlyySignFamily) throws ParseException {
        boolean b = canSaveOrUpdate(wlyySignFamily);
        if(b){
            return wlyySignFamilyDao.save(wlyySignFamily);
@ -43,39 +49,50 @@ public class WlyySignFamilyService extends BaseJpaService<WlyySignFamily, WlyySi
        return wlyySignFamilyDao.findByCode(code);
    }
    private boolean canSaveOrUpdate(WlyySignFamily wlyySignFamily){
    private boolean canSaveOrUpdate(WlyySignFamily wlyySignFamily) throws ParseException {
        if (StringUtils.isEmpty(wlyySignFamily.getCode())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getType())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_type_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getName())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_name_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getIdcard())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_idCard_is_null, CommonContants.common_error_params_code);
        String idcard = wlyySignFamily.getIdcard();
        if (StringUtils.isEmpty(idcard)) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_idCard_is_null, CommonContants.common_error_params_code);
        }
        String s = new IDCard().IDCardValidate(idcard);//不为空字符串,说明身份证有问题啦
        if(!StringUtils.isEmpty(s)){
            throw new ApiException(s, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getSsc())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_ssc_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_ssc_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getHospital())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_hospital_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_hospital_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getHospitalName())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_hospitalName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_hospitalName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getStatus())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getExpenses())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_expense_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_expense_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getExpensesStatus())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_expenseStatus_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.SignFamily.message_fail_expenseStatus_is_null, CommonContants.common_error_params_code);
        }
        String agreementCode = wlyySignFamily.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.SignFamily.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyySignFamily.getAgreementCode())) {
            throw new ApiException(WlyyContants.WlyySignFamily.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        //根据agreementCode查找协议是否存在
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        return true;
    }