|
@@ -59,6 +59,8 @@
|
|
|
|
|
|
<option value="file1">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/InstitutionService.go (100.0%)</option>
|
|
|
|
|
|
+ <option value="file2">bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/service/claim.go (93.5%)</option>
|
|
|
+
|
|
|
</select>
|
|
|
</div>
|
|
|
<div id="legend">
|
|
@@ -96,7 +98,7 @@ type AuthService struct{}
|
|
|
func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span class="cov10" title="4">{
|
|
|
//先判断用户是否存在
|
|
|
user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
|
|
|
- "user_id": in.UserId,"appid":in.Appid,
|
|
|
+ "user_id": in.UserId, "appid": in.Appid,
|
|
|
}, "id", "")
|
|
|
if user != nil </span><span class="cov5" title="2">{
|
|
|
if in.OperationType == "add" </span><span class="cov1" title="1">{
|
|
@@ -111,15 +113,15 @@ func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span
|
|
|
<span class="cov5" title="2">if in.OperationType == "update" </span><span class="cov1" title="1">{
|
|
|
//修改处理
|
|
|
data := map[string]interface{}{
|
|
|
- "name": in.Name,
|
|
|
- "phone": in.Phone,
|
|
|
+ "name": in.Name,
|
|
|
+ "phone": in.Phone,
|
|
|
"position": in.Position,
|
|
|
"department": in.Department,
|
|
|
- "mail": in.Mail,
|
|
|
+ "mail": in.Mail,
|
|
|
"ent_code": in.EntCode,
|
|
|
"ent_name": in.EntName,
|
|
|
}
|
|
|
- ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId,"appid":in.Appid}, data)
|
|
|
+ ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid}, data)
|
|
|
if ok1 </span><span class="cov1" title="1">{
|
|
|
return true, ""
|
|
|
}</span> else<span class="cov0" title="0"> {
|
|
@@ -129,16 +131,16 @@ func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span
|
|
|
} else<span class="cov1" title="1"> {
|
|
|
//新增处理
|
|
|
data := map[string]interface{}{
|
|
|
- "name": in.Name,
|
|
|
- "phone": in.Phone,
|
|
|
+ "name": in.Name,
|
|
|
+ "phone": in.Phone,
|
|
|
"position": in.Position,
|
|
|
"department": in.Department,
|
|
|
- "mail": in.Mail,
|
|
|
+ "mail": in.Mail,
|
|
|
"ent_code": in.EntCode,
|
|
|
"ent_name": in.EntName,
|
|
|
"user_id": in.UserId,
|
|
|
"create_time": time.Now().Local(),
|
|
|
- "appid":in.Appid,
|
|
|
+ "appid": in.Appid,
|
|
|
}
|
|
|
ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
|
|
|
if ok > 0 </span><span class="cov1" title="1">{
|
|
@@ -154,7 +156,7 @@ func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) <span
|
|
|
func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} <span class="cov5" title="2">{
|
|
|
//先判断用户是否存在
|
|
|
user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
|
|
|
- "user_id": in.UserId,"appid":in.Appid,
|
|
|
+ "user_id": in.UserId, "appid": in.Appid,
|
|
|
}, "id", "")
|
|
|
return user
|
|
|
}</span>
|
|
@@ -176,6 +178,107 @@ func (b InstitutionService) GetFilterItem() (levelList, typeList *[]map[string]i
|
|
|
typeList = entity.Mysql.Find(entity.CODE_MEDICAL_INSTITUTION_TYPE, nil, "*", "", -1, -1)
|
|
|
return
|
|
|
}</span>
|
|
|
+</pre>
|
|
|
+
|
|
|
+ <pre class="file" id="file2" style="display: none">package service
|
|
|
+
|
|
|
+import (
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
|
|
|
+ "github.com/zeromicro/go-zero/core/logx"
|
|
|
+)
|
|
|
+
|
|
|
+// EntClaimService 企业认领
|
|
|
+type EntClaimService struct {
|
|
|
+ *entity.Conn
|
|
|
+}
|
|
|
+
|
|
|
+// NewEntClaimSrv 创建一个EntClaimSrv实例
|
|
|
+func NewEntClaimSrv(conn *entity.Conn) *EntClaimService <span class="cov1" title="1">{
|
|
|
+ return &EntClaimService{
|
|
|
+ conn,
|
|
|
+ }
|
|
|
+}</span>
|
|
|
+
|
|
|
+// Claim 认领
|
|
|
+func (e *EntClaimService) Claim(data *entity.EntClaim) bool <span class="cov6" title="2">{
|
|
|
+ if e.IsClaimed(data.UserId, data.AppId, data.EntId, data.Type) </span><span class="cov0" title="0">{
|
|
|
+ return true
|
|
|
+ }</span>
|
|
|
+ <span class="cov6" title="2">return e.BaseMysql.Insert(entity.TableDomainEntClaim, common.StructToMapMore(data)) > 0</span>
|
|
|
+}
|
|
|
+
|
|
|
+// Unclaimed // 取消认领
|
|
|
+func (e *EntClaimService) Unclaimed(id, userId int) bool <span class="cov10" title="3">{
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "id": id,
|
|
|
+ }
|
|
|
+ // 1. 查询该条数据
|
|
|
+ rs := e.BaseMysql.FindOne(entity.TableDomainEntClaim, query, "user_id", "")
|
|
|
+ if rs == nil || len(*rs) == 0 </span><span class="cov1" title="1">{
|
|
|
+ logx.Errorf("取消认领:无效的id %v", id)
|
|
|
+ return false
|
|
|
+ }</span>
|
|
|
+ // 2. 存在则判断是否是该用户的
|
|
|
+ <span class="cov6" title="2">rsUerId := common.IntAll((*rs)["user_id"])
|
|
|
+ if rsUerId != userId </span><span class="cov1" title="1">{
|
|
|
+ logx.Errorf("取消认领:id[%v]与用户id[%v]不匹配 ", id, userId)
|
|
|
+ return false
|
|
|
+ }</span>
|
|
|
+ // 3. 取消认领
|
|
|
+ <span class="cov1" title="1">update := map[string]interface{}{
|
|
|
+ "status": entity.StatusUnClaimed,
|
|
|
+ "update_time": date.NowFormat(date.Date_Full_Layout),
|
|
|
+ }
|
|
|
+ return e.BaseMysql.Update(entity.TableDomainEntClaim, query, update)</span>
|
|
|
+}
|
|
|
+
|
|
|
+// IsClaimed 是否认领
|
|
|
+func (e *EntClaimService) IsClaimed(userId int, appId string, entId string, typeCode int) bool <span class="cov10" title="3">{
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "type": typeCode,
|
|
|
+ "ent_id": entId,
|
|
|
+ "status": entity.StatusClaimed,
|
|
|
+ }
|
|
|
+ return e.BaseMysql.Count(entity.TableDomainEntClaim, query) > 0
|
|
|
+}</span>
|
|
|
+
|
|
|
+// DistributorList 关注的经销商列表
|
|
|
+func (e *EntClaimService) DistributorList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
|
|
|
+
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "appid": appId,
|
|
|
+ "type": entity.TypeDistributor,
|
|
|
+ "status": entity.StatusClaimed,
|
|
|
+ }
|
|
|
+ field := "id,appid,user_id,ent_id,ent_name,address,create_time"
|
|
|
+ order := "create_time desc"
|
|
|
+ total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
|
|
|
+ if total == 0 </span><span class="cov6" title="2">{
|
|
|
+ return nil, 0
|
|
|
+ }</span>
|
|
|
+ <span class="cov0" title="0">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
|
|
|
+}
|
|
|
+
|
|
|
+// InstitutionList 我关注的医疗机构列表
|
|
|
+func (e *EntClaimService) InstitutionList(userId int, appId string, page int, pageSize int) (*[]map[string]interface{}, int) <span class="cov6" title="2">{
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "appid": appId,
|
|
|
+ "type": entity.TypeInstitution,
|
|
|
+ "status": entity.StatusClaimed,
|
|
|
+ }
|
|
|
+ field := "id,appid,user_id,ent_id,ent_name,address,create_time"
|
|
|
+ order := "create_time desc"
|
|
|
+ total := e.BaseMysql.Count(entity.TableDomainEntClaim, query)
|
|
|
+ if total == 0 </span><span class="cov1" title="1">{
|
|
|
+ return nil, 0
|
|
|
+ }</span>
|
|
|
+ <span class="cov1" title="1">return e.BaseMysql.Find(entity.TableDomainEntClaim, query, field, order, (page-1)*pageSize, pageSize), int(total)</span>
|
|
|
+}
|
|
|
</pre>
|
|
|
|
|
|
</div>
|